@cratis/scene.primereact 4.13.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/PrimeDataTable.tsx +13 -2
- package/dist/cjs/data/PrimeDataTable.js +15 -2
- package/dist/cjs/data/PrimeDataTable.js.map +1 -1
- package/dist/cjs/form/PrimeCalendar.js +2 -1
- package/dist/cjs/form/PrimeCalendar.js.map +1 -1
- package/dist/cjs/form/PrimeCheckbox.js +1 -0
- package/dist/cjs/form/PrimeCheckbox.js.map +1 -1
- package/dist/cjs/form/PrimeDropdown.js +1 -0
- package/dist/cjs/form/PrimeDropdown.js.map +1 -1
- package/dist/cjs/form/PrimeInputNumber.js +2 -1
- package/dist/cjs/form/PrimeInputNumber.js.map +1 -1
- package/dist/cjs/form/PrimeInputText.js +1 -0
- package/dist/cjs/form/PrimeInputText.js.map +1 -1
- package/dist/cjs/form/PrimeInputTextarea.js +1 -0
- package/dist/cjs/form/PrimeInputTextarea.js.map +1 -1
- package/dist/cjs/form/PrimePassword.js +1 -0
- package/dist/cjs/form/PrimePassword.js.map +1 -1
- package/dist/esm/data/PrimeDataTable.d.ts.map +1 -1
- package/dist/esm/data/PrimeDataTable.js +16 -3
- package/dist/esm/data/PrimeDataTable.js.map +1 -1
- package/dist/esm/form/PrimeCalendar.js +2 -1
- package/dist/esm/form/PrimeCalendar.js.map +1 -1
- package/dist/esm/form/PrimeCheckbox.d.ts.map +1 -1
- package/dist/esm/form/PrimeCheckbox.js +1 -0
- package/dist/esm/form/PrimeCheckbox.js.map +1 -1
- package/dist/esm/form/PrimeDropdown.js +1 -0
- package/dist/esm/form/PrimeDropdown.js.map +1 -1
- package/dist/esm/form/PrimeInputNumber.js +2 -1
- package/dist/esm/form/PrimeInputNumber.js.map +1 -1
- package/dist/esm/form/PrimeInputText.d.ts.map +1 -1
- package/dist/esm/form/PrimeInputText.js +1 -0
- package/dist/esm/form/PrimeInputText.js.map +1 -1
- package/dist/esm/form/PrimeInputTextarea.d.ts.map +1 -1
- package/dist/esm/form/PrimeInputTextarea.js +1 -0
- package/dist/esm/form/PrimeInputTextarea.js.map +1 -1
- package/dist/esm/form/PrimePassword.d.ts.map +1 -1
- package/dist/esm/form/PrimePassword.js +1 -0
- package/dist/esm/form/PrimePassword.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/form/PrimeCalendar.tsx +1 -1
- package/form/PrimeCheckbox.tsx +1 -0
- package/form/PrimeDropdown.tsx +1 -1
- package/form/PrimeInputNumber.tsx +1 -1
- package/form/PrimeInputText.tsx +1 -0
- package/form/PrimeInputTextarea.tsx +1 -0
- package/form/PrimePassword.tsx +1 -0
- package/package.json +7 -7
package/data/PrimeDataTable.tsx
CHANGED
|
@@ -22,9 +22,15 @@ import { columnDefinitions } from './columnDefinitions';
|
|
|
22
22
|
* otherwise from the element's model - nested `column` children, a `columns` property, or the shape of
|
|
23
23
|
* the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second
|
|
24
24
|
* only because an explicitly composed declaration is the more specific statement of the two.
|
|
25
|
+
*
|
|
26
|
+
* A host that is still loading the rows sets `loading`, and one whose query failed sets `error` to the
|
|
27
|
+
* message to show. Both replace the rows with one announced row - a status while loading, an alert on
|
|
28
|
+
* error - and keep the column headers, so the table keeps its shape and the reader knows why it is empty.
|
|
25
29
|
*/
|
|
26
30
|
export function PrimeDataTable({ element, slots }: RegisteredComponentProps) {
|
|
27
|
-
const
|
|
31
|
+
const loading = booleanProperty(element, 'loading', false);
|
|
32
|
+
const error = stringProperty(element, 'error');
|
|
33
|
+
const rows = loading || error !== undefined ? [] : recordArrayProperty(element, 'rows');
|
|
28
34
|
const declared = declaredColumns(slots);
|
|
29
35
|
const columns: ColumnProps[] = declared.length > 0 ? declared : columnDefinitions(element, rows);
|
|
30
36
|
const pageSize = numberProperty(element, 'pageSize');
|
|
@@ -33,6 +39,7 @@ export function PrimeDataTable({ element, slots }: RegisteredComponentProps) {
|
|
|
33
39
|
return (
|
|
34
40
|
<DataTable.Root
|
|
35
41
|
data-scene-id={element.id}
|
|
42
|
+
aria-busy={loading}
|
|
36
43
|
data={rows}
|
|
37
44
|
removableSort
|
|
38
45
|
paginator={pageSize !== undefined}
|
|
@@ -83,7 +90,11 @@ export function PrimeDataTable({ element, slots }: RegisteredComponentProps) {
|
|
|
83
90
|
<DataTable.EmptyTBody>
|
|
84
91
|
<DataTable.Row>
|
|
85
92
|
<DataTable.Cell colSpan={Math.max(columns.length, 1)}>
|
|
86
|
-
{
|
|
93
|
+
{error !== undefined
|
|
94
|
+
? <span role='alert'>{error}</span>
|
|
95
|
+
: loading
|
|
96
|
+
? <span role='status'>{stringProperty(element, 'loadingMessage', 'Loading…')}</span>
|
|
97
|
+
: stringProperty(element, 'emptyMessage', 'No records found')}
|
|
87
98
|
</DataTable.Cell>
|
|
88
99
|
</DataTable.Row>
|
|
89
100
|
</DataTable.EmptyTBody>
|
|
@@ -21,14 +21,21 @@ var columnDefinitions = require('./columnDefinitions.js');
|
|
|
21
21
|
* otherwise from the element's model - nested `column` children, a `columns` property, or the shape of
|
|
22
22
|
* the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second
|
|
23
23
|
* only because an explicitly composed declaration is the more specific statement of the two.
|
|
24
|
+
*
|
|
25
|
+
* A host that is still loading the rows sets `loading`, and one whose query failed sets `error` to the
|
|
26
|
+
* message to show. Both replace the rows with one announced row - a status while loading, an alert on
|
|
27
|
+
* error - and keep the column headers, so the table keeps its shape and the reader knows why it is empty.
|
|
24
28
|
*/ function PrimeDataTable({ element, slots }) {
|
|
25
|
-
const
|
|
29
|
+
const loading = properties.booleanProperty(element, 'loading', false);
|
|
30
|
+
const error = properties.stringProperty(element, 'error');
|
|
31
|
+
const rows = loading || error !== undefined ? [] : properties.recordArrayProperty(element, 'rows');
|
|
26
32
|
const declared = declaredColumns(slots);
|
|
27
33
|
const columns = declared.length > 0 ? declared : columnDefinitions.columnDefinitions(element, rows);
|
|
28
34
|
const pageSize = properties.numberProperty(element, 'pageSize');
|
|
29
35
|
const size = properties.stringProperty(element, 'size');
|
|
30
36
|
return /*#__PURE__*/ jsxRuntime.jsxs(datatable.DataTable.Root, {
|
|
31
37
|
"data-scene-id": element.id,
|
|
38
|
+
"aria-busy": loading,
|
|
32
39
|
data: rows,
|
|
33
40
|
removableSort: true,
|
|
34
41
|
paginator: pageSize !== undefined,
|
|
@@ -86,7 +93,13 @@ var columnDefinitions = require('./columnDefinitions.js');
|
|
|
86
93
|
children: /*#__PURE__*/ jsxRuntime.jsx(datatable.DataTable.Row, {
|
|
87
94
|
children: /*#__PURE__*/ jsxRuntime.jsx(datatable.DataTable.Cell, {
|
|
88
95
|
colSpan: Math.max(columns.length, 1),
|
|
89
|
-
children:
|
|
96
|
+
children: error !== undefined ? /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
97
|
+
role: "alert",
|
|
98
|
+
children: error
|
|
99
|
+
}) : loading ? /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
100
|
+
role: "status",
|
|
101
|
+
children: properties.stringProperty(element, 'loadingMessage', 'Loading…')
|
|
102
|
+
}) : properties.stringProperty(element, 'emptyMessage', 'No records found')
|
|
90
103
|
})
|
|
91
104
|
})
|
|
92
105
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeDataTable.js","sources":["../../../data/PrimeDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactElement, ReactNode, isValidElement } from 'react';\nimport { DataTable, type DataTableFilterInstance, type DataTablePaginationInstance, type DataTableTBodyItemOptions } from 'primereact/datatable';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, recordArrayProperty, stringProperty } from '../properties';\nimport { Column, ColumnProps } from './Column';\nimport { columnDefinitions } from './columnDefinitions';\n\n/**\n * The `PrimeReact:dataTable` component, also registered under Screenplay's `table` name so a screen\n * compiled from a `.play` file renders through this package without a translation step.\n *\n * PrimeReact 11 turned the table inside out. Where PrimeReact 10 took `value` and a set of `Column`\n * children and produced the whole table, PrimeReact 11 gives back a root that owns sorting, filtering and\n * paging and a set of parts - container, table, head, rows, cells - that the caller arranges. So this\n * adapter now writes out the table's structure itself, and the column concept it renders from is\n * {@link Column}, which is Cratis-owned because PrimeReact 11 removed `primereact/column` entirely.\n *\n * Columns are taken from `Column` declarations when a React caller composed some into a slot, and\n * otherwise from the element's model - nested `column` children, a `columns` property, or the shape of\n * the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second\n * only because an explicitly composed declaration is the more specific statement of the two.\n */\nexport function PrimeDataTable({ element, slots }: RegisteredComponentProps) {\n const rows = recordArrayProperty(element, 'rows');\n const declared = declaredColumns(slots);\n const columns: ColumnProps[] = declared.length > 0 ? declared : columnDefinitions(element, rows);\n const pageSize = numberProperty(element, 'pageSize');\n const size = stringProperty(element, 'size');\n\n return (\n <DataTable.Root\n data-scene-id={element.id}\n data={rows}\n removableSort\n paginator={pageSize !== undefined}\n rows={pageSize}\n stripedRows={booleanProperty(element, 'stripedRows', false)}\n showGridlines={booleanProperty(element, 'showGridlines', false)}\n size={size === 'small' || size === 'large' ? size : undefined}>\n <DataTable.TableContainer>\n <DataTable.Table>\n <DataTable.THead>\n <DataTable.THeadRow>\n {columns.map((column, index) => (\n <DataTable.THeadCell key={column.field ?? index}>\n {column.sortable && column.field ? (\n <DataTable.Sort field={column.field}>\n {headerOf(column)}\n <DataTable.SortIndicator match='asc'> ▲</DataTable.SortIndicator>\n <DataTable.SortIndicator match='desc'> ▼</DataTable.SortIndicator>\n </DataTable.Sort>\n ) : (\n <span>{headerOf(column)}</span>\n )}\n {column.filter && column.field && (\n <DataTable.Filter field={column.field} display='row'>\n {(filter: DataTableFilterInstance) => (\n <input\n className='w-full'\n aria-label={`Filter by ${headerOf(column)}`}\n value={typeof filter.value === 'string' ? filter.value : ''}\n onChange={(event) => filter.onChange(event, event.target.value)}\n />\n )}\n </DataTable.Filter>\n )}\n </DataTable.THeadCell>\n ))}\n </DataTable.THeadRow>\n </DataTable.THead>\n <DataTable.TBody>\n {({ item, index }: DataTableTBodyItemOptions) => (\n <DataTable.Row index={index}>\n {columns.map((column, columnIndex) => (\n <DataTable.Cell key={column.field ?? columnIndex}>{cellOf(column, item)}</DataTable.Cell>\n ))}\n </DataTable.Row>\n )}\n </DataTable.TBody>\n <DataTable.EmptyTBody>\n <DataTable.Row>\n <DataTable.Cell colSpan={Math.max(columns.length, 1)}>\n {stringProperty(element, 'emptyMessage', 'No records found')}\n </DataTable.Cell>\n </DataTable.Row>\n </DataTable.EmptyTBody>\n </DataTable.Table>\n </DataTable.TableContainer>\n <DataTable.Pagination>\n {(pagination: DataTablePaginationInstance) => (\n <div className='flex items-center gap-2 p-2'>\n <button\n type='button'\n disabled={!pagination.canPrev}\n onClick={(event) => pagination.onPageChange(event, pagination.page - 1)}>\n ‹\n </button>\n <span className='text-sm opacity-75'>\n {pagination.page + 1} / {Math.max(pagination.pageCount, 1)}\n </span>\n <button\n type='button'\n disabled={!pagination.canNext}\n onClick={(event) => pagination.onPageChange(event, pagination.page + 1)}>\n ›\n </button>\n </div>\n )}\n </DataTable.Pagination>\n </DataTable.Root>\n );\n}\n\nfunction declaredColumns(slots: Record<string, ReactNode[]>): ColumnProps[] {\n return [...(slots.columns ?? []), ...(slots.content ?? [])]\n .filter((node): node is ReactElement<ColumnProps> => isValidElement(node) && node.type === Column)\n .map((node) => node.props);\n}\n\nfunction headerOf(column: ColumnProps): string {\n return column.header ?? column.field ?? '';\n}\n\nfunction cellOf(column: ColumnProps, row: Record<string, unknown>): ReactNode {\n if (column.body !== undefined) return column.body(row);\n if (column.field === undefined) return '';\n return String(row[column.field] ?? '');\n}\n"],"names":["PrimeDataTable","element","slots","rows","recordArrayProperty","declared","declaredColumns","columns","length","columnDefinitions","pageSize","numberProperty","size","stringProperty","_jsxs","DataTable","Root","data-scene-id","id","data","removableSort","paginator","undefined","stripedRows","booleanProperty","showGridlines","_jsx","TableContainer","Table","THead","THeadRow","map","column","index","THeadCell","sortable","field","Sort","headerOf","SortIndicator","match","span","filter","Filter","display","input","className","aria-label","value","onChange","event","target","TBody","item","Row","columnIndex","Cell","cellOf","EmptyTBody","colSpan","Math","max","Pagination","pagination","div","button","type","disabled","canPrev","onClick","onPageChange","page","pageCount","canNext","content","node","isValidElement","Column","props","header","row","body","String"],"mappings":";;;;;;;;;AAUA;;;;;;;;;;;;;;AAcC,IACM,SAASA,cAAAA,CAAe,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;IACvE,MAAMC,IAAAA,GAAOC,+BAAoBH,OAAAA,EAAS,MAAA,CAAA;AAC1C,IAAA,MAAMI,WAAWC,eAAAA,CAAgBJ,KAAAA,CAAAA;AACjC,IAAA,MAAMK,UAAyBF,QAAAA,CAASG,MAAM,GAAG,CAAA,GAAIH,QAAAA,GAAWI,oCAAkBR,OAAAA,EAASE,IAAAA,CAAAA;IAC3F,MAAMO,QAAAA,GAAWC,0BAAeV,OAAAA,EAAS,UAAA,CAAA;IACzC,MAAMW,IAAAA,GAAOC,0BAAeZ,OAAAA,EAAS,MAAA,CAAA;IAErC,qBACIa,eAAA,CAACC,oBAAUC,IAAI,EAAA;AACXC,QAAAA,eAAAA,EAAehB,QAAQiB,EAAE;QACzBC,IAAAA,EAAMhB,IAAAA;QACNiB,aAAa,EAAA,IAAA;AACbC,QAAAA,SAAAA,EAAWX,QAAAA,KAAaY,SAAAA;QACxBnB,IAAAA,EAAMO,QAAAA;QACNa,WAAAA,EAAaC,0BAAAA,CAAgBvB,SAAS,aAAA,EAAe,KAAA,CAAA;QACrDwB,aAAAA,EAAeD,0BAAAA,CAAgBvB,SAAS,eAAA,EAAiB,KAAA,CAAA;AACzDW,QAAAA,IAAAA,EAAMA,IAAAA,KAAS,OAAA,IAAWA,IAAAA,KAAS,OAAA,GAAUA,IAAAA,GAAOU,SAAAA;;AACpD,0BAAAI,cAAA,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D,OAAOF,GAAG,CAAChD,MAAAA,CAAOI,KAAK,CAAC,IAAI,EAAA,CAAA;AACvC;;"}
|
|
1
|
+
{"version":3,"file":"PrimeDataTable.js","sources":["../../../data/PrimeDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactElement, ReactNode, isValidElement } from 'react';\nimport { DataTable, type DataTableFilterInstance, type DataTablePaginationInstance, type DataTableTBodyItemOptions } from 'primereact/datatable';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, recordArrayProperty, stringProperty } from '../properties';\nimport { Column, ColumnProps } from './Column';\nimport { columnDefinitions } from './columnDefinitions';\n\n/**\n * The `PrimeReact:dataTable` component, also registered under Screenplay's `table` name so a screen\n * compiled from a `.play` file renders through this package without a translation step.\n *\n * PrimeReact 11 turned the table inside out. Where PrimeReact 10 took `value` and a set of `Column`\n * children and produced the whole table, PrimeReact 11 gives back a root that owns sorting, filtering and\n * paging and a set of parts - container, table, head, rows, cells - that the caller arranges. So this\n * adapter now writes out the table's structure itself, and the column concept it renders from is\n * {@link Column}, which is Cratis-owned because PrimeReact 11 removed `primereact/column` entirely.\n *\n * Columns are taken from `Column` declarations when a React caller composed some into a slot, and\n * otherwise from the element's model - nested `column` children, a `columns` property, or the shape of\n * the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second\n * only because an explicitly composed declaration is the more specific statement of the two.\n *\n * A host that is still loading the rows sets `loading`, and one whose query failed sets `error` to the\n * message to show. Both replace the rows with one announced row - a status while loading, an alert on\n * error - and keep the column headers, so the table keeps its shape and the reader knows why it is empty.\n */\nexport function PrimeDataTable({ element, slots }: RegisteredComponentProps) {\n const loading = booleanProperty(element, 'loading', false);\n const error = stringProperty(element, 'error');\n const rows = loading || error !== undefined ? [] : recordArrayProperty(element, 'rows');\n const declared = declaredColumns(slots);\n const columns: ColumnProps[] = declared.length > 0 ? declared : columnDefinitions(element, rows);\n const pageSize = numberProperty(element, 'pageSize');\n const size = stringProperty(element, 'size');\n\n return (\n <DataTable.Root\n data-scene-id={element.id}\n aria-busy={loading}\n data={rows}\n removableSort\n paginator={pageSize !== undefined}\n rows={pageSize}\n stripedRows={booleanProperty(element, 'stripedRows', false)}\n showGridlines={booleanProperty(element, 'showGridlines', false)}\n size={size === 'small' || size === 'large' ? size : undefined}>\n <DataTable.TableContainer>\n <DataTable.Table>\n <DataTable.THead>\n <DataTable.THeadRow>\n {columns.map((column, index) => (\n <DataTable.THeadCell key={column.field ?? index}>\n {column.sortable && column.field ? (\n <DataTable.Sort field={column.field}>\n {headerOf(column)}\n <DataTable.SortIndicator match='asc'> ▲</DataTable.SortIndicator>\n <DataTable.SortIndicator match='desc'> ▼</DataTable.SortIndicator>\n </DataTable.Sort>\n ) : (\n <span>{headerOf(column)}</span>\n )}\n {column.filter && column.field && (\n <DataTable.Filter field={column.field} display='row'>\n {(filter: DataTableFilterInstance) => (\n <input\n className='w-full'\n aria-label={`Filter by ${headerOf(column)}`}\n value={typeof filter.value === 'string' ? filter.value : ''}\n onChange={(event) => filter.onChange(event, event.target.value)}\n />\n )}\n </DataTable.Filter>\n )}\n </DataTable.THeadCell>\n ))}\n </DataTable.THeadRow>\n </DataTable.THead>\n <DataTable.TBody>\n {({ item, index }: DataTableTBodyItemOptions) => (\n <DataTable.Row index={index}>\n {columns.map((column, columnIndex) => (\n <DataTable.Cell key={column.field ?? columnIndex}>{cellOf(column, item)}</DataTable.Cell>\n ))}\n </DataTable.Row>\n )}\n </DataTable.TBody>\n <DataTable.EmptyTBody>\n <DataTable.Row>\n <DataTable.Cell colSpan={Math.max(columns.length, 1)}>\n {error !== undefined\n ? <span role='alert'>{error}</span>\n : loading\n ? <span role='status'>{stringProperty(element, 'loadingMessage', 'Loading…')}</span>\n : stringProperty(element, 'emptyMessage', 'No records found')}\n </DataTable.Cell>\n </DataTable.Row>\n </DataTable.EmptyTBody>\n </DataTable.Table>\n </DataTable.TableContainer>\n <DataTable.Pagination>\n {(pagination: DataTablePaginationInstance) => (\n <div className='flex items-center gap-2 p-2'>\n <button\n type='button'\n disabled={!pagination.canPrev}\n onClick={(event) => pagination.onPageChange(event, pagination.page - 1)}>\n ‹\n </button>\n <span className='text-sm opacity-75'>\n {pagination.page + 1} / {Math.max(pagination.pageCount, 1)}\n </span>\n <button\n type='button'\n disabled={!pagination.canNext}\n onClick={(event) => pagination.onPageChange(event, pagination.page + 1)}>\n ›\n </button>\n </div>\n )}\n </DataTable.Pagination>\n </DataTable.Root>\n );\n}\n\nfunction declaredColumns(slots: Record<string, ReactNode[]>): ColumnProps[] {\n return [...(slots.columns ?? []), ...(slots.content ?? [])]\n .filter((node): node is ReactElement<ColumnProps> => isValidElement(node) && node.type === Column)\n .map((node) => node.props);\n}\n\nfunction headerOf(column: ColumnProps): string {\n return column.header ?? column.field ?? '';\n}\n\nfunction cellOf(column: ColumnProps, row: Record<string, unknown>): ReactNode {\n if (column.body !== undefined) return column.body(row);\n if (column.field === undefined) return '';\n return String(row[column.field] ?? '');\n}\n"],"names":["PrimeDataTable","element","slots","loading","booleanProperty","error","stringProperty","rows","undefined","recordArrayProperty","declared","declaredColumns","columns","length","columnDefinitions","pageSize","numberProperty","size","_jsxs","DataTable","Root","data-scene-id","id","aria-busy","data","removableSort","paginator","stripedRows","showGridlines","_jsx","TableContainer","Table","THead","THeadRow","map","column","index","THeadCell","sortable","field","Sort","headerOf","SortIndicator","match","span","filter","Filter","display","input","className","aria-label","value","onChange","event","target","TBody","item","Row","columnIndex","Cell","cellOf","EmptyTBody","colSpan","Math","max","role","Pagination","pagination","div","button","type","disabled","canPrev","onClick","onPageChange","page","pageCount","canNext","content","node","isValidElement","Column","props","header","row","body","String"],"mappings":";;;;;;;;;AAUA;;;;;;;;;;;;;;;;;;AAkBC,IACM,SAASA,cAAAA,CAAe,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;IACvE,MAAMC,OAAAA,GAAUC,0BAAAA,CA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IAAI,CAACD,GAAAA,CAAAA;AAClD,IAAA,IAAIjD,MAAAA,CAAOI,KAAK,KAAK/B,SAAAA,EAAW,OAAO,EAAA;AACvC,IAAA,OAAO8E,OAAOF,GAAG,CAACjD,MAAAA,CAAOI,KAAK,CAAC,IAAI,EAAA,CAAA;AACvC;;"}
|
|
@@ -83,7 +83,8 @@ var properties = require('../properties.js');
|
|
|
83
83
|
children: [
|
|
84
84
|
/*#__PURE__*/ jsxRuntime.jsx(datepicker.DatePicker.Input, {
|
|
85
85
|
as: inputtext.InputText,
|
|
86
|
-
placeholder: properties.stringProperty(element, 'placeholder')
|
|
86
|
+
placeholder: properties.stringProperty(element, 'placeholder'),
|
|
87
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel')
|
|
87
88
|
}),
|
|
88
89
|
properties.booleanProperty(element, 'showIcon', true) && /*#__PURE__*/ jsxRuntime.jsx(datepicker.DatePicker.Trigger, {
|
|
89
90
|
children: /*#__PURE__*/ jsxRuntime.jsx("i", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeCalendar.js","sources":["../../../form/PrimeCalendar.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { DatePicker } from 'primereact/datepicker';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:calendar` component - a date picker, named `DatePicker` by PrimeReact 11.\n *\n * The seed value is parsed from an ISO date string because that is what survives a round trip through a\n * Scene model's JSON properties; an unparseable one leaves the field empty rather than showing\n * \"Invalid Date\".\n *\n * v11's `DatePicker` is a composition, and the grid is the bulk of it: `Calendar` holds a `Header` (the\n * month/year title flanked by the two navigation buttons) and a `Table` whose three `TableBody` views are\n * what makes clicking the title drill from days to months to years. That whole calendar is built once\n * here and then placed one of two ways, which is how `inline` survives a version that has no `inline`\n * prop: either inside a `Panel`, which simply renders where it stands, or behind a `Portal` and a\n * `Positioner`, which anchors it to the field and escapes any clipping ancestor.\n */\nexport function PrimeCalendar({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<Date | undefined>(() => {\n const seed = stringProperty(element, 'value');\n if (seed === undefined) return undefined;\n const parsed = new Date(seed);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n });\n\n const inline = booleanProperty(element, 'inline', false);\n const showTime = booleanProperty(element, 'showTime', false);\n const calendar = (\n <>\n <DatePicker.Calendar>\n <DatePicker.Header>\n <DatePicker.Prev>\n <i className='pi pi-chevron-left' />\n </DatePicker.Prev>\n <DatePicker.Title>\n <DatePicker.SelectMonth />\n <DatePicker.SelectYear />\n <DatePicker.Decade />\n </DatePicker.Title>\n <DatePicker.Next>\n <i className='pi pi-chevron-right' />\n </DatePicker.Next>\n </DatePicker.Header>\n <DatePicker.Table>\n <DatePicker.TableHead />\n <DatePicker.TableBody />\n <DatePicker.TableBody view='month' />\n <DatePicker.TableBody view='year' />\n </DatePicker.Table>\n </DatePicker.Calendar>\n {showTime && <DatePicker.Time />}\n </>\n );\n\n return (\n <DatePicker.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value instanceof Date ? event.value : undefined)}\n dateFormat={stringProperty(element, 'dateFormat')}\n showTime={showTime}\n disabled={booleanProperty(element, 'disabled', false)}>\n {inline ? (\n <DatePicker.Panel>{calendar}</DatePicker.Panel>\n ) : (\n <>\n <DatePicker.Input as={InputText} placeholder={stringProperty(element, 'placeholder')} />\n {booleanProperty(element, 'showIcon', true) && (\n <DatePicker.Trigger>\n <i className='pi pi-calendar' />\n </DatePicker.Trigger>\n )}\n <DatePicker.Portal>\n <DatePicker.Positioner align='start'>\n <DatePicker.Popup>{calendar}</DatePicker.Popup>\n </DatePicker.Positioner>\n </DatePicker.Portal>\n </>\n )}\n </DatePicker.Root>\n );\n}\n"],"names":["PrimeCalendar","element","value","setValue","useState","seed","stringProperty","undefined","parsed","Date","Number","isNaN","getTime","inline","booleanProperty","showTime","calendar","_jsxs","_Fragment","DatePicker","Calendar","Header","_jsx","Prev","i","className","Title","SelectMonth","SelectYear","Decade","Next","Table","TableHead","TableBody","view","Time","Root","data-scene-id","id","onValueChange","event","dateFormat","disabled","Panel","Input","as","InputText","placeholder","Trigger","Portal","Positioner","align","Popup"],"mappings":";;;;;;;;AASA;;;;;;;;;;;;;AAaC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAA2B,IAAA;QACjD,MAAMC,IAAAA,GAAOC,0BAAeL,OAAAA,EAAS,OAAA,CAAA;QACrC,IAAII,IAAAA,KAASE,WAAW,OAAOA,SAAAA;QAC/B,MAAMC,MAAAA,GAAS,IAAIC,IAAAA,CAAKJ,IAAAA,CAAAA;AACxB,QAAA,OAAOK,OAAOC,KAAK,CAACH,MAAAA,CAAOI,OAAO,MAAML,SAAAA,GAAYC,MAAAA;AACxD,IAAA,CAAA,CAAA;IAEA,MAAMK,MAAAA,GAASC,0BAAAA,CAAgBb,OAAAA,EAAS,QAAA,EAAU,KAAA,CAAA;IAClD,MAAMc,QAAAA,GAAWD,0BAAAA,CAAgBb,OAAAA,EAAS,UAAA,EAAY,KAAA,CAAA;AACtD,IAAA,MAAMe,QAAAA,iBACFC,eAAA,CAAAC,mBAAA,EAAA;;AACI,0BAAAD,eAAA,CAACE,sBAAWC,QAAQ,EAAA;;AAChB,kCAAAH,eAAA,CAACE,sBAAWE,MAAM,EAAA;;AACd,0CAAAC,cAAA,CAACH,sBAAWI,IAAI,EAAA;AACZ,gCAAA,QAAA,gBAAAD,cAAA,CAACE,GAAAA,EAAAA;oCAAEC,SAAAA,EAAU;;;AAEjB,0CAAAR,eAAA,CAACE,sBAAWO,KAAK,EAAA;;AACb,kDAAAJ,cAAA,CAACH,sBAAWQ,WAAW,EAAA,E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KAAK,EAAA;oBAACC,EAAAA,EAAIC,mBAAAA;AAAWC,oBAAAA,WAAAA,EAAazC,0BAAeL,OAAAA,EAAS,aAAA;;
|
|
1
|
+
{"version":3,"file":"PrimeCalendar.js","sources":["../../../form/PrimeCalendar.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { DatePicker } from 'primereact/datepicker';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:calendar` component - a date picker, named `DatePicker` by PrimeReact 11.\n *\n * The seed value is parsed from an ISO date string because that is what survives a round trip through a\n * Scene model's JSON properties; an unparseable one leaves the field empty rather than showing\n * \"Invalid Date\".\n *\n * v11's `DatePicker` is a composition, and the grid is the bulk of it: `Calendar` holds a `Header` (the\n * month/year title flanked by the two navigation buttons) and a `Table` whose three `TableBody` views are\n * what makes clicking the title drill from days to months to years. That whole calendar is built once\n * here and then placed one of two ways, which is how `inline` survives a version that has no `inline`\n * prop: either inside a `Panel`, which simply renders where it stands, or behind a `Portal` and a\n * `Positioner`, which anchors it to the field and escapes any clipping ancestor.\n */\nexport function PrimeCalendar({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<Date | undefined>(() => {\n const seed = stringProperty(element, 'value');\n if (seed === undefined) return undefined;\n const parsed = new Date(seed);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n });\n\n const inline = booleanProperty(element, 'inline', false);\n const showTime = booleanProperty(element, 'showTime', false);\n const calendar = (\n <>\n <DatePicker.Calendar>\n <DatePicker.Header>\n <DatePicker.Prev>\n <i className='pi pi-chevron-left' />\n </DatePicker.Prev>\n <DatePicker.Title>\n <DatePicker.SelectMonth />\n <DatePicker.SelectYear />\n <DatePicker.Decade />\n </DatePicker.Title>\n <DatePicker.Next>\n <i className='pi pi-chevron-right' />\n </DatePicker.Next>\n </DatePicker.Header>\n <DatePicker.Table>\n <DatePicker.TableHead />\n <DatePicker.TableBody />\n <DatePicker.TableBody view='month' />\n <DatePicker.TableBody view='year' />\n </DatePicker.Table>\n </DatePicker.Calendar>\n {showTime && <DatePicker.Time />}\n </>\n );\n\n return (\n <DatePicker.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value instanceof Date ? event.value : undefined)}\n dateFormat={stringProperty(element, 'dateFormat')}\n showTime={showTime}\n disabled={booleanProperty(element, 'disabled', false)}>\n {inline ? (\n <DatePicker.Panel>{calendar}</DatePicker.Panel>\n ) : (\n <>\n <DatePicker.Input as={InputText} placeholder={stringProperty(element, 'placeholder')} aria-label={stringProperty(element, 'ariaLabel')} />\n {booleanProperty(element, 'showIcon', true) && (\n <DatePicker.Trigger>\n <i className='pi pi-calendar' />\n </DatePicker.Trigger>\n )}\n <DatePicker.Portal>\n <DatePicker.Positioner align='start'>\n <DatePicker.Popup>{calendar}</DatePicker.Popup>\n </DatePicker.Positioner>\n </DatePicker.Portal>\n </>\n )}\n </DatePicker.Root>\n );\n}\n"],"names":["PrimeCalendar","element","value","setValue","useState","seed","stringProperty","undefined","parsed","Date","Number","isNaN","getTime","inline","booleanProperty","showTime","calendar","_jsxs","_Fragment","DatePicker","Calendar","Header","_jsx","Prev","i","className","Title","SelectMonth","SelectYear","Decade","Next","Table","TableHead","TableBody","view","Time","Root","data-scene-id","id","onValueChange","event","dateFormat","disabled","Panel","Input","as","InputText","placeholder","aria-label","Trigger","Portal","Positioner","align","Popup"],"mappings":";;;;;;;;AASA;;;;;;;;;;;;;AAaC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAA2B,IAAA;QACjD,MAAMC,IAAAA,GAAOC,0BAAeL,OAAAA,EAAS,OAAA,CAAA;QACrC,IAAII,IAAAA,KAASE,WAAW,OAAOA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kC,KAAK,EAAA;AAAErC,4BAAAA,QAAAA,EAAAA;;;;;;;AAO/C;;"}
|
|
@@ -24,6 +24,7 @@ var properties = require('../properties.js');
|
|
|
24
24
|
children: [
|
|
25
25
|
/*#__PURE__*/ jsxRuntime.jsx(checkbox.Checkbox.Root, {
|
|
26
26
|
inputId: element.id,
|
|
27
|
+
"aria-label": label === undefined ? properties.stringProperty(element, 'ariaLabel') : undefined,
|
|
27
28
|
checked: checked,
|
|
28
29
|
onCheckedChange: (event)=>setChecked(event.checked),
|
|
29
30
|
disabled: properties.booleanProperty(element, 'disabled', false),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeCheckbox.js","sources":["../../../form/PrimeCheckbox.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { Checkbox } from 'primereact/checkbox';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:checkbox` component.\n *\n * Rendered with its label rather than bare: an unlabeled checkbox has no accessible name and nothing to\n * click but a 20-pixel box, which is a defect in every screen that would ever use one.\n *\n * PrimeReact 11 makes the tick its own part: `Root` renders the real (visually hidden) input and owns the\n * state, `Box` is the square, and `Indicator` is what appears inside it when checked. The `checked` state\n * now arrives as `onCheckedChange` with a boolean rather than a change event whose `checked` might be\n * `undefined`, so the defensive `=== true` the v10 adapter needed is gone.\n */\nexport function PrimeCheckbox({ element }: RegisteredComponentProps) {\n const [checked, setChecked] = useState(booleanProperty(element, 'checked', false));\n const label = stringProperty(element, 'label');\n return (\n <div data-scene-id={element.id} className='flex items-center gap-2'>\n <Checkbox.Root\n inputId={element.id}\n checked={checked}\n onCheckedChange={(event) => setChecked(event.checked)}\n disabled={booleanProperty(element, 'disabled', false)}>\n <Checkbox.Box>\n <Checkbox.Indicator />\n </Checkbox.Box>\n </Checkbox.Root>\n {label !== undefined && <label htmlFor={element.id}>{label}</label>}\n </div>\n );\n}\n"],"names":["PrimeCheckbox","element","checked","setChecked","useState","booleanProperty","label","stringProperty","_jsxs","div","data-scene-id","id","className","_jsx","Checkbox","Root","inputId","onCheckedChange","event","disabled","Box","Indicator","
|
|
1
|
+
{"version":3,"file":"PrimeCheckbox.js","sources":["../../../form/PrimeCheckbox.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { Checkbox } from 'primereact/checkbox';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:checkbox` component.\n *\n * Rendered with its label rather than bare: an unlabeled checkbox has no accessible name and nothing to\n * click but a 20-pixel box, which is a defect in every screen that would ever use one.\n *\n * PrimeReact 11 makes the tick its own part: `Root` renders the real (visually hidden) input and owns the\n * state, `Box` is the square, and `Indicator` is what appears inside it when checked. The `checked` state\n * now arrives as `onCheckedChange` with a boolean rather than a change event whose `checked` might be\n * `undefined`, so the defensive `=== true` the v10 adapter needed is gone.\n */\nexport function PrimeCheckbox({ element }: RegisteredComponentProps) {\n const [checked, setChecked] = useState(booleanProperty(element, 'checked', false));\n const label = stringProperty(element, 'label');\n return (\n <div data-scene-id={element.id} className='flex items-center gap-2'>\n <Checkbox.Root\n inputId={element.id}\n aria-label={label === undefined ? stringProperty(element, 'ariaLabel') : undefined}\n checked={checked}\n onCheckedChange={(event) => setChecked(event.checked)}\n disabled={booleanProperty(element, 'disabled', false)}>\n <Checkbox.Box>\n <Checkbox.Indicator />\n </Checkbox.Box>\n </Checkbox.Root>\n {label !== undefined && <label htmlFor={element.id}>{label}</label>}\n </div>\n );\n}\n"],"names":["PrimeCheckbox","element","checked","setChecked","useState","booleanProperty","label","stringProperty","_jsxs","div","data-scene-id","id","className","_jsx","Checkbox","Root","inputId","aria-label","undefined","onCheckedChange","event","disabled","Box","Indicator","htmlFor"],"mappings":";;;;;;;AAQA;;;;;;;;;;AAUC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,OAAAA,EAASC,UAAAA,CAAW,GAAGC,cAAAA,CAASC,0BAAAA,CAAgBJ,SAAS,SAAA,EAAW,KAAA,CAAA,CAAA;IAC3E,MAAMK,KAAAA,GAAQC,0BAAeN,OAAAA,EAAS,OAAA,CAAA;AACtC,IAAA,qBACIO,eAAA,CAACC,KAAAA,EAAAA;AAAIC,QAAAA,eAAAA,EAAeT,QAAQU,EAAE;QAAEC,SAAAA,EAAU,yBAAA;;AACtC,0BAAAC,cAAA,CAACC,kBAASC,IAAI,EAAA;AACVC,gBAAAA,OAAAA,EAASf,QAAQU,EAAE;AACnBM,gBAAAA,YAAAA,EAAYX,KAAAA,KAAUY,SAAAA,GAAYX,yBAAAA,CAAeN,OAAAA,EAAS,WAAA,CAAA,GAAeiB,SAAAA;gBACzEhB,OAAAA,EAASA,OAAAA;AACTiB,gBAAAA,eAAAA,EAAiB,CAACC,KAAAA,GAAUjB,UAAAA,CAAWiB,KAAAA,CAAMlB,OAAO,CAAA;gBACpDmB,QAAAA,EAAUhB,0BAAAA,CAAgBJ,SAAS,UAAA,EAAY,KAAA,CAAA;wCAC/CY,cAAA,CAACC,kBAASQ,GAAG,EAAA;4CACTT,cAAA,CAACC,kBAASS,SAAS,EAAA,EAAA;;;AAG1BjB,YAAAA,KAAAA,KAAUY,2BAAaL,cAAA,CAACP,OAAAA,EAAAA;AAAMkB,gBAAAA,OAAAA,EAASvB,QAAQU,EAAE;AAAGL,gBAAAA,QAAAA,EAAAA;;;;AAGjE;;"}
|
|
@@ -33,6 +33,7 @@ var properties = require('../properties.js');
|
|
|
33
33
|
disabled: properties.booleanProperty(element, 'disabled', false),
|
|
34
34
|
children: [
|
|
35
35
|
/*#__PURE__*/ jsxRuntime.jsxs(select.Select.Trigger, {
|
|
36
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel'),
|
|
36
37
|
children: [
|
|
37
38
|
/*#__PURE__*/ jsxRuntime.jsx(select.Select.Value, {
|
|
38
39
|
placeholder: placeholder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeDropdown.js","sources":["../../../form/PrimeDropdown.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { Select } from 'primereact/select';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, optionsProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:dropdown` component - a single-choice select.\n *\n * Options are normalized by `optionsProperty`, so a screen may write either bare strings or\n * `{ label, value }` records and get the same result.\n *\n * PrimeReact calls this `Select`, and it is a composition rather than one component: `Root` owns the\n * value and the option model, `Trigger` is what the user clicks, and the list lives behind a `Portal` so\n * it escapes any clipping ancestor. `Select.List` renders `options` itself - there is no option mapping\n * here, and adding one would only duplicate what `optionLabel` / `optionValue` already say. The `appendTo`\n * and z-index juggling a dropdown inside a dialog used to need is gone with it: the portal stacks\n * correctly on its own.\n */\nexport function PrimeDropdown({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<unknown>(stringProperty(element, 'value'));\n const placeholder = stringProperty(element, 'placeholder', 'Select');\n const filter = booleanProperty(element, 'filter', false);\n const showClear = booleanProperty(element, 'showClear', false);\n return (\n <Select.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value)}\n options={optionsProperty(element, 'options')}\n optionLabel='label'\n optionValue='value'\n filter={filter}\n disabled={booleanProperty(element, 'disabled', false)}>\n <Select.Trigger>\n <Select.Value placeholder={placeholder} />\n {showClear && <Select.Clear />}\n <Select.Arrow />\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n {filter && <Select.Filter placeholder={placeholder} />}\n <Select.List />\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n );\n}\n"],"names":["PrimeDropdown","element","value","setValue","useState","stringProperty","placeholder","filter","booleanProperty","showClear","_jsxs","Select","Root","data-scene-id","id","onValueChange","event","options","optionsProperty","optionLabel","optionValue","disabled","Trigger","_jsx","Value","Clear","Arrow","Portal","Positioner","Popup","Filter","List"],"mappings":";;;;;;;AAQA;;;;;;;;;;;;AAYC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAAkBC,0BAAeJ,OAAAA,EAAS,OAAA,CAAA,CAAA;IACpE,MAAMK,WAAAA,GAAcD,yBAAAA,CAAeJ,OAAAA,EAAS,aAAA,EAAe,QAAA,CAAA;IAC3D,MAAMM,MAAAA,GAASC,0BAAAA,CAAgBP,OAAAA,EAAS,QAAA,EAAU,KAAA,CAAA;IAClD,MAAMQ,SAAAA,GAAYD,0BAAAA,CAAgBP,OAAAA,EAAS,WAAA,EAAa,KAAA,CAAA;IACxD,qBACIS,eAAA,CAACC,cAAOC,IAAI,EAAA;AACRC,QAAAA,eAAAA,EAAeZ,QAAQa,EAAE;QACzBZ,KAAAA,EAAOA,KAAAA;AACPa,QAAAA,aAAAA,EAAe,CAACC,KAAAA,GAAUb,QAAAA,CAASa,KAAAA,CAAMd,KAAK,CAAA;AAC9Ce,QAAAA,OAAAA,EAASC,2BAAgBjB,OAAAA,EAAS,SAAA,CAAA;QAClCkB,WAAAA,EAAY,OAAA;QACZC,WAAAA,EAAY,OAAA;QACZb,MAAAA,EAAQA,MAAAA;QACRc,QAAAA,EAAUb,0BAAAA,CAAgBP,SAAS,UAAA,EAAY,KAAA,CAAA;;AAC/C,0BAAAS,eAAA,CAACC,cAAOW,OAAO,EAAA;;
|
|
1
|
+
{"version":3,"file":"PrimeDropdown.js","sources":["../../../form/PrimeDropdown.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { Select } from 'primereact/select';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, optionsProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:dropdown` component - a single-choice select.\n *\n * Options are normalized by `optionsProperty`, so a screen may write either bare strings or\n * `{ label, value }` records and get the same result.\n *\n * PrimeReact calls this `Select`, and it is a composition rather than one component: `Root` owns the\n * value and the option model, `Trigger` is what the user clicks, and the list lives behind a `Portal` so\n * it escapes any clipping ancestor. `Select.List` renders `options` itself - there is no option mapping\n * here, and adding one would only duplicate what `optionLabel` / `optionValue` already say. The `appendTo`\n * and z-index juggling a dropdown inside a dialog used to need is gone with it: the portal stacks\n * correctly on its own.\n */\nexport function PrimeDropdown({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<unknown>(stringProperty(element, 'value'));\n const placeholder = stringProperty(element, 'placeholder', 'Select');\n const filter = booleanProperty(element, 'filter', false);\n const showClear = booleanProperty(element, 'showClear', false);\n return (\n <Select.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value)}\n options={optionsProperty(element, 'options')}\n optionLabel='label'\n optionValue='value'\n filter={filter}\n disabled={booleanProperty(element, 'disabled', false)}>\n <Select.Trigger aria-label={stringProperty(element, 'ariaLabel')}>\n <Select.Value placeholder={placeholder} />\n {showClear && <Select.Clear />}\n <Select.Arrow />\n </Select.Trigger>\n <Select.Portal>\n <Select.Positioner>\n <Select.Popup>\n {filter && <Select.Filter placeholder={placeholder} />}\n <Select.List />\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n );\n}\n"],"names":["PrimeDropdown","element","value","setValue","useState","stringProperty","placeholder","filter","booleanProperty","showClear","_jsxs","Select","Root","data-scene-id","id","onValueChange","event","options","optionsProperty","optionLabel","optionValue","disabled","Trigger","aria-label","_jsx","Value","Clear","Arrow","Portal","Positioner","Popup","Filter","List"],"mappings":";;;;;;;AAQA;;;;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,UAAU,EAAA;4CACdnB,eAAA,CAACC,cAAOmB,KAAK,EAAA;;4BACRvB,MAAAA,kBAAUiB,cAAA,CAACb,cAAOoB,MAAM,EAAA;gCAACzB,WAAAA,EAAaA;;AACvC,0CAAAkB,cAAA,CAACb,cAAOqB,IAAI,EAAA,EAAA;;;;;;;AAMpC;;"}
|
|
@@ -29,7 +29,8 @@ var properties = require('../properties.js');
|
|
|
29
29
|
disabled: properties.booleanProperty(element, 'disabled', false),
|
|
30
30
|
children: [
|
|
31
31
|
/*#__PURE__*/ jsxRuntime.jsx(inputnumber.InputNumber.Input, {
|
|
32
|
-
placeholder: properties.stringProperty(element, 'placeholder')
|
|
32
|
+
placeholder: properties.stringProperty(element, 'placeholder'),
|
|
33
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel')
|
|
33
34
|
}),
|
|
34
35
|
properties.booleanProperty(element, 'showButtons', false) && /*#__PURE__*/ jsxRuntime.jsxs(inputnumber.InputNumber.Group, {
|
|
35
36
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeInputNumber.js","sources":["../../../form/PrimeInputNumber.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputNumber } from 'primereact/inputnumber';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputNumber` component - a numeric field with locale-aware formatting.\n *\n * `mode` and `currency` are passed straight through because that is where InputNumber earns its keep\n * over a plain text field: it formats and parses in the user's locale rather than making a screen do it.\n *\n * PrimeReact 11 splits the component in two: `Root` holds the number model and `Input` is the field it\n * formats into, which is also why `placeholder` moved onto the input rather than the root. `showButtons`\n * is no longer a flag the component interprets - the spinner is a `Group` of `Increment` and `Decrement`\n * you either render or do not - so the property now decides whether that group exists at all.\n */\nexport function PrimeInputNumber({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<number | undefined>(numberProperty(element, 'value'));\n const currency = stringProperty(element, 'currency');\n return (\n <InputNumber.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(typeof event.value === 'number' ? event.value : undefined)}\n mode={currency === undefined ? 'decimal' : 'currency'}\n currency={currency}\n min={numberProperty(element, 'min')}\n max={numberProperty(element, 'max')}\n disabled={booleanProperty(element, 'disabled', false)}>\n <InputNumber.Input placeholder={stringProperty(element, 'placeholder')} />\n {booleanProperty(element, 'showButtons', false) && (\n <InputNumber.Group>\n <InputNumber.Increment>\n <i className='pi pi-chevron-up' />\n </InputNumber.Increment>\n <InputNumber.Decrement>\n <i className='pi pi-chevron-down' />\n </InputNumber.Decrement>\n </InputNumber.Group>\n )}\n </InputNumber.Root>\n );\n}\n"],"names":["PrimeInputNumber","element","value","setValue","useState","numberProperty","currency","stringProperty","_jsxs","InputNumber","Root","data-scene-id","id","onValueChange","event","undefined","mode","min","max","disabled","booleanProperty","_jsx","Input","placeholder","Group","Increment","i","className","Decrement"],"mappings":";;;;;;;AAQA;;;;;;;;;;AAUC,IACM,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;AAClE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAA6BC,0BAAeJ,OAAAA,EAAS,OAAA,CAAA,CAAA;IAC/E,MAAMK,QAAAA,GAAWC,0BAAeN,OAAAA,EAAS,UAAA,CAAA;IACzC,qBACIO,eAAA,CAACC,wBAAYC,IAAI,EAAA;AACbC,QAAAA,eAAAA,EAAeV,QAAQW,EAAE;QACzBV,KAAAA,EAAOA,KAAAA;QACPW,aAAAA,EAAe,CAACC,KAAAA,GAAUX,QAAAA,CAAS,OAAOW,KAAAA,CAAMZ,KAAK,KAAK,QAAA,GAAWY,KAAAA,CAAMZ,KAAK,GAAGa,SAAAA,CAAAA;QACnFC,IAAAA,EAAMV,QAAAA,KAAaS,YAAY,SAAA,GAAY,UAAA;QAC3CT,QAAAA,EAAUA,QAAAA;AACVW,QAAAA,GAAAA,EAAKZ,0BAAeJ,OAAAA,EAAS,KAAA,CAAA;AAC7BiB,QAAAA,GAAAA,EAAKb,0BAAeJ,OAAAA,EAAS,KAAA,CAAA;QAC7BkB,QAAAA,EAAUC,0BAAAA,CAAgBnB,SAAS,UAAA,EAAY,KAAA,CAAA;;AAC/C,0BAAAoB,cAAA,CAACZ,wBAAYa,KAAK,EAAA;AAACC,gBAAAA,WAAAA,EAAahB,0BAAeN,OAAAA,EAAS,aAAA;;
|
|
1
|
+
{"version":3,"file":"PrimeInputNumber.js","sources":["../../../form/PrimeInputNumber.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputNumber } from 'primereact/inputnumber';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputNumber` component - a numeric field with locale-aware formatting.\n *\n * `mode` and `currency` are passed straight through because that is where InputNumber earns its keep\n * over a plain text field: it formats and parses in the user's locale rather than making a screen do it.\n *\n * PrimeReact 11 splits the component in two: `Root` holds the number model and `Input` is the field it\n * formats into, which is also why `placeholder` moved onto the input rather than the root. `showButtons`\n * is no longer a flag the component interprets - the spinner is a `Group` of `Increment` and `Decrement`\n * you either render or do not - so the property now decides whether that group exists at all.\n */\nexport function PrimeInputNumber({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<number | undefined>(numberProperty(element, 'value'));\n const currency = stringProperty(element, 'currency');\n return (\n <InputNumber.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(typeof event.value === 'number' ? event.value : undefined)}\n mode={currency === undefined ? 'decimal' : 'currency'}\n currency={currency}\n min={numberProperty(element, 'min')}\n max={numberProperty(element, 'max')}\n disabled={booleanProperty(element, 'disabled', false)}>\n <InputNumber.Input placeholder={stringProperty(element, 'placeholder')} aria-label={stringProperty(element, 'ariaLabel')} />\n {booleanProperty(element, 'showButtons', false) && (\n <InputNumber.Group>\n <InputNumber.Increment>\n <i className='pi pi-chevron-up' />\n </InputNumber.Increment>\n <InputNumber.Decrement>\n <i className='pi pi-chevron-down' />\n </InputNumber.Decrement>\n </InputNumber.Group>\n )}\n </InputNumber.Root>\n );\n}\n"],"names":["PrimeInputNumber","element","value","setValue","useState","numberProperty","currency","stringProperty","_jsxs","InputNumber","Root","data-scene-id","id","onValueChange","event","undefined","mode","min","max","disabled","booleanProperty","_jsx","Input","placeholder","aria-label","Group","Increment","i","className","Decrement"],"mappings":";;;;;;;AAQA;;;;;;;;;;AAUC,IACM,SAASA,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;AAClE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAA6BC,0BAAeJ,OAAAA,EAAS,OAAA,CAAA,CAAA;IAC/E,MAAMK,QAAAA,GAAWC,0BAAeN,OAAAA,EAAS,UAAA,CAAA;IACzC,qBACIO,eAAA,CAACC,wBAAYC,IAAI,EAAA;AACbC,QAAAA,eAAAA,EAAeV,QAAQW,EAAE;QACzBV,KAAAA,EAAOA,KAAAA;QACPW,aAAAA,EAAe,CAACC,KAAAA,GAAUX,QAAAA,CAAS,OAAOW,KAAAA,CAAMZ,KAAK,KAAK,QAAA,GAAWY,KAAAA,CAAMZ,KAAK,GAAGa,SAAAA,CAAAA;QACnFC,IAAAA,EAAMV,QAAAA,KAAaS,YAAY,SAAA,GAAY,UAAA;QAC3CT,QAAAA,EAAUA,QAAAA;AACVW,QAAAA,GAAAA,EAAKZ,0BAAeJ,OAAAA,EAAS,KAAA,CAAA;AAC7BiB,QAAAA,GAAAA,EAAKb,0BAAeJ,OAAAA,EAAS,KAAA,CAAA;QAC7BkB,QAAAA,EAAUC,0BAAAA,CAAgBnB,SAAS,UAAA,EAAY,KAAA,CAAA;;AAC/C,0BAAAoB,cAAA,CAACZ,wBAAYa,KAAK,EAAA;AAACC,gBAAAA,WAAAA,EAAahB,0BAAeN,OAAAA,EAAS,aAAA,CAAA;AAAgBuB,gBAAAA,YAAAA,EAAYjB,0BAAeN,OAAAA,EAAS,WAAA;;AAC3GmB,YAAAA,0BAAAA,CAAgBnB,OAAAA,EAAS,aAAA,EAAe,KAAA,CAAA,kBACrCO,eAAA,CAACC,wBAAYgB,KAAK,EAAA;;AACd,kCAAAJ,cAAA,CAACZ,wBAAYiB,SAAS,EAAA;AAClB,wBAAA,QAAA,gBAAAL,cAAA,CAACM,GAAAA,EAAAA;4BAAEC,SAAAA,EAAU;;;AAEjB,kCAAAP,cAAA,CAACZ,wBAAYoB,SAAS,EAAA;AAClB,wBAAA,QAAA,gBAAAR,cAAA,CAACM,GAAAA,EAAAA;4BAAEC,SAAAA,EAAU;;;;;;;AAMrC;;"}
|
|
@@ -20,6 +20,7 @@ var properties = require('../properties.js');
|
|
|
20
20
|
value: value,
|
|
21
21
|
onChange: (event)=>setValue(event.target.value),
|
|
22
22
|
placeholder: properties.stringProperty(element, 'placeholder'),
|
|
23
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel'),
|
|
23
24
|
disabled: properties.booleanProperty(element, 'disabled', false),
|
|
24
25
|
readOnly: properties.booleanProperty(element, 'readOnly', false),
|
|
25
26
|
invalid: properties.booleanProperty(element, 'invalid', false)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeInputText.js","sources":["../../../form/PrimeInputText.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputText` component - a single-line text field.\n *\n * PrimeReact inputs are controlled, and a Scene element has nowhere to put \"what the user has typed so\n * far\" - `properties` is authored design-time configuration, not live state. The adapter therefore owns\n * that state locally, seeded from the `value` property. The consequence is deliberate and worth knowing:\n * a preview is genuinely typeable instead of frozen, and the typed value is local to the rendered\n * component rather than pushed back into the model.\n */\nexport function PrimeInputText({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <InputText\n data-scene-id={element.id}\n value={value}\n onChange={(event) => setValue(event.target.value)}\n placeholder={stringProperty(element, 'placeholder')}\n disabled={booleanProperty(element, 'disabled', false)}\n readOnly={booleanProperty(element, 'readOnly', false)}\n invalid={booleanProperty(element, 'invalid', false)}\n />\n );\n}\n"],"names":["PrimeInputText","element","value","setValue","useState","stringProperty","_jsx","InputText","data-scene-id","id","onChange","event","target","placeholder","disabled","booleanProperty","readOnly","invalid"],"mappings":";;;;;;;AAQA;;;;;;;;AAQC,IACM,SAASA,cAAAA,CAAe,EAAEC,OAAO,EAA4B,EAAA;AAChE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,mBAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,QAAAA,EAAU,CAACC,KAAAA,GAAUR,QAAAA,CAASQ,KAAAA,CAAMC,MAAM,CAACV,KAAK,CAAA;AAChDW,QAAAA,WAAAA,EAAaR,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"PrimeInputText.js","sources":["../../../form/PrimeInputText.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputText` component - a single-line text field.\n *\n * PrimeReact inputs are controlled, and a Scene element has nowhere to put \"what the user has typed so\n * far\" - `properties` is authored design-time configuration, not live state. The adapter therefore owns\n * that state locally, seeded from the `value` property. The consequence is deliberate and worth knowing:\n * a preview is genuinely typeable instead of frozen, and the typed value is local to the rendered\n * component rather than pushed back into the model.\n */\nexport function PrimeInputText({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <InputText\n data-scene-id={element.id}\n value={value}\n onChange={(event) => setValue(event.target.value)}\n placeholder={stringProperty(element, 'placeholder')}\n aria-label={stringProperty(element, 'ariaLabel')}\n disabled={booleanProperty(element, 'disabled', false)}\n readOnly={booleanProperty(element, 'readOnly', false)}\n invalid={booleanProperty(element, 'invalid', false)}\n />\n );\n}\n"],"names":["PrimeInputText","element","value","setValue","useState","stringProperty","_jsx","InputText","data-scene-id","id","onChange","event","target","placeholder","aria-label","disabled","booleanProperty","readOnly","invalid"],"mappings":";;;;;;;AAQA;;;;;;;;AAQC,IACM,SAASA,cAAAA,CAAe,EAAEC,OAAO,EAA4B,EAAA;AAChE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,mBAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,QAAAA,EAAU,CAACC,KAAAA,GAAUR,QAAAA,CAASQ,KAAAA,CAAMC,MAAM,CAACV,KAAK,CAAA;AAChDW,QAAAA,WAAAA,EAAaR,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;AACrCa,QAAAA,YAAAA,EAAYT,0BAAeJ,OAAAA,EAAS,WAAA,CAAA;QACpCc,QAAAA,EAAUC,0BAAAA,CAAgBf,SAAS,UAAA,EAAY,KAAA,CAAA;QAC/CgB,QAAAA,EAAUD,0BAAAA,CAAgBf,SAAS,UAAA,EAAY,KAAA,CAAA;QAC/CiB,OAAAA,EAASF,0BAAAA,CAAgBf,SAAS,SAAA,EAAW,KAAA;;AAGzD;;"}
|
|
@@ -21,6 +21,7 @@ var properties = require('../properties.js');
|
|
|
21
21
|
cols: properties.numberProperty(element, 'cols'),
|
|
22
22
|
autoResize: properties.booleanProperty(element, 'autoResize', false),
|
|
23
23
|
placeholder: properties.stringProperty(element, 'placeholder'),
|
|
24
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel'),
|
|
24
25
|
disabled: properties.booleanProperty(element, 'disabled', false)
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeInputTextarea.js","sources":["../../../form/PrimeInputTextarea.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChangeEvent, useState } from 'react';\nimport { Textarea } from 'primereact/textarea';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputTextarea` component - a multi-line text field, named `Textarea` by PrimeReact 11.\n *\n * One of the few components the version change left alone beyond its name: it is still a single element\n * rather than a composition, and `rows`, `cols` and `placeholder` still reach the underlying `<textarea>`\n * untouched. Holds the typed value locally for the same reason {@link PrimeInputText} does.\n */\nexport function PrimeInputTextarea({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <Textarea\n data-scene-id={element.id}\n value={value}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) => setValue(event.target.value)}\n rows={numberProperty(element, 'rows', 4)}\n cols={numberProperty(element, 'cols')}\n autoResize={booleanProperty(element, 'autoResize', false)}\n placeholder={stringProperty(element, 'placeholder')}\n disabled={booleanProperty(element, 'disabled', false)}\n />\n );\n}\n"],"names":["PrimeInputTextarea","element","value","setValue","useState","stringProperty","_jsx","Textarea","data-scene-id","id","onChange","event","target","rows","numberProperty","cols","autoResize","booleanProperty","placeholder","disabled"],"mappings":";;;;;;;AAQA;;;;;;AAMC,IACM,SAASA,kBAAAA,CAAmB,EAAEC,OAAO,EAA4B,EAAA;AACpE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,iBAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,QAAAA,EAAU,CAACC,KAAAA,GAA4CR,QAAAA,CAASQ,KAAAA,CAAMC,MAAM,CAACV,KAAK,CAAA;QAClFW,IAAAA,EAAMC,yBAAAA,CAAeb,SAAS,MAAA,EAAQ,CAAA,CAAA;AACtCc,QAAAA,IAAAA,EAAMD,0BAAeb,OAAAA,EAAS,MAAA,CAAA;QAC9Be,UAAAA,EAAYC,0BAAAA,CAAgBhB,SAAS,YAAA,EAAc,KAAA,CAAA;AACnDiB,QAAAA,WAAAA,EAAab,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"PrimeInputTextarea.js","sources":["../../../form/PrimeInputTextarea.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChangeEvent, useState } from 'react';\nimport { Textarea } from 'primereact/textarea';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:inputTextarea` component - a multi-line text field, named `Textarea` by PrimeReact 11.\n *\n * One of the few components the version change left alone beyond its name: it is still a single element\n * rather than a composition, and `rows`, `cols` and `placeholder` still reach the underlying `<textarea>`\n * untouched. Holds the typed value locally for the same reason {@link PrimeInputText} does.\n */\nexport function PrimeInputTextarea({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <Textarea\n data-scene-id={element.id}\n value={value}\n onChange={(event: ChangeEvent<HTMLTextAreaElement>) => setValue(event.target.value)}\n rows={numberProperty(element, 'rows', 4)}\n cols={numberProperty(element, 'cols')}\n autoResize={booleanProperty(element, 'autoResize', false)}\n placeholder={stringProperty(element, 'placeholder')}\n aria-label={stringProperty(element, 'ariaLabel')}\n disabled={booleanProperty(element, 'disabled', false)}\n />\n );\n}\n"],"names":["PrimeInputTextarea","element","value","setValue","useState","stringProperty","_jsx","Textarea","data-scene-id","id","onChange","event","target","rows","numberProperty","cols","autoResize","booleanProperty","placeholder","aria-label","disabled"],"mappings":";;;;;;;AAQA;;;;;;AAMC,IACM,SAASA,kBAAAA,CAAmB,EAAEC,OAAO,EAA4B,EAAA;AACpE,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,iBAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,QAAAA,EAAU,CAACC,KAAAA,GAA4CR,QAAAA,CAASQ,KAAAA,CAAMC,MAAM,CAACV,KAAK,CAAA;QAClFW,IAAAA,EAAMC,yBAAAA,CAAeb,SAAS,MAAA,EAAQ,CAAA,CAAA;AACtCc,QAAAA,IAAAA,EAAMD,0BAAeb,OAAAA,EAAS,MAAA,CAAA;QAC9Be,UAAAA,EAAYC,0BAAAA,CAAgBhB,SAAS,YAAA,EAAc,KAAA,CAAA;AACnDiB,QAAAA,WAAAA,EAAab,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;AACrCkB,QAAAA,YAAAA,EAAYd,0BAAeJ,OAAAA,EAAS,WAAA,CAAA;QACpCmB,QAAAA,EAAUH,0BAAAA,CAAgBhB,SAAS,UAAA,EAAY,KAAA;;AAG3D;;"}
|
|
@@ -22,6 +22,7 @@ var properties = require('../properties.js');
|
|
|
22
22
|
onValueChange: (event)=>setValue(event.value ?? ''),
|
|
23
23
|
mask: properties.booleanProperty(element, 'mask', true),
|
|
24
24
|
placeholder: properties.stringProperty(element, 'placeholder'),
|
|
25
|
+
"aria-label": properties.stringProperty(element, 'ariaLabel'),
|
|
25
26
|
disabled: properties.booleanProperty(element, 'disabled', false)
|
|
26
27
|
});
|
|
27
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimePassword.js","sources":["../../../form/PrimePassword.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputPassword } from 'primereact/inputpassword';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:password` component - a masked field, named `InputPassword` by PrimeReact 11.\n *\n * v11 pared this back to what a password field actually is: an input that renders as `type=\"password\"`\n * until something flips `mask`. The v10 `feedback` strength meter and the `toggleMask` eye button are\n * both gone from the component - there is no prompt/weak/medium/strong panel and no built-in reveal\n * control to switch on - so neither property is read here. `mask` is exposed instead, which is the one\n * knob that survived and the one an authored screen can actually mean: a preview that starts revealed.\n * A screen that needs a reveal button now owns that button, because only the screen knows where it goes.\n */\nexport function PrimePassword({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <InputPassword\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value ?? '')}\n mask={booleanProperty(element, 'mask', true)}\n placeholder={stringProperty(element, 'placeholder')}\n disabled={booleanProperty(element, 'disabled', false)}\n />\n );\n}\n"],"names":["PrimePassword","element","value","setValue","useState","stringProperty","_jsx","InputPassword","data-scene-id","id","onValueChange","event","mask","booleanProperty","placeholder","disabled"],"mappings":";;;;;;;AAQA;;;;;;;;;AASC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,2BAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,aAAAA,EAAe,CAACC,KAAAA,GAAUR,QAAAA,CAASQ,KAAAA,CAAMT,KAAK,IAAI,EAAA,CAAA;QAClDU,IAAAA,EAAMC,0BAAAA,CAAgBZ,SAAS,MAAA,EAAQ,IAAA,CAAA;AACvCa,QAAAA,WAAAA,EAAaT,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"PrimePassword.js","sources":["../../../form/PrimePassword.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { InputPassword } from 'primereact/inputpassword';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:password` component - a masked field, named `InputPassword` by PrimeReact 11.\n *\n * v11 pared this back to what a password field actually is: an input that renders as `type=\"password\"`\n * until something flips `mask`. The v10 `feedback` strength meter and the `toggleMask` eye button are\n * both gone from the component - there is no prompt/weak/medium/strong panel and no built-in reveal\n * control to switch on - so neither property is read here. `mask` is exposed instead, which is the one\n * knob that survived and the one an authored screen can actually mean: a preview that starts revealed.\n * A screen that needs a reveal button now owns that button, because only the screen knows where it goes.\n */\nexport function PrimePassword({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState(stringProperty(element, 'value', ''));\n return (\n <InputPassword\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value ?? '')}\n mask={booleanProperty(element, 'mask', true)}\n placeholder={stringProperty(element, 'placeholder')}\n aria-label={stringProperty(element, 'ariaLabel')}\n disabled={booleanProperty(element, 'disabled', false)}\n />\n );\n}\n"],"names":["PrimePassword","element","value","setValue","useState","stringProperty","_jsx","InputPassword","data-scene-id","id","onValueChange","event","mask","booleanProperty","placeholder","aria-label","disabled"],"mappings":";;;;;;;AAQA;;;;;;;;;AASC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAASC,yBAAAA,CAAeJ,SAAS,OAAA,EAAS,EAAA,CAAA,CAAA;AACpE,IAAA,qBACIK,cAAA,CAACC,2BAAAA,EAAAA;AACGC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;QACzBP,KAAAA,EAAOA,KAAAA;AACPQ,QAAAA,aAAAA,EAAe,CAACC,KAAAA,GAAUR,QAAAA,CAASQ,KAAAA,CAAMT,KAAK,IAAI,EAAA,CAAA;QAClDU,IAAAA,EAAMC,0BAAAA,CAAgBZ,SAAS,MAAA,EAAQ,IAAA,CAAA;AACvCa,QAAAA,WAAAA,EAAaT,0BAAeJ,OAAAA,EAAS,aAAA,CAAA;AACrCc,QAAAA,YAAAA,EAAYV,0BAAeJ,OAAAA,EAAS,WAAA,CAAA;QACpCe,QAAAA,EAAUH,0BAAAA,CAAgBZ,SAAS,UAAA,EAAY,KAAA;;AAG3D;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeDataTable.d.ts","sourceRoot":"","sources":["../../../data/PrimeDataTable.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PrimeDataTable.d.ts","sourceRoot":"","sources":["../../../data/PrimeDataTable.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAwB/D,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,wBAAwB,+BAgG1E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { isValidElement } from 'react';
|
|
3
3
|
import { DataTable } from 'primereact/datatable';
|
|
4
|
-
import {
|
|
4
|
+
import { booleanProperty, stringProperty, recordArrayProperty, numberProperty } from '../properties.js';
|
|
5
5
|
import { Column } from './Column.js';
|
|
6
6
|
import { columnDefinitions } from './columnDefinitions.js';
|
|
7
7
|
|
|
@@ -19,14 +19,21 @@ import { columnDefinitions } from './columnDefinitions.js';
|
|
|
19
19
|
* otherwise from the element's model - nested `column` children, a `columns` property, or the shape of
|
|
20
20
|
* the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second
|
|
21
21
|
* only because an explicitly composed declaration is the more specific statement of the two.
|
|
22
|
+
*
|
|
23
|
+
* A host that is still loading the rows sets `loading`, and one whose query failed sets `error` to the
|
|
24
|
+
* message to show. Both replace the rows with one announced row - a status while loading, an alert on
|
|
25
|
+
* error - and keep the column headers, so the table keeps its shape and the reader knows why it is empty.
|
|
22
26
|
*/ function PrimeDataTable({ element, slots }) {
|
|
23
|
-
const
|
|
27
|
+
const loading = booleanProperty(element, 'loading', false);
|
|
28
|
+
const error = stringProperty(element, 'error');
|
|
29
|
+
const rows = loading || error !== undefined ? [] : recordArrayProperty(element, 'rows');
|
|
24
30
|
const declared = declaredColumns(slots);
|
|
25
31
|
const columns = declared.length > 0 ? declared : columnDefinitions(element, rows);
|
|
26
32
|
const pageSize = numberProperty(element, 'pageSize');
|
|
27
33
|
const size = stringProperty(element, 'size');
|
|
28
34
|
return /*#__PURE__*/ jsxs(DataTable.Root, {
|
|
29
35
|
"data-scene-id": element.id,
|
|
36
|
+
"aria-busy": loading,
|
|
30
37
|
data: rows,
|
|
31
38
|
removableSort: true,
|
|
32
39
|
paginator: pageSize !== undefined,
|
|
@@ -84,7 +91,13 @@ import { columnDefinitions } from './columnDefinitions.js';
|
|
|
84
91
|
children: /*#__PURE__*/ jsx(DataTable.Row, {
|
|
85
92
|
children: /*#__PURE__*/ jsx(DataTable.Cell, {
|
|
86
93
|
colSpan: Math.max(columns.length, 1),
|
|
87
|
-
children:
|
|
94
|
+
children: error !== undefined ? /*#__PURE__*/ jsx("span", {
|
|
95
|
+
role: "alert",
|
|
96
|
+
children: error
|
|
97
|
+
}) : loading ? /*#__PURE__*/ jsx("span", {
|
|
98
|
+
role: "status",
|
|
99
|
+
children: stringProperty(element, 'loadingMessage', 'Loading…')
|
|
100
|
+
}) : stringProperty(element, 'emptyMessage', 'No records found')
|
|
88
101
|
})
|
|
89
102
|
})
|
|
90
103
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeDataTable.js","sources":["../../../data/PrimeDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactElement, ReactNode, isValidElement } from 'react';\nimport { DataTable, type DataTableFilterInstance, type DataTablePaginationInstance, type DataTableTBodyItemOptions } from 'primereact/datatable';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, recordArrayProperty, stringProperty } from '../properties';\nimport { Column, ColumnProps } from './Column';\nimport { columnDefinitions } from './columnDefinitions';\n\n/**\n * The `PrimeReact:dataTable` component, also registered under Screenplay's `table` name so a screen\n * compiled from a `.play` file renders through this package without a translation step.\n *\n * PrimeReact 11 turned the table inside out. Where PrimeReact 10 took `value` and a set of `Column`\n * children and produced the whole table, PrimeReact 11 gives back a root that owns sorting, filtering and\n * paging and a set of parts - container, table, head, rows, cells - that the caller arranges. So this\n * adapter now writes out the table's structure itself, and the column concept it renders from is\n * {@link Column}, which is Cratis-owned because PrimeReact 11 removed `primereact/column` entirely.\n *\n * Columns are taken from `Column` declarations when a React caller composed some into a slot, and\n * otherwise from the element's model - nested `column` children, a `columns` property, or the shape of\n * the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second\n * only because an explicitly composed declaration is the more specific statement of the two.\n */\nexport function PrimeDataTable({ element, slots }: RegisteredComponentProps) {\n const rows = recordArrayProperty(element, 'rows');\n const declared = declaredColumns(slots);\n const columns: ColumnProps[] = declared.length > 0 ? declared : columnDefinitions(element, rows);\n const pageSize = numberProperty(element, 'pageSize');\n const size = stringProperty(element, 'size');\n\n return (\n <DataTable.Root\n data-scene-id={element.id}\n data={rows}\n removableSort\n paginator={pageSize !== undefined}\n rows={pageSize}\n stripedRows={booleanProperty(element, 'stripedRows', false)}\n showGridlines={booleanProperty(element, 'showGridlines', false)}\n size={size === 'small' || size === 'large' ? size : undefined}>\n <DataTable.TableContainer>\n <DataTable.Table>\n <DataTable.THead>\n <DataTable.THeadRow>\n {columns.map((column, index) => (\n <DataTable.THeadCell key={column.field ?? index}>\n {column.sortable && column.field ? (\n <DataTable.Sort field={column.field}>\n {headerOf(column)}\n <DataTable.SortIndicator match='asc'> ▲</DataTable.SortIndicator>\n <DataTable.SortIndicator match='desc'> ▼</DataTable.SortIndicator>\n </DataTable.Sort>\n ) : (\n <span>{headerOf(column)}</span>\n )}\n {column.filter && column.field && (\n <DataTable.Filter field={column.field} display='row'>\n {(filter: DataTableFilterInstance) => (\n <input\n className='w-full'\n aria-label={`Filter by ${headerOf(column)}`}\n value={typeof filter.value === 'string' ? filter.value : ''}\n onChange={(event) => filter.onChange(event, event.target.value)}\n />\n )}\n </DataTable.Filter>\n )}\n </DataTable.THeadCell>\n ))}\n </DataTable.THeadRow>\n </DataTable.THead>\n <DataTable.TBody>\n {({ item, index }: DataTableTBodyItemOptions) => (\n <DataTable.Row index={index}>\n {columns.map((column, columnIndex) => (\n <DataTable.Cell key={column.field ?? columnIndex}>{cellOf(column, item)}</DataTable.Cell>\n ))}\n </DataTable.Row>\n )}\n </DataTable.TBody>\n <DataTable.EmptyTBody>\n <DataTable.Row>\n <DataTable.Cell colSpan={Math.max(columns.length, 1)}>\n {stringProperty(element, 'emptyMessage', 'No records found')}\n </DataTable.Cell>\n </DataTable.Row>\n </DataTable.EmptyTBody>\n </DataTable.Table>\n </DataTable.TableContainer>\n <DataTable.Pagination>\n {(pagination: DataTablePaginationInstance) => (\n <div className='flex items-center gap-2 p-2'>\n <button\n type='button'\n disabled={!pagination.canPrev}\n onClick={(event) => pagination.onPageChange(event, pagination.page - 1)}>\n ‹\n </button>\n <span className='text-sm opacity-75'>\n {pagination.page + 1} / {Math.max(pagination.pageCount, 1)}\n </span>\n <button\n type='button'\n disabled={!pagination.canNext}\n onClick={(event) => pagination.onPageChange(event, pagination.page + 1)}>\n ›\n </button>\n </div>\n )}\n </DataTable.Pagination>\n </DataTable.Root>\n );\n}\n\nfunction declaredColumns(slots: Record<string, ReactNode[]>): ColumnProps[] {\n return [...(slots.columns ?? []), ...(slots.content ?? [])]\n .filter((node): node is ReactElement<ColumnProps> => isValidElement(node) && node.type === Column)\n .map((node) => node.props);\n}\n\nfunction headerOf(column: ColumnProps): string {\n return column.header ?? column.field ?? '';\n}\n\nfunction cellOf(column: ColumnProps, row: Record<string, unknown>): ReactNode {\n if (column.body !== undefined) return column.body(row);\n if (column.field === undefined) return '';\n return String(row[column.field] ?? '');\n}\n"],"names":["PrimeDataTable","element","slots","rows","recordArrayProperty","declared","declaredColumns","columns","length","columnDefinitions","pageSize","numberProperty","size","stringProperty","_jsxs","DataTable","Root","data-scene-id","id","data","removableSort","paginator","undefined","stripedRows","booleanProperty","showGridlines","_jsx","TableContainer","Table","THead","THeadRow","map","column","index","THeadCell","sortable","field","Sort","headerOf","SortIndicator","match","span","filter","Filter","display","input","className","aria-label","value","onChange","event","target","TBody","item","Row","columnIndex","Cell","cellOf","EmptyTBody","colSpan","Math","max","Pagination","pagination","div","button","type","disabled","canPrev","onClick","onPageChange","page","pageCount","canNext","content","node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,EAAE,CAAA;;;0CAE5D9C,GAAA,CAACuC,QAAAA,EAAAA;gCACGC,IAAAA,EAAK,QAAA;gCACLC,QAAAA,EAAU,CAACJ,WAAWU,OAAO;gCAC7BJ,OAAAA,EAAS,CAACnB,QAAUa,UAAAA,CAAWO,YAAY,CAACpB,KAAAA,EAAOa,UAAAA,CAAWQ,IAAI,GAAG,CAAA,CAAA;AAAI,gCAAA,QAAA,EAAA;;;;;;;AAQrG;AAEA,SAASjE,gBAAgBJ,KAAkC,EAAA;IACvD,OAAO;WAAKA,KAAAA,CAAMK,OAAO,IAAI,EAAE;WAAOL,KAAAA,CAAMwE,OAAO,IAAI;AAAI,KAAA,CACtDhC,MAAM,CAAC,CAACiC,IAAAA,iBAA4CC,eAAeD,IAAAA,CAAAA,IAASA,IAAAA,CAAKT,IAAI,KAAKW,QAC1F9C,GAAG,CAAC,CAAC4C,IAAAA,GAASA,KAAKG,KAAK,CAAA;AACjC;AAEA,SAASxC,SAASN,MAAmB,EAAA;AACjC,IAAA,OAAOA,MAAAA,CAAO+C,MAAM,IAAI/C,MAAAA,CAAOI,KAAK,IAAI,EAAA;AAC5C;AAEA,SAASqB,MAAAA,CAAOzB,MAAmB,EAAEgD,GAA4B,EAAA;AAC7D,IAAA,IAAIhD,OAAOiD,IAAI,KAAK3D,WAAW,OAAOU,MAAAA,CAAOiD,IAAI,CAACD,GAAAA,CAAAA;AAClD,IAAA,IAAIhD,MAAAA,CAAOI,KAAK,KAAKd,SAAAA,EAAW,OAAO,EAAA;AACvC,IAAA,OAAO4D,OAAOF,GAAG,CAAChD,MAAAA,CAAOI,KAAK,CAAC,IAAI,EAAA,CAAA;AACvC;;"}
|
|
1
|
+
{"version":3,"file":"PrimeDataTable.js","sources":["../../../data/PrimeDataTable.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactElement, ReactNode, isValidElement } from 'react';\nimport { DataTable, type DataTableFilterInstance, type DataTablePaginationInstance, type DataTableTBodyItemOptions } from 'primereact/datatable';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, numberProperty, recordArrayProperty, stringProperty } from '../properties';\nimport { Column, ColumnProps } from './Column';\nimport { columnDefinitions } from './columnDefinitions';\n\n/**\n * The `PrimeReact:dataTable` component, also registered under Screenplay's `table` name so a screen\n * compiled from a `.play` file renders through this package without a translation step.\n *\n * PrimeReact 11 turned the table inside out. Where PrimeReact 10 took `value` and a set of `Column`\n * children and produced the whole table, PrimeReact 11 gives back a root that owns sorting, filtering and\n * paging and a set of parts - container, table, head, rows, cells - that the caller arranges. So this\n * adapter now writes out the table's structure itself, and the column concept it renders from is\n * {@link Column}, which is Cratis-owned because PrimeReact 11 removed `primereact/column` entirely.\n *\n * Columns are taken from `Column` declarations when a React caller composed some into a slot, and\n * otherwise from the element's model - nested `column` children, a `columns` property, or the shape of\n * the first row; see `columnDefinitions`. The model is the path a screen takes, and it is checked second\n * only because an explicitly composed declaration is the more specific statement of the two.\n *\n * A host that is still loading the rows sets `loading`, and one whose query failed sets `error` to the\n * message to show. Both replace the rows with one announced row - a status while loading, an alert on\n * error - and keep the column headers, so the table keeps its shape and the reader knows why it is empty.\n */\nexport function PrimeDataTable({ element, slots }: RegisteredComponentProps) {\n const loading = booleanProperty(element, 'loading', false);\n const error = stringProperty(element, 'error');\n const rows = loading || error !== undefined ? [] : recordArrayProperty(element, 'rows');\n const declared = declaredColumns(slots);\n const columns: ColumnProps[] = declared.length > 0 ? declared : columnDefinitions(element, rows);\n const pageSize = numberProperty(element, 'pageSize');\n const size = stringProperty(element, 'size');\n\n return (\n <DataTable.Root\n data-scene-id={element.id}\n aria-busy={loading}\n data={rows}\n removableSort\n paginator={pageSize !== undefined}\n rows={pageSize}\n stripedRows={booleanProperty(element, 'stripedRows', false)}\n showGridlines={booleanProperty(element, 'showGridlines', false)}\n size={size === 'small' || size === 'large' ? size : undefined}>\n <DataTable.TableContainer>\n <DataTable.Table>\n <DataTable.THead>\n <DataTable.THeadRow>\n {columns.map((column, index) => (\n <DataTable.THeadCell key={column.field ?? index}>\n {column.sortable && column.field ? (\n <DataTable.Sort field={column.field}>\n {headerOf(column)}\n <DataTable.SortIndicator match='asc'> ▲</DataTable.SortIndicator>\n <DataTable.SortIndicator match='desc'> ▼</DataTable.SortIndicator>\n </DataTable.Sort>\n ) : (\n <span>{headerOf(column)}</span>\n )}\n {column.filter && column.field && (\n <DataTable.Filter field={column.field} display='row'>\n {(filter: DataTableFilterInstance) => (\n <input\n className='w-full'\n aria-label={`Filter by ${headerOf(column)}`}\n value={typeof filter.value === 'string' ? filter.value : ''}\n onChange={(event) => filter.onChange(event, event.target.value)}\n />\n )}\n </DataTable.Filter>\n )}\n </DataTable.THeadCell>\n ))}\n </DataTable.THeadRow>\n </DataTable.THead>\n <DataTable.TBody>\n {({ item, index }: DataTableTBodyItemOptions) => (\n <DataTable.Row index={index}>\n {columns.map((column, columnIndex) => (\n <DataTable.Cell key={column.field ?? columnIndex}>{cellOf(column, item)}</DataTable.Cell>\n ))}\n </DataTable.Row>\n )}\n </DataTable.TBody>\n <DataTable.EmptyTBody>\n <DataTable.Row>\n <DataTable.Cell colSpan={Math.max(columns.length, 1)}>\n {error !== undefined\n ? <span role='alert'>{error}</span>\n : loading\n ? <span role='status'>{stringProperty(element, 'loadingMessage', 'Loading…')}</span>\n : stringProperty(element, 'emptyMessage', 'No records found')}\n </DataTable.Cell>\n </DataTable.Row>\n </DataTable.EmptyTBody>\n </DataTable.Table>\n </DataTable.TableContainer>\n <DataTable.Pagination>\n {(pagination: DataTablePaginationInstance) => (\n <div className='flex items-center gap-2 p-2'>\n <button\n type='button'\n disabled={!pagination.canPrev}\n onClick={(event) => pagination.onPageChange(event, pagination.page - 1)}>\n ‹\n </button>\n <span className='text-sm opacity-75'>\n {pagination.page + 1} / {Math.max(pagination.pageCount, 1)}\n </span>\n <button\n type='button'\n disabled={!pagination.canNext}\n onClick={(event) => pagination.onPageChange(event, pagination.page + 1)}>\n ›\n </button>\n </div>\n )}\n </DataTable.Pagination>\n </DataTable.Root>\n );\n}\n\nfunction declaredColumns(slots: Record<string, ReactNode[]>): ColumnProps[] {\n return [...(slots.columns ?? []), ...(slots.content ?? [])]\n .filter((node): node is ReactElement<ColumnProps> => isValidElement(node) && node.type === Column)\n .map((node) => node.props);\n}\n\nfunction headerOf(column: ColumnProps): string {\n return column.header ?? column.field ?? '';\n}\n\nfunction cellOf(column: ColumnProps, row: Record<string, unknown>): ReactNode {\n if (column.body !== undefined) return column.body(row);\n if (column.field === undefined) return '';\n return String(row[column.field] ?? '');\n}\n"],"names":["PrimeDataTable","element","slots","loading","booleanProperty","error","stringProperty","rows","undefined","recordArrayProperty","declared","declaredColumns","columns","length","columnDefinitions","pageSize","numberProperty","size","_jsxs","DataTable","Root","data-scene-id","id","aria-busy","data","removableSort","paginator","stripedRows","showGridlines","_jsx","TableContainer","Table","THead","THeadRow","map","column","index","THeadCell","sortable","field","Sort","headerOf","SortIndicator","match","span","filter","Filter","display","input","className","aria-label","value","onChange","event","target","TBody","item","Row","columnIndex","Cell","cellOf","EmptyTBody","colSpan","Math","max","role","Pagination","pagination","div","button","type","disabled","canPrev","onClick","onPageChange","page","pageCount","canNext","content","node","isValidElement","Column","props","header","row","body","String"],"mappings":";;;;;;;AAUA;;;;;;;;;;;;;;;;;;AAkBC,IACM,SAASA,cAAAA,CAAe,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;IACvE,MAAMC,OAAAA,GAAUC,eAAAA,CAAgBH,OAAAA,EAAS,SAAA,EAAW,KAAA,CAAA;IACpD,MAAMI,KAAAA,GAAQC,eAAeL,OAAAA,EAAS,OAAA,CAAA;AACtC,IAAA,MAAMM,OAAOJ,OAAAA,IAAWE,KAAAA,KAAUG,YAAY,EAAE,GAAGC,oBAAoBR,OAAAA,EAAS,MAAA,CAAA;AAChF,IAAA,MAAMS,WAAWC,eAAAA,CAAgBT,KAAAA,CAAAA;AACjC,IA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, {
|
|
83
83
|
as: InputText,
|
|
84
|
-
placeholder: stringProperty(element, 'placeholder')
|
|
84
|
+
placeholder: stringProperty(element, 'placeholder'),
|
|
85
|
+
"aria-label": stringProperty(element, 'ariaLabel')
|
|
85
86
|
}),
|
|
86
87
|
booleanProperty(element, 'showIcon', true) && /*#__PURE__*/ jsx(DatePicker.Trigger, {
|
|
87
88
|
children: /*#__PURE__*/ jsx("i", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeCalendar.js","sources":["../../../form/PrimeCalendar.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { DatePicker } from 'primereact/datepicker';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:calendar` component - a date picker, named `DatePicker` by PrimeReact 11.\n *\n * The seed value is parsed from an ISO date string because that is what survives a round trip through a\n * Scene model's JSON properties; an unparseable one leaves the field empty rather than showing\n * \"Invalid Date\".\n *\n * v11's `DatePicker` is a composition, and the grid is the bulk of it: `Calendar` holds a `Header` (the\n * month/year title flanked by the two navigation buttons) and a `Table` whose three `TableBody` views are\n * what makes clicking the title drill from days to months to years. That whole calendar is built once\n * here and then placed one of two ways, which is how `inline` survives a version that has no `inline`\n * prop: either inside a `Panel`, which simply renders where it stands, or behind a `Portal` and a\n * `Positioner`, which anchors it to the field and escapes any clipping ancestor.\n */\nexport function PrimeCalendar({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<Date | undefined>(() => {\n const seed = stringProperty(element, 'value');\n if (seed === undefined) return undefined;\n const parsed = new Date(seed);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n });\n\n const inline = booleanProperty(element, 'inline', false);\n const showTime = booleanProperty(element, 'showTime', false);\n const calendar = (\n <>\n <DatePicker.Calendar>\n <DatePicker.Header>\n <DatePicker.Prev>\n <i className='pi pi-chevron-left' />\n </DatePicker.Prev>\n <DatePicker.Title>\n <DatePicker.SelectMonth />\n <DatePicker.SelectYear />\n <DatePicker.Decade />\n </DatePicker.Title>\n <DatePicker.Next>\n <i className='pi pi-chevron-right' />\n </DatePicker.Next>\n </DatePicker.Header>\n <DatePicker.Table>\n <DatePicker.TableHead />\n <DatePicker.TableBody />\n <DatePicker.TableBody view='month' />\n <DatePicker.TableBody view='year' />\n </DatePicker.Table>\n </DatePicker.Calendar>\n {showTime && <DatePicker.Time />}\n </>\n );\n\n return (\n <DatePicker.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value instanceof Date ? event.value : undefined)}\n dateFormat={stringProperty(element, 'dateFormat')}\n showTime={showTime}\n disabled={booleanProperty(element, 'disabled', false)}>\n {inline ? (\n <DatePicker.Panel>{calendar}</DatePicker.Panel>\n ) : (\n <>\n <DatePicker.Input as={InputText} placeholder={stringProperty(element, 'placeholder')} />\n {booleanProperty(element, 'showIcon', true) && (\n <DatePicker.Trigger>\n <i className='pi pi-calendar' />\n </DatePicker.Trigger>\n )}\n <DatePicker.Portal>\n <DatePicker.Positioner align='start'>\n <DatePicker.Popup>{calendar}</DatePicker.Popup>\n </DatePicker.Positioner>\n </DatePicker.Portal>\n </>\n )}\n </DatePicker.Root>\n );\n}\n"],"names":["PrimeCalendar","element","value","setValue","useState","seed","stringProperty","undefined","parsed","Date","Number","isNaN","getTime","inline","booleanProperty","showTime","calendar","_jsxs","_Fragment","DatePicker","Calendar","Header","_jsx","Prev","i","className","Title","SelectMonth","SelectYear","Decade","Next","Table","TableHead","TableBody","view","Time","Root","data-scene-id","id","onValueChange","event","dateFormat","disabled","Panel","Input","as","InputText","placeholder","Trigger","Portal","Positioner","align","Popup"],"mappings":";;;;;;AASA;;;;;;;;;;;;;AAaC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,E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AAA,CAACH,WAAWc,SAAS,EAAA,EAAA,CAAA;AACrB,0CAAAX,GAAA,CAACH,WAAWc,SAAS,EAAA;gCAACC,IAAAA,EAAK;;AAC3B,0CAAAZ,GAAA,CAACH,WAAWc,SAAS,EAAA;gCAACC,IAAAA,EAAK;;;;;;YAGlCnB,QAAAA,kBAAYO,GAAA,CAACH,WAAWgB,IAAI,EAAA,EAAA;;;IAIrC,qBACIb,GAAA,CAACH,WAAWiB,IAAI,EAAA;AACZC,QAAAA,eAAAA,EAAepC,QAAQqC,EAAE;QACzBpC,KAAAA,EAAOA,KAAAA;QACPqC,aAAAA,EAAe,CAACC,QAAUrC,QAAAA,CAASqC,KAAAA,CAAMtC,KAAK,YAAYO,IAAAA,GAAO+B,KAAAA,CAAMtC,KAAK,GAAGK,SAAAA,CAAAA;AAC/EkC,QAAAA,UAAAA,EAAYnC,eAAeL,OAAAA,EAAS,YAAA,CAAA;QACpCc,QAAAA,EAAUA,QAAAA;QACV2B,QAAAA,EAAU5B,eAAAA,CAAgBb,SAAS,UAAA,EAAY,KAAA,CAAA;kBAC9CY,MAAAA,iBACGS,GAAA,CAACH,WAAWwB,KAAK,EAAA;AAAE3B,YAAAA,QAAAA,EAAAA;AAEnB,SAAA,CAAA,iBAAAC,IAAA,CAAAC,QAAA,EAAA;;AACI,8BAAAI,GAAA,CAACH,WAAWyB,KAAK,EAAA;oBAACC,EAAAA,EAAIC,SAAAA;AAAWC,oBAAAA,WAAAA,EAAazC,eAAeL,OAAAA,EAAS,aAAA;;
|
|
1
|
+
{"version":3,"file":"PrimeCalendar.js","sources":["../../../form/PrimeCalendar.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState } from 'react';\nimport { DatePicker } from 'primereact/datepicker';\nimport { InputText } from 'primereact/inputtext';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { booleanProperty, stringProperty } from '../properties';\n\n/**\n * The `PrimeReact:calendar` component - a date picker, named `DatePicker` by PrimeReact 11.\n *\n * The seed value is parsed from an ISO date string because that is what survives a round trip through a\n * Scene model's JSON properties; an unparseable one leaves the field empty rather than showing\n * \"Invalid Date\".\n *\n * v11's `DatePicker` is a composition, and the grid is the bulk of it: `Calendar` holds a `Header` (the\n * month/year title flanked by the two navigation buttons) and a `Table` whose three `TableBody` views are\n * what makes clicking the title drill from days to months to years. That whole calendar is built once\n * here and then placed one of two ways, which is how `inline` survives a version that has no `inline`\n * prop: either inside a `Panel`, which simply renders where it stands, or behind a `Portal` and a\n * `Positioner`, which anchors it to the field and escapes any clipping ancestor.\n */\nexport function PrimeCalendar({ element }: RegisteredComponentProps) {\n const [value, setValue] = useState<Date | undefined>(() => {\n const seed = stringProperty(element, 'value');\n if (seed === undefined) return undefined;\n const parsed = new Date(seed);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed;\n });\n\n const inline = booleanProperty(element, 'inline', false);\n const showTime = booleanProperty(element, 'showTime', false);\n const calendar = (\n <>\n <DatePicker.Calendar>\n <DatePicker.Header>\n <DatePicker.Prev>\n <i className='pi pi-chevron-left' />\n </DatePicker.Prev>\n <DatePicker.Title>\n <DatePicker.SelectMonth />\n <DatePicker.SelectYear />\n <DatePicker.Decade />\n </DatePicker.Title>\n <DatePicker.Next>\n <i className='pi pi-chevron-right' />\n </DatePicker.Next>\n </DatePicker.Header>\n <DatePicker.Table>\n <DatePicker.TableHead />\n <DatePicker.TableBody />\n <DatePicker.TableBody view='month' />\n <DatePicker.TableBody view='year' />\n </DatePicker.Table>\n </DatePicker.Calendar>\n {showTime && <DatePicker.Time />}\n </>\n );\n\n return (\n <DatePicker.Root\n data-scene-id={element.id}\n value={value}\n onValueChange={(event) => setValue(event.value instanceof Date ? event.value : undefined)}\n dateFormat={stringProperty(element, 'dateFormat')}\n showTime={showTime}\n disabled={booleanProperty(element, 'disabled', false)}>\n {inline ? (\n <DatePicker.Panel>{calendar}</DatePicker.Panel>\n ) : (\n <>\n <DatePicker.Input as={InputText} placeholder={stringProperty(element, 'placeholder')} aria-label={stringProperty(element, 'ariaLabel')} />\n {booleanProperty(element, 'showIcon', true) && (\n <DatePicker.Trigger>\n <i className='pi pi-calendar' />\n </DatePicker.Trigger>\n )}\n <DatePicker.Portal>\n <DatePicker.Positioner align='start'>\n <DatePicker.Popup>{calendar}</DatePicker.Popup>\n </DatePicker.Positioner>\n </DatePicker.Portal>\n </>\n )}\n </DatePicker.Root>\n );\n}\n"],"names":["PrimeCalendar","element","value","setValue","useState","seed","stringProperty","undefined","parsed","Date","Number","isNaN","getTime","inline","booleanProperty","showTime","calendar","_jsxs","_Fragment","DatePicker","Calendar","Header","_jsx","Prev","i","className","Title","SelectMonth","SelectYear","Decade","Next","Table","TableHead","TableBody","view","Time","Root","data-scene-id","id","onValueChange","event","dateFormat","disabled","Panel","Input","as","InputText","placeholder","aria-label","Trigger","Portal","Positioner","align","Popup"],"mappings":";;;;;;AASA;;;;;;;;;;;;;AAaC,IACM,SAASA,aAAAA,CAAc,EAAEC,OAAO,EAA4B,EAAA;AAC/D,IAAA,MAAM,CAACC,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,QAAAA,CAA2B,IAAA;QACjD,MAAMC,IAAAA,GAAOC,eAAeL,OAAAA,EAAS,OAAA,CAAA;QACrC,IAAII,IAAAA,KAASE,WAAW,OAAOA,SAAAA;QAC/B,MAAMC,MAAAA,GAAS,IAAIC,IAAAA,CAAKJ,IAAAA,CAAAA;AACxB,QAAA,OAAOK,OAAOC,KAAK,CAACH,MAAAA,CAAOI,OAAO,MAAML,SAAAA,GAAYC,MAAAA;AACxD,IAAA,CAAA,CAAA;IAEA,MAAMK,MAAAA,GAASC,eAAAA,CAAgBb,OAAAA,EAAS,QAAA,EAAU,KAAA,CAAA;IAClD,MAAMc,QAAAA,GAAWD,eAAAA,CAAgBb,OAAAA,EAAS,UAAA,EAAY,KAAA,CAAA;AACtD,IAAA,MAAMe,QAAAA,iBACFC,IAAA,CAAAC,QAA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eAAeL,OAAAA,EAAS,YAAA,CAAA;QACpCc,QAAAA,EAAUA,QAAAA;QACV2B,QAAAA,EAAU5B,eAAAA,CAAgBb,SAAS,UAAA,EAAY,KAAA,CAAA;kBAC9CY,MAAAA,iBACGS,GAAA,CAACH,WAAWwB,KAAK,EAAA;AAAE3B,YAAAA,QAAAA,EAAAA;AAEnB,SAAA,CAAA,iBAAAC,IAAA,CAAAC,QAAA,EAAA;;AACI,8BAAAI,GAAA,CAACH,WAAWyB,KAAK,EAAA;oBAACC,EAAAA,EAAIC,SAAAA;AAAWC,oBAAAA,WAAAA,EAAazC,eAAeL,OAAAA,EAAS,aAAA,CAAA;AAAgB+C,oBAAAA,YAAAA,EAAY1C,eAAeL,OAAAA,EAAS,WAAA;;AACzHa,gBAAAA,eAAAA,CAAgBb,OAAAA,EAAS,UAAA,EAAY,IAAA,CAAA,kBAClCqB,GAAA,CAACH,WAAW8B,OAAO,EAAA;AACf,oBAAA,QAAA,gBAAA3B,GAAA,CAACE,GAAAA,EAAAA;wBAAEC,SAAAA,EAAU;;;AAGrB,8BAAAH,GAAA,CAACH,WAAW+B,MAAM,EAAA;4CACd5B,GAAA,CAACH,WAAWgC,UAAU,EAAA;wBAACC,KAAAA,EAAM,OAAA;gDACzB9B,GAAA,CAACH,WAAWkC,KAAK,EAAA;AAAErC,4BAAAA,QAAAA,EAAAA;;;;;;;AAO/C;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimeCheckbox.d.ts","sourceRoot":"","sources":["../../../form/PrimeCheckbox.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAc/D,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+
|
|
1
|
+
{"version":3,"file":"PrimeCheckbox.d.ts","sourceRoot":"","sources":["../../../form/PrimeCheckbox.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAc/D,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAkBlE"}
|
|
@@ -22,6 +22,7 @@ import { booleanProperty, stringProperty } from '../properties.js';
|
|
|
22
22
|
children: [
|
|
23
23
|
/*#__PURE__*/ jsx(Checkbox.Root, {
|
|
24
24
|
inputId: element.id,
|
|
25
|
+
"aria-label": label === undefined ? stringProperty(element, 'ariaLabel') : undefined,
|
|
25
26
|
checked: checked,
|
|
26
27
|
onCheckedChange: (event)=>setChecked(event.checked),
|
|
27
28
|
disabled: booleanProperty(element, 'disabled', false),
|