Repository Public License
1import Foundation2import PrismComponentSDK3import PrismCore45/// Catalog family C: data views, charts, commerce and social.6extension Catalog {7 static let familyC: [ComponentManifest] = familyCCharts + familyCDataViews + familyCLists + familyCCommerce89 // MARK: Builders1011 /// A fixture table: `columns` are `(name, type)`, each row lists the values in the same order.12 private static func cTable(_ id: String, _ name: String, _ columns: [(String, String)], _ rows: [[JSONValue]]) -> JSONValue {13 let seed = rows.map { row in JSONValue.object(Dictionary(uniqueKeysWithValues: zip(columns.map(\.0), row))) }14 return ["id": .string(id), "type": "prism.data.table", "name": .string(name), "props": [15 "columns": .array(columns.map { ["name": .string($0.0), "type": .string($0.1)] }), "seed": .array(seed),16 ]]17 }1819 private static let cProducts = cTable("fx_products", "Products", [("name", "text"), ("category", "text"), ("price", "currency"), ("rating", "number"), ("sold", "integer")], [20 ["Desk lamp", "Home", 39, 4.4, 320], ["Notebook", "Office", 6.5, 4.7, 910], ["Headphones", "Audio", 129, 4.1, 240],21 ["Backpack", "Travel", 74, 4.6, 410], ["Water bottle", "Travel", 18, 3.9, 620], ["Keyboard", "Office", 89, 4.5, 180],22 ])23 private static let cPrices = cTable("fx_prices", "Prices", [("day", "date"), ("open", "number"), ("high", "number"), ("low", "number"), ("close", "number")], [24 ["2026-03-02", 102, 108, 100, 106], ["2026-03-03", 106, 111, 104, 105], ["2026-03-04", 105, 107, 98, 99], ["2026-03-05", 99, 104, 97, 103],25 ["2026-03-06", 103, 112, 102, 110], ["2026-03-09", 110, 114, 107, 108], ["2026-03-10", 108, 116, 108, 115],26 ])27 private static let cVisits = cTable("fx_visits", "Visits", [("day", "text"), ("slot", "text"), ("visits", "integer")], [28 ["Mon", "Morning", 12], ["Mon", "Afternoon", 30], ["Mon", "Evening", 18], ["Tue", "Morning", 20], ["Tue", "Afternoon", 44], ["Tue", "Evening", 9],29 ["Wed", "Morning", 7], ["Wed", "Afternoon", 26], ["Wed", "Evening", 35], ["Thu", "Morning", 16], ["Thu", "Afternoon", 51], ["Thu", "Evening", 22],30 ])31 private static let cStages = cTable("fx_stages", "Stages", [("stage", "text"), ("people", "integer")], [["Visitors", 1200], ["Sign-ups", 480], ["Trials", 210], ["Customers", 85]])32 private static let cFlow = cTable("fx_flow", "Cash flow", [("step", "text"), ("change", "currency")], [["Sales", 4200], ["Services", 1300], ["Salaries", -2600], ["Rent", -900], ["Marketing", -450]])33 private static let cSkills = cTable("fx_skills", "Skills", [("skill", "text"), ("score", "number")], [["Design", 8], ["Code", 9], ["Writing", 6], ["Speaking", 5], ["Planning", 7]])34 private static let cSales = cTable("fx_sales", "Sales", [("quarter", "text"), ("region", "text"), ("revenue", "currency")], [35 ["Q1", "North", 4200], ["Q1", "South", 3100], ["Q2", "North", 4800], ["Q2", "South", 3900], ["Q3", "North", 5100], ["Q3", "South", 3600], ["Q4", "North", 6200], ["Q4", "South", 4700],36 ])37 private static let cCart = cTable("fx_cart", "Cart lines", [("order_id", "integer"), ("product", "text"), ("price", "currency"), ("quantity", "integer")], [38 [1, "Notebook", 6.5, 4], [1, "Desk lamp", 39, 1], [1, "Backpack", 74, 1], [2, "Keyboard", 89, 2],39 ])40 private static let cMessages = cTable("fx_messages", "Messages", [("author", "text"), ("text", "text"), ("date", "date")], [41 ["Ada", "Did the new export ship?", "2026-03-01"], ["Me", "Yes, it went out this morning.", "2026-03-01"],42 ["Ada", "Great. I will tell the team.", "2026-03-02"], ["Lin", "Works on my side too.", "2026-03-03"],43 ])44 private static let cTasks = cTable("fx_tasks", "Tasks", [("task", "text"), ("owner", "text"), ("progress", "number"), ("done", "boolean")], [45 ["Design review", "Ada", 1, true], ["API migration", "Lin", 0.65, false], ["User guide", "Sam", 0.4, false], ["Launch plan", "Ada", 0.15, false],46 ])4748 private static let cQuery = PropSpec("query", .query, "Rows to read: `{table, filters?, search?, sort?, groupBy?, aggregates?, limit?}` or `{$ref: queryId}`.", required: true, dynamic: false)49 private static let cTitle = PropSpec("title", .string, "Heading above the content.")50 private static let cFormat = PropSpec("format", .enum, "How values are written.", default: "number", values: ["number", "currency", "percent"], dynamic: false)51 private static let cAutoFormat = PropSpec("format", .enum, "How the value is written; by default it follows the column's type.", values: ["text", "number", "currency", "percent", "date"], dynamic: false)52 private static let cSelection = PropSpec("selection", .any, "State key that receives the clicked record's id.", dynamic: false, binding: .optional)53 private static let cSort = PropSpec("sort", .object, "Sort override `{column, descending}`, usually `{$expr: \"state.sort\"}` written by a `prism.sortMenu`.")54 private static let cTaxRate = PropSpec("taxRate", .number, "Tax as a fraction of the subtotal, e.g. 0.15 for 15 %.", default: 0)55 private static func cCol(_ name: String, _ summary: String, required: Bool = false) -> PropSpec { PropSpec(name, .string, summary, required: required, dynamic: false) }5657 /// One manifest; `example` and `preview` are the props of the example object and of the fixture.58 private static func c(59 _ type: String, _ name: String, _ category: String, _ summary: String, _ props: [PropSpec], events: [String] = [], data: Bool = true,60 keywords: [String], role: String, label: String? = nil, example: JSONValue, preview: JSONValue, state: JSONValue = [:], tables: [JSONValue] = []61 ) -> ComponentManifest {62 ComponentManifest(63 type: type, name: name, category: category, summary: summary, props: props, events: events, permissions: data ? storage : [], keywords: keywords,64 accessibilityRole: role, accessibilityLabelProp: label,65 examples: [["id": .string(String(type.dropFirst(6)).replacingOccurrences(of: ".", with: "_") + "_1"), "type": .string(type), "props": example]],66 fixture: fixture(type, preview, state: state, extra: tables, permissions: tables.isEmpty ? [] : storage)67 )68 }6970 private static func cChart(_ type: String, _ name: String, _ summary: String, _ props: [PropSpec], keywords: [String], example: JSONValue, preview: JSONValue, tables: [JSONValue]) -> ComponentManifest {71 c(type, name, "charts", summary, [cQuery] + props + [PropSpec("title", .string, "Chart title.")], keywords: keywords, role: "chart", label: "title", example: example, preview: preview, tables: tables)72 }7374 private static let cTone = PropSpec("tone", .enum, "Semantic color of the marks; neutral uses the app's accent.", default: "neutral", values: tones, dynamic: true)75 private static let cGrouped: JSONValue = ["table": "orders", "groupBy": ["column": "status", "as": "status"], "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]7677 // MARK: Charts7879 static let familyCCharts: [ComponentManifest] = [80 cChart("prism.chart.area", "Area chart", "A filled line over an ordered axis: volume or a cumulative trend, e.g. revenue per period.",81 [cCol("x", "Result column for the horizontal axis.", required: true), cCol("y", "Numeric result column.", required: true), cFormat, cTone],82 keywords: ["area", "filled line", "trend", "time series", "volume", "graph"],83 example: ["title": "Revenue per year", "x": "year", "y": "total", "format": "currency", "query": ["table": "orders", "groupBy": ["column": "date", "bucket": "year", "as": "year"], "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]],84 preview: ["title": "Spending per month", "x": "month", "y": "total", "format": "currency", "query": byMonth], tables: [sampleTable]),85 cChart("prism.chart.scatter", "Scatter plot", "Points placed by two numeric columns, to see how one measure relates to another (correlation, outliers).",86 [cCol("x", "Numeric column for the horizontal axis.", required: true), cCol("y", "Numeric column for the vertical axis.", required: true),87 cCol("labelColumn", "Column whose text is written next to each point."), cFormat, cTone],88 keywords: ["scatter", "points", "correlation", "xy", "relationship", "outliers", "graph"],89 example: ["title": "Price vs. units sold", "x": "price", "y": "sold", "query": ["table": "products"]],90 preview: ["title": "Price vs. units sold", "x": "price", "y": "sold", "labelColumn": "name", "query": ["table": "fx_products"]], tables: [cProducts]),91 cChart("prism.chart.stackedBar", "Stacked bar chart", "Bars split into colored segments by a series column: how each group's total is composed, e.g. revenue per quarter by region.",92 [cCol("x", "Column for the horizontal axis (one bar per value).", required: true), cCol("y", "Numeric column that is stacked.", required: true),93 cCol("series", "Column that splits each bar into segments.", required: true), cFormat],94 keywords: ["stacked", "bars", "segments", "composition", "series", "breakdown", "graph"],95 example: ["title": "Revenue by region", "x": "quarter", "y": "revenue", "series": "region", "format": "currency", "query": ["table": "sales"]],96 preview: ["title": "Revenue by region", "x": "quarter", "y": "revenue", "series": "region", "format": "currency", "query": ["table": "fx_sales"]], tables: [cSales]),97 cChart("prism.chart.horizontalBar", "Horizontal bar chart", "Horizontal bars with a value at the end of each: best for ranking groups with long names.",98 [cCol("label", "Result column naming each bar.", required: true), cCol("value", "Numeric result column.", required: true), cFormat, cTone],99 keywords: ["horizontal", "bars", "ranking", "compare", "long labels", "graph"],100 example: ["title": "Total by status", "label": "status", "value": "total", "format": "currency", "query": cGrouped],101 preview: ["title": "Spending by category", "label": "category", "value": "total", "format": "currency", "query": byCategory], tables: [sampleTable]),102 cChart("prism.chart.multiLine", "Multi-line chart", "One line per series over a shared axis, to compare several trends, e.g. revenue per quarter for each region.",103 [cCol("x", "Column for the horizontal axis.", required: true), cCol("y", "Numeric column.", required: true),104 cCol("series", "Column that names each line.", required: true), cFormat],105 keywords: ["lines", "series", "compare trends", "multiple", "time series", "graph"],106 example: ["title": "Revenue per quarter", "x": "quarter", "y": "revenue", "series": "region", "format": "currency", "query": ["table": "sales"]],107 preview: ["title": "Revenue per quarter", "x": "quarter", "y": "revenue", "series": "region", "format": "currency", "query": ["table": "fx_sales"]], tables: [cSales]),108 cChart("prism.chart.heatmap", "Heatmap", "A grid of cells colored by value for two categories (x and y), e.g. visits per weekday and time of day; rows sharing a cell are added up.",109 [cCol("x", "Column for the horizontal categories.", required: true), cCol("y", "Column for the vertical categories.", required: true),110 cCol("value", "Numeric column that sets each cell's intensity.", required: true),111 PropSpec("showValues", .boolean, "Write the value inside each cell.", default: true, dynamic: false), cFormat, cTone],112 keywords: ["heat map", "matrix", "density", "intensity", "grid", "weekday", "calendar"],113 example: ["title": "Visits by day and time", "x": "day", "y": "slot", "value": "visits", "query": ["table": "visits"]],114 preview: ["title": "Visits by day and time", "x": "day", "y": "slot", "value": "visits", "query": ["table": "fx_visits"]], tables: [cVisits]),115 cChart("prism.chart.histogram", "Histogram", "The distribution of a numeric column: its values are sorted into equal-width bins and each bar counts the records in a bin.",116 [cCol("value", "Numeric column to distribute.", required: true), PropSpec("bins", .number, "Number of bins (1 to 100).", default: 10, dynamic: false), cFormat, cTone],117 keywords: ["distribution", "bins", "frequency", "spread", "buckets", "statistics"],118 example: ["title": "Order sizes", "value": "amount", "bins": 8, "format": "currency", "query": ["table": "orders"]],119 preview: ["title": "Price distribution", "value": "price", "bins": 6, "format": "currency", "query": ["table": "fx_products"]], tables: [cProducts]),120 cChart("prism.chart.gauge", "Gauge", "A half-circle dial showing one aggregate between a minimum and a maximum, e.g. revenue against a goal.",121 [cCol("value", "Result column of the query's first row.", required: true), PropSpec("min", .number, "Value at the start of the dial.", default: 0),122 PropSpec("max", .number, "Value at the end of the dial.", default: 100), cFormat, cTone],123 keywords: ["dial", "meter", "goal", "speedometer", "kpi", "progress"],124 example: ["title": "Revenue vs. goal", "value": "total", "min": 0, "max": 10000, "format": "currency", "query": ["table": "orders", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]],125 preview: ["title": "Spent of 4,000", "value": "total", "min": 0, "max": 4000, "format": "currency", "tone": "accent", "query": ["table": "fx_items", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]], tables: [sampleTable]),126 cChart("prism.chart.radar", "Radar chart", "A spider web with one axis per row (three or more), to compare several scores of one subject at a glance.",127 [cCol("label", "Result column naming each axis.", required: true), cCol("value", "Numeric result column.", required: true),128 PropSpec("max", .number, "Value at the outer edge; defaults to the largest value."), cFormat, cTone],129 keywords: ["spider", "web", "skills", "scores", "profile", "polygon"],130 example: ["title": "Skills", "label": "skill", "value": "score", "max": 10, "query": ["table": "skills"]],131 preview: ["title": "Skills", "label": "skill", "value": "score", "max": 10, "query": ["table": "fx_skills"]], tables: [cSkills]),132 cChart("prism.chart.funnel", "Funnel chart", "Ordered stages as centered bars that narrow, each with its value and its share of the first stage (conversion).",133 [cCol("label", "Result column naming each stage, in order.", required: true), cCol("value", "Numeric result column.", required: true), cFormat, cTone],134 keywords: ["funnel", "conversion", "stages", "pipeline", "drop-off", "sales"],135 example: ["title": "Sign-up funnel", "label": "stage", "value": "people", "query": ["table": "stages"]],136 preview: ["title": "Sign-up funnel", "label": "stage", "value": "people", "query": ["table": "fx_stages"]], tables: [cStages]),137 cChart("prism.chart.sparkline", "Sparkline", "A tiny line without axes that fits in a row, a card or next to a number, with the latest value beside it.",138 [cCol("y", "Numeric column, one point per row in query order.", required: true), PropSpec("showValue", .boolean, "Write the last value after the line.", default: true, dynamic: false),139 PropSpec("fill", .boolean, "Shade the area under the line.", default: false, dynamic: false), cFormat, cTone],140 keywords: ["spark", "tiny", "inline", "trend", "mini", "microchart"],141 example: ["title": "Close", "y": "close", "query": ["table": "prices", "sort": [["column": "day"]]]],142 preview: ["title": "Close", "y": "close", "fill": true, "query": ["table": "fx_prices", "sort": [["column": "day"]]]], tables: [cPrices]),143 cChart("prism.chart.treemap", "Treemap", "Nested rectangles whose areas are proportional to a value: shares of a whole when there are many groups.",144 [cCol("label", "Result column naming each rectangle.", required: true), cCol("value", "Numeric result column (positive values).", required: true), cFormat],145 keywords: ["treemap", "rectangles", "proportion", "share", "hierarchy", "mosaic", "area"],146 example: ["title": "Units sold", "label": "name", "value": "sold", "query": ["table": "products"]],147 preview: ["title": "Units sold", "label": "name", "value": "sold", "query": ["table": "fx_products"]], tables: [cProducts]),148 cChart("prism.chart.waterfall", "Waterfall chart", "Signed values as floating bars on a running total (gains up, losses down), ending with the total: how a result is built up.",149 [cCol("label", "Result column naming each step.", required: true), cCol("value", "Signed numeric result column.", required: true),150 PropSpec("showTotal", .boolean, "Add a final bar with the running total.", default: true, dynamic: false),151 PropSpec("totalLabel", .string, "Name of the final bar.", default: "Total"), cFormat, cTone],152 keywords: ["waterfall", "running total", "bridge", "cash flow", "profit", "contributions", "cumulative"],153 example: ["title": "Cash flow", "label": "step", "value": "change", "format": "currency", "totalLabel": "Net", "query": ["table": "cash_flow"]],154 preview: ["title": "Cash flow", "label": "step", "value": "change", "format": "currency", "totalLabel": "Net", "query": ["table": "fx_flow"]], tables: [cFlow]),155 cChart("prism.chart.candlestick", "Candlestick chart", "Open, high, low and close per period as candles (green up, red down), for prices and other ranges over time.",156 [cCol("x", "Column naming each period, e.g. a date.", required: true), cCol("open", "Numeric column with the opening value.", required: true),157 cCol("high", "Numeric column with the highest value.", required: true), cCol("low", "Numeric column with the lowest value.", required: true),158 cCol("close", "Numeric column with the closing value.", required: true), cFormat],159 keywords: ["candles", "ohlc", "stock", "price", "trading", "finance", "market"],160 example: ["title": "Daily price", "x": "day", "open": "open", "high": "high", "low": "low", "close": "close", "query": ["table": "prices", "sort": [["column": "day"]]]],161 preview: ["title": "Daily price", "x": "day", "open": "open", "high": "high", "low": "low", "close": "close", "format": "currency", "query": ["table": "fx_prices", "sort": [["column": "day"]]]], tables: [cPrices]),162 cChart("prism.chart.bullet", "Bullet chart", "One measure as a bar against a target mark, over shaded qualitative ranges (poor, fair, good): compact progress toward a goal.",163 [cCol("value", "Result column of the query's first row.", required: true), PropSpec("target", .number, "Where the target mark is drawn."),164 PropSpec("ranges", .list, "Upper bounds of the shaded ranges, ascending, e.g. [2000, 3500]."),165 PropSpec("max", .number, "End of the scale; defaults to fit the value, target and ranges."), cFormat, cTone],166 keywords: ["bullet", "target", "goal", "ranges", "kpi", "performance", "actual vs target"],167 example: ["title": "Revenue", "value": "total", "target": 9000, "ranges": [5000, 8000], "max": 10000, "format": "currency", "query": ["table": "orders", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]],168 preview: ["title": "Spending", "value": "total", "target": 3000, "ranges": [1500, 3200], "max": 4000, "format": "currency", "query": ["table": "fx_items", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]]], tables: [sampleTable]),169 cChart("prism.chart.bubble", "Bubble chart", "A scatter plot whose points grow with a third numeric column: three measures per record at once.",170 [cCol("x", "Numeric column for the horizontal axis.", required: true), cCol("y", "Numeric column for the vertical axis.", required: true),171 cCol("size", "Numeric column that sets each bubble's area.", required: true), cCol("labelColumn", "Column whose text is written on each bubble."), cFormat, cTone],172 keywords: ["bubbles", "scatter", "three measures", "size", "xy", "portfolio", "graph"],173 example: ["title": "Price, rating and sales", "x": "price", "y": "rating", "size": "sold", "query": ["table": "products"]],174 preview: ["title": "Price, rating and sales", "x": "price", "y": "rating", "size": "sold", "labelColumn": "name", "query": ["table": "fx_products"]], tables: [cProducts]),175 ]176177 // MARK: Data views178179 static let familyCDataViews: [ComponentManifest] = [180 c("prism.pivot", "Pivot table", "data", "A cross-tabulation computed from a query's rows: one line per value of `row`, one column per value of `column`, an aggregate in each cell, with totals.",181 [cQuery, cCol("row", "Column whose values become the lines.", required: true), cCol("column", "Column whose values become the columns.", required: true),182 cCol("valueColumn", "Numeric column to aggregate; not needed for `count`."),183 PropSpec("aggregate", .enum, "How each cell is computed; defaults to sum, or count without a `valueColumn`.", values: ["sum", "count", "avg", "min", "max"], dynamic: false),184 PropSpec("showTotals", .boolean, "Add a total column and a total line.", default: true, dynamic: false), cAutoFormat, cTitle],185 keywords: ["crosstab", "cross tabulation", "matrix", "rows by columns", "summarize", "aggregate"], role: "table", label: "title",186 example: ["title": "Revenue by region and quarter", "row": "region", "column": "quarter", "valueColumn": "revenue", "aggregate": "sum", "query": ["table": "sales"]],187 preview: ["title": "Revenue by region and quarter", "row": "region", "column": "quarter", "valueColumn": "revenue", "aggregate": "sum", "query": ["table": "fx_sales"]], tables: [cSales]),188 c("prism.dataGrid", "Editable grid", "data", "A spreadsheet-like grid of a table where every cell is editable in place: pressing Return or leaving a cell updates the record.",189 [cCol("table", "The table to edit.", required: true), PropSpec("columns", .list, "Column names to show; defaults to all.", dynamic: false),190 PropSpec("limit", .number, "Most rows shown at once.", default: 100, dynamic: false), cTitle],191 events: ["saved"], keywords: ["spreadsheet", "inline edit", "editable cells", "bulk edit", "cells", "quick edit"], role: "table", label: "title",192 example: ["table": "products", "title": "Products", "columns": ["name", "price", "stock"]],193 preview: ["table": "fx_items", "title": "Items", "columns": ["title", "category", "amount"]], tables: [sampleTable]),194 c("prism.cardList", "Card list", "data", "One card per row with a title, a subtitle, a badge and a value taken from columns; clicking a card selects the record.",195 [cQuery, cCol("titleColumn", "Column shown as each card's title.", required: true), cCol("subtitleColumn", "Column shown under the title."),196 cCol("badgeColumn", "Column shown as a badge."), cCol("valueColumn", "Column shown large on the right."), cAutoFormat, cSelection, cSort,197 PropSpec("emptyText", .string, "Text when there are no rows.")],198 events: ["select"], keywords: ["cards", "tiles", "rows as cards", "feed", "master list", "items"], role: "list",199 example: ["titleColumn": "name", "subtitleColumn": "category", "valueColumn": "price", "selection": ["$bind": "selectedId"], "query": ["table": "products"]],200 preview: ["titleColumn": "title", "subtitleColumn": "date", "badgeColumn": "category", "valueColumn": "amount", "selection": ["$bind": "selected"], "query": ["table": "fx_items", "limit": 4]],201 state: ["selected": 2], tables: [sampleTable]),202 c("prism.gallery", "Gallery", "data", "A grid of tiles, one per row, each with a symbol or the title's initials, a title and a caption; clicking a tile selects the record.",203 [cQuery, cCol("titleColumn", "Column shown as each tile's title.", required: true), cCol("captionColumn", "Column shown under the title."),204 PropSpec("symbol", .string, "SF Symbol drawn on every tile; initials are drawn when omitted."), cCol("symbolColumn", "Column holding an SF Symbol name per row."),205 PropSpec("tilesPerRow", .number, "Number of tiles per line (1 to 12).", default: 4, dynamic: false), cSelection],206 events: ["select"], keywords: ["tiles", "thumbnails", "icons", "album", "catalogue", "people", "initials"], role: "grid",207 example: ["titleColumn": "name", "captionColumn": "category", "tilesPerRow": 4, "query": ["table": "products"]],208 preview: ["titleColumn": "name", "captionColumn": "category", "tilesPerRow": 3, "selection": ["$bind": "selected"], "query": ["table": "fx_products"]], state: ["selected": nil], tables: [cProducts]),209 c("prism.recordDetail", "Record detail", "data", "A read-only label and value view of one record chosen by id, e.g. the row selected in a table.",210 [cCol("table", "The record's table.", required: true), PropSpec("recordId", .any, "Id of the record to show.", required: true, binding: .optional),211 PropSpec("fields", .list, "Column names to show; defaults to all.", dynamic: false), PropSpec("emptyText", .string, "Text when no id is given."), cTitle],212 keywords: ["details", "read only", "show record", "properties", "summary", "inspector"], role: "group", label: "title",213 example: ["table": "products", "recordId": ["$bind": "selectedId"], "title": "Product"],214 preview: ["table": "fx_items", "recordId": 2, "title": "Item"], tables: [sampleTable]),215 c("prism.recordCard", "Record card", "data", "A compact card for one record chosen by id: avatar, title, subtitle, badge and a value.",216 [cCol("table", "The record's table.", required: true), PropSpec("recordId", .any, "Id of the record to show.", required: true, binding: .optional),217 cCol("titleColumn", "Column shown as the title.", required: true), cCol("subtitleColumn", "Column shown under the title."),218 cCol("badgeColumn", "Column shown as a badge."), cCol("valueColumn", "Column shown large on the right."),219 PropSpec("symbol", .string, "SF Symbol for the avatar; initials are drawn when omitted.")],220 keywords: ["summary card", "one record", "header", "preview", "selected item", "compact"], role: "group",221 example: ["table": "products", "recordId": ["$bind": "selectedId"], "titleColumn": "name", "subtitleColumn": "category", "valueColumn": "price"],222 preview: ["table": "fx_products", "recordId": 3, "titleColumn": "name", "subtitleColumn": "category", "valueColumn": "price", "symbol": "headphones"], tables: [cProducts]),223 c("prism.lookup", "Record lookup", "data", "A dropdown listing the records of another table by a label column; the chosen record's id is stored in state (a foreign key picker).",224 [cCol("table", "Table whose records are listed.", required: true), cCol("labelColumn", "Column shown for each record.", required: true),225 PropSpec("value", .any, "State key that receives the chosen record's id (null when none).", required: true, dynamic: false, binding: .required),226 PropSpec("label", .string, "Field label."), PropSpec("placeholder", .string, "Text of the empty choice.", default: "Choose…")],227 events: ["change"], keywords: ["foreign key", "relation", "reference", "pick record", "link", "belongs to"], role: "popUpButton", label: "label",228 example: ["table": "customers", "labelColumn": "name", "label": "Customer", "value": ["$bind": "customerId"]],229 preview: ["table": "fx_products", "labelColumn": "name", "label": "Product", "value": ["$bind": "productId"]], state: ["productId": 2], tables: [cProducts]),230 c("prism.relatedList", "Related list", "data", "The rows of a table whose foreign-key column equals a given id, e.g. the lines of the selected order.",231 [cCol("table", "The child table.", required: true), cCol("foreignKey", "Column of that table holding the parent's id.", required: true),232 PropSpec("parentId", .any, "Id of the parent record.", required: true, binding: .optional),233 PropSpec("columns", .list, "Column names to show; defaults to all but the foreign key.", dynamic: false), PropSpec("emptyText", .string, "Text when nothing is related."), cTitle],234 events: ["select"], keywords: ["children", "one to many", "foreign key", "order lines", "master detail", "linked"], role: "table", label: "title",235 example: ["table": "order_lines", "foreignKey": "order_id", "parentId": ["$bind": "selectedOrder"], "title": "Lines"],236 preview: ["table": "fx_cart", "foreignKey": "order_id", "parentId": 1, "title": "Lines of order 1", "columns": ["product", "quantity", "price"]], tables: [cCart]),237 c("prism.countBadge", "Count badge", "data", "A pill showing how many rows a query returns, e.g. open tasks or unread messages.",238 [cQuery, PropSpec("label", .string, "Text after the number."), PropSpec("icon", .string, "SF Symbol before the number."),239 PropSpec("hideWhenZero", .boolean, "Draw nothing when the count is 0.", default: false, dynamic: false), toneProp],240 keywords: ["counter", "pill", "number of rows", "unread", "how many", "tally"], role: "staticText", label: "label",241 example: ["label": "open", "icon": "tray", "tone": "info", "query": ["table": "tasks", "filters": [["column": "done", "op": "eq", "value": 0]]]],242 preview: ["label": "items", "icon": "tray.full", "tone": "info", "query": ["table": "fx_items"]], tables: [sampleTable]),243 c("prism.groupedList", "Grouped list", "data", "Rows listed under a header per distinct value of a column, with the number of rows in each group.",244 [cQuery, cCol("groupColumn", "Column whose values become the headers.", required: true), cCol("titleColumn", "Column shown on each line.", required: true),245 cCol("detailColumn", "Column shown at the end of each line."), cAutoFormat, PropSpec("showCounts", .boolean, "Show each group's row count.", default: true, dynamic: false), cSelection, cTitle],246 events: ["select"], keywords: ["sections", "headers", "group by", "outline", "categorized", "buckets"], role: "list", label: "title",247 example: ["title": "Tasks by owner", "groupColumn": "owner", "titleColumn": "task", "query": ["table": "tasks"]],248 preview: ["title": "Items by category", "groupColumn": "category", "titleColumn": "title", "detailColumn": "amount", "query": ["table": "fx_items", "sort": [["column": "category"]]]], tables: [sampleTable]),249 c("prism.leaderboard", "Leaderboard", "data", "Rows ranked by a numeric column, with gold, silver and bronze medals for the first three.",250 [cQuery, cCol("labelColumn", "Column naming each entry.", required: true), cCol("valueColumn", "Numeric column to rank by.", required: true),251 PropSpec("limit", .number, "Number of entries shown.", default: 10, dynamic: false), PropSpec("descending", .boolean, "Highest value first.", default: true, dynamic: false), cAutoFormat, cTitle],252 keywords: ["ranking", "medals", "top", "scores", "podium", "best", "winners"], role: "list", label: "title",253 example: ["title": "Best sellers", "labelColumn": "name", "valueColumn": "sold", "limit": 5, "query": ["table": "products"]],254 preview: ["title": "Best sellers", "labelColumn": "name", "valueColumn": "sold", "limit": 5, "query": ["table": "fx_products"]], tables: [cProducts]),255 c("prism.comparison", "Comparison", "data", "A side-by-side table of chosen records (one column each) and chosen fields (one line each).",256 [cCol("table", "The records' table.", required: true), PropSpec("recordIds", .list, "Ids of the records to compare, at most 8.", required: true),257 PropSpec("fields", .list, "Column names to compare; defaults to all.", dynamic: false), cCol("labelColumn", "Column used as each record's heading."), cTitle],258 keywords: ["compare", "side by side", "versus", "specs", "difference", "plans"], role: "table", label: "title",259 example: ["table": "products", "recordIds": ["$expr": "state.compareIds"], "labelColumn": "name", "fields": ["price", "rating"]],260 preview: ["table": "fx_products", "recordIds": [1, 3, 6], "labelColumn": "name", "fields": ["category", "price", "rating", "sold"], "title": "Compare"], tables: [cProducts]),261 c("prism.summaryRow", "Summary row", "data", "Several aggregates of one query side by side in a single strip, e.g. count, total and average of the filtered rows.",262 [cQuery, PropSpec("items", .list, "Aggregates: `{label, fn: sum|count|avg|min|max, column?, format?: number|currency|percent}`, computed over the query's rows.", required: true, dynamic: false), cTitle],263 keywords: ["totals", "aggregates", "footer", "strip", "kpi", "overview", "sum count average"], role: "group", label: "title",264 example: ["query": ["table": "orders"], "items": [["label": "Orders", "fn": "count"], ["label": "Revenue", "fn": "sum", "column": "amount", "format": "currency"]]],265 preview: ["query": ["table": "fx_items"], "items": [["label": "Items", "fn": "count"], ["label": "Total", "fn": "sum", "column": "amount"], ["label": "Average", "fn": "avg", "column": "amount"], ["label": "Largest", "fn": "max", "column": "amount"]]],266 tables: [sampleTable]),267 c("prism.filterBar", "Filter bar", "data",268 "Auto-generated filter controls for chosen columns of a table, written to one state object that query filters read: text column → `state.f.<col>` (text, or the picked value), number → `<col>Min` / `<col>Max`, date → `<col>From` / `<col>To` (YYYY-MM-DD), boolean → 1 or 0; a key is null while unset.",269 [cCol("table", "Table whose columns are filtered.", required: true), PropSpec("columns", .list, "Column names to build a control for.", required: true, dynamic: false),270 PropSpec("value", .object, "State key holding the filter object (declare it as `{}`). Use it in queries, e.g. `{column: \"category\", op: \"eq\", value: {$expr: \"state.f.category\"}, unless: {$expr: \"state.f.category == null\"}}`; `contains` filters skip themselves when empty.", required: true, dynamic: false, binding: .required),271 PropSpec("showClear", .boolean, "Show a Clear button.", default: true, dynamic: false), cTitle],272 events: ["change"], keywords: ["filter", "facets", "narrow", "refine", "criteria", "range", "search options"], role: "group", label: "title",273 example: ["table": "products", "columns": ["category", "price"], "value": ["$bind": "f"]],274 preview: ["table": "fx_items", "columns": ["category", "title", "amount", "date"], "value": ["$bind": "f"]], state: ["f": ["category": "Food", "amountMin": 20]], tables: [sampleTable]),275 c("prism.sortMenu", "Sort menu", "data", "A menu to choose the sort column and direction; writes `{column, descending}` to state, which list components read through their `sort` prop.",276 [PropSpec("columns", .list, "Choices: column names or `{column, title}`.", required: true, dynamic: false),277 PropSpec("value", .object, "State key holding `{column, descending}`.", required: true, dynamic: false, binding: .required),278 PropSpec("label", .string, "Button label.", default: "Sort")],279 events: ["change"], data: false, keywords: ["sort", "order by", "ascending", "descending", "arrange", "reorder list"], role: "menuButton", label: "label",280 example: ["columns": [["column": "name", "title": "Name"], ["column": "price", "title": "Price"]], "value": ["$bind": "sort"]],281 preview: ["columns": [["column": "title", "title": "Title"], ["column": "amount", "title": "Amount"]], "value": ["$bind": "sort"]], state: ["sort": ["column": "amount", "descending": true]]),282 c("prism.columnStats", "Column statistics", "data", "Count, minimum, maximum, average and sum of one numeric column of a query, in a strip.",283 [cQuery, cCol("valueColumn", "Numeric column to describe.", required: true), cAutoFormat, PropSpec("title", .string, "Heading; defaults to the column's label.")],284 keywords: ["statistics", "min max", "average", "mean", "describe", "numbers"], role: "group", label: "title",285 example: ["valueColumn": "amount", "title": "Order amounts", "query": ["table": "orders"]],286 preview: ["valueColumn": "amount", "title": "Amounts", "query": ["table": "fx_items"]], tables: [sampleTable]),287 c("prism.jsonViewer", "JSON viewer", "data", "A collapsible tree of any JSON value, such as a record, a query result or part of the app's state.",288 [PropSpec("value", .any, "The value to inspect, e.g. `{$expr: \"state.settings\"}`.", required: true, binding: .optional),289 PropSpec("expandDepth", .number, "Levels open at first.", default: 1, dynamic: false), cTitle],290 data: false, keywords: ["json", "tree", "inspect", "debug", "object", "raw data", "structure"], role: "outline", label: "title",291 example: ["title": "Settings", "value": ["$expr": "state.settings"]],292 preview: ["title": "Settings", "value": ["$expr": "state.settings"], "expandDepth": 2],293 state: ["settings": ["theme": "dark", "notifications": ["email": true, "push": false], "recent": ["Invoices", "Reports"], "pageSize": 25, "owner": nil]]),294 c("prism.statGrid", "Statistics grid", "data", "A grid of statistic tiles, each with its own query: a dashboard header in one component.",295 [PropSpec("items", .list, "Tiles: `{label, query, valueColumn, format?: number|currency|percent|text, icon?}`; the first row of each query is used.", required: true, dynamic: false),296 PropSpec("perRow", .number, "Tiles per line (1 to 8).", default: 3, dynamic: false)],297 keywords: ["kpi", "metrics", "tiles", "dashboard", "numbers", "overview", "stats"], role: "group",298 example: ["perRow": 2, "items": [299 ["label": "Orders", "query": ["table": "orders", "aggregates": [["fn": "count", "as": "n"]]], "valueColumn": "n"],300 ["label": "Revenue", "format": "currency", "query": ["table": "orders", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]], "valueColumn": "total"]]],301 preview: ["perRow": 3, "items": [302 ["label": "Items", "icon": "number", "query": ["table": "fx_items", "aggregates": [["fn": "count", "as": "n"]]], "valueColumn": "n"],303 ["label": "Total", "icon": "sum", "format": "currency", "query": ["table": "fx_items", "aggregates": [["fn": "sum", "column": "amount", "as": "total"]]], "valueColumn": "total"],304 ["label": "Average", "icon": "divide", "format": "currency", "query": ["table": "fx_items", "aggregates": [["fn": "avg", "column": "amount", "as": "mean"]]], "valueColumn": "mean"]]],305 tables: [sampleTable]),306 ]307308 // MARK: Lists, feeds and threads309310 static let familyCLists: [ComponentManifest] = [311 c("prism.recordTimeline", "Record timeline", "data", "Rows placed on a vertical time axis by a date column, newest first: history, milestones, a log.",312 [cQuery, cCol("dateColumn", "Date column that orders the rows.", required: true), cCol("titleColumn", "Column shown as each entry's title.", required: true),313 cCol("detailColumn", "Column shown under the title."), PropSpec("descending", .boolean, "Newest first.", default: true, dynamic: false), cTone, cTitle],314 keywords: ["timeline", "history", "chronology", "milestones", "log", "events", "dates"], role: "list", label: "title",315 example: ["title": "History", "dateColumn": "date", "titleColumn": "event", "query": ["table": "events"]],316 preview: ["title": "History", "dateColumn": "date", "titleColumn": "title", "detailColumn": "category", "query": ["table": "fx_items", "limit": 4]], tables: [sampleTable]),317 c("prism.activityFeed", "Activity feed", "social", "Rows as feed entries, most recent first, each with an icon, a title, a detail and a relative date such as “3 days ago”.",318 [cQuery, cCol("titleColumn", "Column shown as each entry's title.", required: true), cCol("detailColumn", "Column shown under the title."),319 cCol("dateColumn", "Date column; orders the entries and gives the relative date."), PropSpec("icon", .string, "SF Symbol of the entries.", default: "bolt.fill"),320 PropSpec("limit", .number, "Most entries shown.", default: 20, dynamic: false), cTone, cTitle],321 keywords: ["feed", "recent", "news", "updates", "stream", "relative date", "what happened"], role: "list", label: "title",322 example: ["title": "Recent activity", "titleColumn": "summary", "dateColumn": "date", "query": ["table": "activity"]],323 preview: ["title": "Recent activity", "titleColumn": "title", "detailColumn": "category", "dateColumn": "date", "icon": "cart.fill", "limit": 4, "query": ["table": "fx_items"]], tables: [sampleTable]),324 c("prism.comments", "Comments", "social", "A comment thread stored in a table (author, text, date columns) with a box that adds a new comment as a record.",325 [cCol("table", "Table holding the comments.", required: true), cCol("authorColumn", "Text column with the author's name.", required: true),326 cCol("textColumn", "Text column with the comment.", required: true), cCol("dateColumn", "Date column, filled with today for new comments."),327 PropSpec("author", .string, "Name stored as the author of new comments.", default: "Me"), PropSpec("placeholder", .string, "Hint in the add box.", default: "Add a comment…"),328 PropSpec("limit", .number, "Most comments shown (the latest).", default: 200, dynamic: false), PropSpec("title", .string, "Heading.", default: "Comments")],329 events: ["add"], keywords: ["comments", "thread", "discussion", "notes", "replies", "feedback"], role: "group", label: "title",330 example: ["table": "comments", "authorColumn": "author", "textColumn": "text", "dateColumn": "date", "author": ["$expr": "state.userName"]],331 preview: ["table": "fx_messages", "authorColumn": "author", "textColumn": "text", "dateColumn": "date", "author": "Me", "limit": 3], tables: [cMessages]),332 c("prism.chat", "Chat", "social", "A conversation as bubbles from a table (sender and text columns): own messages on the right, with an input that sends a message as a new record.",333 [cCol("table", "Table holding the messages.", required: true), cCol("senderColumn", "Text column with the sender's name.", required: true),334 cCol("textColumn", "Text column with the message.", required: true), cCol("dateColumn", "Date column, filled with today for new messages."),335 PropSpec("me", .string, "The current user's name: messages from this sender are shown on the right, and new messages are stored under it.", default: "Me"),336 PropSpec("placeholder", .string, "Hint in the input.", default: "Message"), PropSpec("limit", .number, "Most messages shown (the latest).", default: 50, dynamic: false),337 PropSpec("title", .string, "Optional heading.")],338 events: ["submit"], keywords: ["chat", "messages", "bubbles", "conversation", "messenger", "send"], role: "group", label: "title",339 example: ["table": "messages", "senderColumn": "sender", "textColumn": "text", "me": ["$expr": "state.userName"]],340 preview: ["table": "fx_messages", "senderColumn": "author", "textColumn": "text", "me": "Me", "title": "Team chat"], tables: [cMessages]),341 c("prism.progressList", "Progress list", "data", "One labelled progress bar per row, from a column holding a fraction between 0 and 1.",342 [cQuery, cCol("labelColumn", "Column naming each bar.", required: true), cCol("valueColumn", "Numeric column with the fraction complete, 0 to 1.", required: true),343 PropSpec("showPercent", .boolean, "Show the percentage.", default: true, dynamic: false), cTone, cTitle],344 keywords: ["progress bars", "completion", "tasks", "status", "percent done", "goals"], role: "list", label: "title",345 example: ["title": "Projects", "labelColumn": "name", "valueColumn": "progress", "query": ["table": "projects"]],346 preview: ["title": "Tasks", "labelColumn": "task", "valueColumn": "progress", "query": ["table": "fx_tasks"]], tables: [cTasks]),347 c("prism.dataList", "Simple list", "data", "Plain one-line rows with a title column and a detail column; clicking a row selects the record.",348 [cQuery, cCol("titleColumn", "Column shown at the start of each line.", required: true), cCol("detailColumn", "Column shown at the end of each line."),349 cAutoFormat, cSelection, cSort, PropSpec("emptyText", .string, "Text when there are no rows."), cTitle],350 events: ["select"], keywords: ["list", "rows", "lines", "simple", "plain", "menu of records"], role: "list", label: "title",351 example: ["titleColumn": "name", "detailColumn": "price", "selection": ["$bind": "selectedId"], "sort": ["$expr": "state.sort"], "query": ["table": "products"]],352 preview: ["title": "Items", "titleColumn": "title", "detailColumn": "amount", "selection": ["$bind": "selected"], "query": ["table": "fx_items"]], state: ["selected": 3], tables: [sampleTable]),353 c("prism.rankList", "Top list", "data", "The top N groups of a query's rows by an aggregate (e.g. the 5 categories with the highest total), each with a proportional bar.",354 [cQuery, cCol("labelColumn", "Column to group by.", required: true), cCol("valueColumn", "Numeric column to aggregate; not needed for `count`."),355 PropSpec("aggregate", .enum, "How each group is computed; defaults to sum, or count without a `valueColumn`.", values: ["sum", "count", "avg", "min", "max"], dynamic: false),356 PropSpec("limit", .number, "Number of groups shown.", default: 5, dynamic: false), cAutoFormat, cTone, cTitle],357 keywords: ["top n", "ranking", "most", "biggest", "best", "grouped totals"], role: "list", label: "title",358 example: ["title": "Top customers", "labelColumn": "customer", "valueColumn": "amount", "limit": 5, "query": ["table": "orders"]],359 preview: ["title": "Top categories", "labelColumn": "category", "valueColumn": "amount", "limit": 3, "query": ["table": "fx_items"]], tables: [sampleTable]),360 c("prism.duplicateFinder", "Duplicate finder", "data", "Finds the rows that share the same value in a column and lists them in groups, largest first (data cleanup).",361 [cQuery, cCol("valueColumn", "Column compared between rows.", required: true), cCol("labelColumn", "Column shown for each row of a group."),362 PropSpec("caseSensitive", .boolean, "Treat upper and lower case as different.", default: false, dynamic: false), cTitle],363 events: ["select"], keywords: ["duplicates", "dedupe", "same value", "cleanup", "repeated", "data quality"], role: "list", label: "title",364 example: ["title": "Duplicate e-mails", "valueColumn": "email", "labelColumn": "name", "query": ["table": "contacts"]],365 preview: ["title": "Repeated titles", "valueColumn": "title", "labelColumn": "date", "query": ["table": "fx_items"]], tables: [sampleTable]),366 ]367368 // MARK: Commerce and social369370 static let familyCCommerce: [ComponentManifest] = [371 c("prism.priceTag", "Price tag", "commerce", "A price, with the original price struck through and a discount badge when it is reduced.",372 [PropSpec("amount", .number, "The price to pay.", required: true), PropSpec("originalAmount", .number, "Price before the reduction."),373 PropSpec("currencyCode", .string, "ISO code such as USD or EUR; defaults to the app's currency.", dynamic: false), PropSpec("label", .string, "Small text above the price."),374 PropSpec("showDiscount", .boolean, "Show the percentage saved.", default: true, dynamic: false), toneProp],375 data: false, keywords: ["price", "discount", "sale", "amount", "cost", "offer"], role: "staticText", label: "label",376 example: ["amount": ["$expr": "state.price"], "originalAmount": 99, "label": "Today"],377 preview: ["amount": 79, "originalAmount": 99, "label": "Today only", "currencyCode": "USD"]),378 c("prism.cartSummary", "Cart summary", "commerce", "Totals of a cart table: number of items, the sum of price × quantity, optional tax and the total, with an optional checkout button.",379 [cCol("table", "Table holding the cart lines.", required: true), cCol("priceColumn", "Numeric column with the unit price.", required: true),380 cCol("quantityColumn", "Numeric column with the quantity; 1 when omitted."), cTaxRate, PropSpec("taxLabel", .string, "Name of the tax line.", default: "Tax"),381 PropSpec("buttonTitle", .string, "Shows a button with this title; it fires `click` with the total."), PropSpec("title", .string, "Heading.", default: "Order summary")],382 events: ["click"], keywords: ["cart", "basket", "checkout", "subtotal", "order total", "shopping"], role: "group", label: "title",383 example: ["table": "cart", "priceColumn": "price", "quantityColumn": "quantity", "taxRate": 0.2, "buttonTitle": "Checkout"],384 preview: ["table": "fx_cart", "priceColumn": "price", "quantityColumn": "quantity", "taxRate": 0.15, "buttonTitle": "Checkout"], tables: [cCart]),385 c("prism.invoice", "Invoice", "commerce", "An invoice of a query's rows as line items (description, quantity, unit price, amount) with subtotal, tax and total.",386 [cQuery, cCol("descriptionColumn", "Column describing each line.", required: true), cCol("priceColumn", "Numeric column with the unit price.", required: true),387 cCol("quantityColumn", "Numeric column with the quantity; 1 when omitted."), cTaxRate, PropSpec("number", .string, "Invoice number."),388 PropSpec("customer", .string, "Who is billed."), PropSpec("notes", .string, "Small print under the totals."), PropSpec("title", .string, "Heading.", default: "Invoice")],389 keywords: ["invoice", "bill", "line items", "quote", "estimate", "billing"], role: "group", label: "title",390 example: ["number": "2026-014", "customer": ["$expr": "state.customerName"], "descriptionColumn": "product", "priceColumn": "price", "quantityColumn": "quantity", "taxRate": 0.2,391 "query": ["table": "order_lines", "filters": [["column": "order_id", "op": "eq", "value": ["$bind": "selectedOrder"]]]]],392 preview: ["number": "2026-014", "customer": "Northwind Ltd", "descriptionColumn": "product", "priceColumn": "price", "quantityColumn": "quantity", "taxRate": 0.15, "notes": "Payable within 30 days.",393 "query": ["table": "fx_cart", "filters": [["column": "order_id", "op": "eq", "value": 1]]]], tables: [cCart]),394 c("prism.productCard", "Product card", "commerce", "A product tile with a symbol, title, star rating, price and a button that runs actions (e.g. add to cart).",395 [PropSpec("title", .string, "Product name.", required: true), PropSpec("subtitle", .string, "Short description."), PropSpec("price", .number, "Price shown."),396 PropSpec("currencyCode", .string, "ISO code; defaults to the app's currency.", dynamic: false), PropSpec("symbol", .string, "SF Symbol standing for the product.", default: "shippingbox"),397 PropSpec("rating", .number, "Stars from 0 to 5."), PropSpec("buttonTitle", .string, "Button text; empty hides the button.", default: "Add to cart"),398 PropSpec("disabled", .boolean, "Whether the button is inactive.", default: false)],399 events: ["click"], data: false, keywords: ["product", "shop", "store", "buy", "item tile", "rating"], role: "group", label: "title",400 example: ["title": "Headphones", "price": 129, "rating": 4.5, "symbol": "headphones"],401 preview: ["title": "Wireless headphones", "subtitle": "Noise cancelling, 30 h battery", "price": 129, "rating": 4.5, "symbol": "headphones"]),402 c("prism.quantity", "Quantity selector", "commerce", "A compact − n + stepper bound to a number in state, with bounds.",403 [PropSpec("value", .number, "State key holding the quantity.", required: true, dynamic: false, binding: .required), PropSpec("label", .string, "Field label."),404 PropSpec("min", .number, "Lowest value.", default: 0, dynamic: false), PropSpec("max", .number, "Highest value.", dynamic: false), PropSpec("step", .number, "Increment.", default: 1, dynamic: false)],405 events: ["change"], data: false, keywords: ["quantity", "stepper", "plus minus", "counter", "amount picker", "units"], role: "incrementable", label: "label",406 example: ["label": "Quantity", "value": ["$bind": "quantity"], "min": 1, "max": 10],407 preview: ["label": "Quantity", "value": ["$bind": "qty"], "min": 1, "max": 10], state: ["qty": 2]),408 c("prism.receipt", "Receipt", "commerce", "A monospaced till receipt of a query's rows: one line per row with its amount, then the total (and tax when a rate is given).",409 [cQuery, cCol("labelColumn", "Column naming each line.", required: true), cCol("valueColumn", "Numeric column with the line's unit amount.", required: true),410 cCol("quantityColumn", "Numeric column multiplying the amount."), cTaxRate, PropSpec("title", .string, "Header, e.g. the shop's name."), PropSpec("footer", .string, "Last line, e.g. a thank-you.")],411 keywords: ["receipt", "ticket", "till", "printout", "monospaced", "purchase"], role: "staticText", label: "title",412 example: ["title": "Corner Shop", "labelColumn": "product", "valueColumn": "price", "quantityColumn": "quantity", "footer": "Thank you!", "query": ["table": "cart"]],413 preview: ["title": "Corner Shop", "labelColumn": "product", "valueColumn": "price", "quantityColumn": "quantity", "taxRate": 0.15, "footer": "Thank you!",414 "query": ["table": "fx_cart", "filters": [["column": "order_id", "op": "eq", "value": 1]]]], tables: [cCart]),415 c("prism.converter", "Converter", "commerce", "Two linked number fields that convert between two units or currencies at a fixed rate; typing in either one updates the other.",416 [PropSpec("rate", .number, "How many `to` units one `from` unit is worth.", required: true), PropSpec("fromLabel", .string, "Name of the first unit.", default: "From"),417 PropSpec("toLabel", .string, "Name of the second unit.", default: "To"),418 PropSpec("value", .number, "State key holding the first amount; kept inside the component when omitted.", dynamic: false, binding: .optional),419 PropSpec("result", .number, "State key that receives the converted amount whenever the user edits a field.", dynamic: false, binding: .optional),420 PropSpec("decimals", .number, "Decimal places of the result (0 to 8).", default: 2, dynamic: false)],421 events: ["change"], data: false, keywords: ["convert", "currency", "units", "exchange rate", "calculator", "km miles"], role: "group",422 example: ["rate": 1.6093, "fromLabel": "mi", "toLabel": "km"],423 preview: ["rate": 0.92, "fromLabel": "USD", "toLabel": "EUR", "value": ["$bind": "usd"]], state: ["usd": 250]),424 c("prism.profileCard", "Profile card", "social", "A person card: avatar with initials, name, role, a row of statistics and an optional button.",425 [PropSpec("name", .string, "Full name.", required: true), PropSpec("role", .string, "Role or tagline."),426 PropSpec("stats", .list, "Statistics: `{label, value}`."), PropSpec("buttonTitle", .string, "Shows a button with this title; it fires `click`."), cTone],427 events: ["click"], data: false, keywords: ["profile", "person", "user", "avatar", "contact", "member", "bio"], role: "group", label: "name",428 example: ["name": "Ada Lovelace", "role": "Engineer", "stats": [["label": "Posts", "value": 42]], "buttonTitle": "Follow"],429 preview: ["name": "Ada Lovelace", "role": "Analytical engines", "stats": [["label": "Posts", "value": 128], ["label": "Followers", "value": "3.4k"], ["label": "Following", "value": 86]], "buttonTitle": "Follow"]),430 c("prism.reactionBar", "Reaction bar", "social", "A row of emoji buttons with counts kept in a state object `{emoji: count}`; clicking one adds a reaction.",431 [PropSpec("value", .object, "State key holding the counts, e.g. `{\"👍\": 3}` (declare it as `{}`).", required: true, dynamic: false, binding: .required),432 PropSpec("reactions", .list, "The emoji offered.", default: ["👍", "❤️", "🎉", "😄"])],433 events: ["change"], data: false, keywords: ["reactions", "emoji", "applause", "thumbs up", "respond", "feedback"], role: "group",434 example: ["value": ["$bind": "reactions"], "reactions": ["👍", "❤️", "🎉"]],435 preview: ["value": ["$bind": "reactions"]], state: ["reactions": ["👍": 4, "🎉": 1]]),436 c("prism.likeButton", "Like button", "social", "A heart toggle bound to a true/false state key, with an optional count beside it.",437 [PropSpec("value", .boolean, "State key that is true while liked.", required: true, dynamic: false, binding: .required),438 PropSpec("count", .number, "Number shown next to the heart; when bound to state it goes up and down with the toggle.", binding: .optional), PropSpec("label", .string, "Text next to the heart.")],439 events: ["toggle"], data: false, keywords: ["like", "heart", "favorite", "love", "upvote", "bookmark"], role: "toggleButton", label: "label",440 example: ["value": ["$bind": "liked"], "count": ["$bind": "likes"], "label": "Like"],441 preview: ["value": ["$bind": "liked"], "count": ["$bind": "likes"], "label": "Like"], state: ["liked": true, "likes": 13]),442 c("prism.poll", "Poll", "social", "A question with options to vote on; votes live in a state object `{votes: {option: count}, choice}` and percentages appear once the user has voted.",443 [PropSpec("options", .list, "The answers offered.", required: true), PropSpec("question", .string, "The question asked."),444 PropSpec("value", .object, "State key holding `{votes: {option: count}, choice: option|null}` (declare it as `{}`).", required: true, dynamic: false, binding: .required),445 PropSpec("alwaysShowResults", .boolean, "Show percentages before the user votes.", default: false, dynamic: false)],446 events: ["change"], data: false, keywords: ["poll", "vote", "survey", "ballot", "options", "percentages"], role: "radioGroup", label: "question",447 example: ["question": "Where next?", "options": ["Lisbon", "Kyoto"], "value": ["$bind": "poll"]],448 preview: ["question": "Which feature first?", "options": ["Dark mode", "Offline sync", "CSV export"], "value": ["$bind": "poll"]],449 state: ["poll": ["votes": ["Dark mode": 5, "Offline sync": 9, "CSV export": 2], "choice": "Offline sync"]]),450 ]451}452