@cratis/components 4.43.0 → 4.44.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.
Files changed (57) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -1
  3. package/dist/esm/CommandForm/fields/CheckboxField.js +29 -12
  4. package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -1
  5. package/dist/esm/CommandForm/fields/InputTextField.d.ts.map +1 -1
  6. package/dist/esm/CommandForm/fields/InputTextField.js +30 -9
  7. package/dist/esm/CommandForm/fields/InputTextField.js.map +1 -1
  8. package/dist/esm/CommandForm/fields/RadioButtonField.d.ts.map +1 -1
  9. package/dist/esm/CommandForm/fields/RadioButtonField.js +31 -12
  10. package/dist/esm/CommandForm/fields/RadioButtonField.js.map +1 -1
  11. package/dist/esm/CommandForm/fields/RadioGroupField.d.ts.map +1 -1
  12. package/dist/esm/CommandForm/fields/RadioGroupField.js +34 -32
  13. package/dist/esm/CommandForm/fields/RadioGroupField.js.map +1 -1
  14. package/dist/esm/CommandForm/fields/TextAreaField.d.ts.map +1 -1
  15. package/dist/esm/CommandForm/fields/TextAreaField.js +25 -9
  16. package/dist/esm/CommandForm/fields/TextAreaField.js.map +1 -1
  17. package/dist/esm/CommandForm/fields/ToggleSwitchField.d.ts.map +1 -1
  18. package/dist/esm/CommandForm/fields/ToggleSwitchField.js +29 -9
  19. package/dist/esm/CommandForm/fields/ToggleSwitchField.js.map +1 -1
  20. package/dist/esm/CommandForm/fields/fieldSlotHelpers.d.ts +13 -0
  21. package/dist/esm/CommandForm/fields/fieldSlotHelpers.d.ts.map +1 -0
  22. package/dist/esm/CommandForm/fields/fieldSlotHelpers.js +8 -0
  23. package/dist/esm/CommandForm/fields/fieldSlotHelpers.js.map +1 -0
  24. package/dist/esm/Dialogs/DialogFooter.d.ts.map +1 -1
  25. package/dist/esm/Dialogs/DialogFooter.js +28 -9
  26. package/dist/esm/Dialogs/DialogFooter.js.map +1 -1
  27. package/dist/esm/Dialogs/DialogFooterButton.d.ts +16 -0
  28. package/dist/esm/Dialogs/DialogFooterButton.d.ts.map +1 -0
  29. package/dist/esm/Dialogs/DialogFooterButton.js +23 -0
  30. package/dist/esm/Dialogs/DialogFooterButton.js.map +1 -0
  31. package/dist/esm/styles.Canvas.css +40 -22
  32. package/dist/esm/styles.CommandDialog.css +42 -23
  33. package/dist/esm/styles.CommandForm.css +45 -25
  34. package/dist/esm/styles.CommandStepper.css +42 -23
  35. package/dist/esm/styles.Common.css +40 -22
  36. package/dist/esm/styles.ConfigurationEditor.css +12 -5
  37. package/dist/esm/styles.DataPage.css +57 -32
  38. package/dist/esm/styles.DataTables.css +57 -32
  39. package/dist/esm/styles.Dialogs.css +6 -4
  40. package/dist/esm/styles.Display.css +38 -20
  41. package/dist/esm/styles.Dropdown.css +45 -25
  42. package/dist/esm/styles.Filter.css +8 -7
  43. package/dist/esm/styles.IconPicker.css +6 -2
  44. package/dist/esm/styles.MarkdownEditor.css +2 -1
  45. package/dist/esm/styles.Notifications.css +4 -3
  46. package/dist/esm/styles.ObjectContentEditor.css +40 -22
  47. package/dist/esm/styles.ObjectNavigationalBar.css +36 -19
  48. package/dist/esm/styles.PivotViewer.css +12 -9
  49. package/dist/esm/styles.SchemaEditor.css +68 -38
  50. package/dist/esm/styles.TimeMachine.css +2 -1
  51. package/dist/esm/styles.Toolbar.css +51 -32
  52. package/dist/esm/styles.css +109 -65
  53. package/dist/esm/styles.renderer.builtin.css +59 -33
  54. package/dist/esm/theme.css +12 -0
  55. package/dist/esm/themes/designsystemet.css +103 -0
  56. package/dist/esm/tokens.css +12 -0
  57. package/package.json +3 -2
@@ -70,7 +70,7 @@
70
70
  {
71
71
  "name": "@cratis/components",
72
72
  "role": "core",
73
- "version": "4.43.0",
73
+ "version": "4.44.0",
74
74
  "releaseMajorRange": ">=4 <5",
75
75
  "independentRelease": false,
76
76
  "private": false,
@@ -94,7 +94,7 @@
94
94
  {
95
95
  "name": "@cratis/eslint-plugin-components",
96
96
  "role": "eslint",
97
- "version": "4.43.0",
97
+ "version": "4.44.0",
98
98
  "releaseMajorRange": ">=4 <5",
99
99
  "independentRelease": false,
100
100
  "private": false,
@@ -107,7 +107,7 @@
107
107
  {
108
108
  "name": "@cratis/components.migrator",
109
109
  "role": "migrator",
110
- "version": "4.43.0",
110
+ "version": "4.44.0",
111
111
  "releaseMajorRange": ">=4 <5",
112
112
  "independentRelease": false,
113
113
  "private": false,
@@ -118,13 +118,13 @@
118
118
  {
119
119
  "name": "@cratis/components.conformance",
120
120
  "role": "conformance",
121
- "version": "4.43.0",
121
+ "version": "4.44.0",
122
122
  "releaseMajorRange": ">=4 <5",
123
123
  "independentRelease": false,
124
124
  "private": false,
125
125
  "packageAccess": "public",
126
126
  "peerDependencies": {
127
- "@cratis/components": "4.43.0",
127
+ "@cratis/components": "4.44.0",
128
128
  "react": "^19.0.0",
129
129
  "react-dom": "^19.0.0"
130
130
  },
@@ -134,13 +134,13 @@
134
134
  {
135
135
  "name": "@cratis/components.mui",
136
136
  "role": "renderer-adapter",
137
- "version": "4.43.0",
137
+ "version": "4.44.0",
138
138
  "releaseMajorRange": ">=4 <5",
139
139
  "independentRelease": false,
140
140
  "private": false,
141
141
  "packageAccess": "public",
142
142
  "peerDependencies": {
143
- "@cratis/components": "4.43.0",
143
+ "@cratis/components": "4.44.0",
144
144
  "@emotion/react": ">=11.5 <12",
145
145
  "@emotion/styled": ">=11.11 <12",
146
146
  "@mui/material": ">=9 <10",
@@ -190,13 +190,13 @@
190
190
  {
191
191
  "name": "@cratis/components.primereact",
192
192
  "role": "renderer-adapter",
193
- "version": "4.43.0",
193
+ "version": "4.44.0",
194
194
  "releaseMajorRange": ">=4 <5",
195
195
  "independentRelease": false,
196
196
  "private": false,
197
197
  "packageAccess": "public",
198
198
  "peerDependencies": {
199
- "@cratis/components": "4.43.0",
199
+ "@cratis/components": "4.44.0",
200
200
  "@primereact/core": ">=11 <12",
201
201
  "@primereact/ui": ">=11 <12",
202
202
  "@primeuix/themes": ">=3 <4",
@@ -258,13 +258,13 @@
258
258
  {
259
259
  "name": "@cratis/components.primereact10",
260
260
  "role": "renderer-adapter",
261
- "version": "4.43.0",
261
+ "version": "4.44.0",
262
262
  "releaseMajorRange": ">=4 <5",
263
263
  "independentRelease": false,
264
264
  "private": false,
265
265
  "packageAccess": "public",
266
266
  "peerDependencies": {
267
- "@cratis/components": "4.43.0",
267
+ "@cratis/components": "4.44.0",
268
268
  "primereact": ">=10.9.9 <11",
269
269
  "react": "^19.0.0",
270
270
  "react-dom": "^19.0.0"
@@ -306,13 +306,13 @@
306
306
  {
307
307
  "name": "@cratis/components.designsystemet",
308
308
  "role": "renderer-adapter",
309
- "version": "4.43.0",
309
+ "version": "4.44.0",
310
310
  "releaseMajorRange": ">=4 <5",
311
311
  "independentRelease": false,
312
312
  "private": false,
313
313
  "packageAccess": "public",
314
314
  "peerDependencies": {
315
- "@cratis/components": "4.43.0",
315
+ "@cratis/components": "4.44.0",
316
316
  "@digdir/designsystemet-css": ">=1.24 <2",
317
317
  "@digdir/designsystemet-react": ">=1.24 <2",
318
318
  "react": "^19.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/CheckboxField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAI9B,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC1B,sBAAsB;IACtB,IAAI,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACxC,6BAA6B;IAC7B,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,2BAA2B;I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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA6HD,sEAAsE;AACtE,eAAO,MAAM,aAAa,0NA4BzB,CAAC"}
@@ -1,25 +1,42 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { asCommandFormField } from '@cratis/arc.react/commands';
3
+ import { unstable_useSlot } from '../../renderer/RendererContext.js';
4
+ import { renderSlot } from '../../renderer/renderSlot.js';
5
+ import { joinClassNames, userChange } from './fieldSlotHelpers.js';
3
6
  import { useFieldAccessibility } from './fieldAccessibility.js';
4
7
 
8
+ const CheckboxInput = ({ parts, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, checked, onChange, state, }) => (jsx("input", { ...parts, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, type: 'checkbox', checked: checked, onChange: (event) => onChange?.(event.currentTarget.checked, userChange(event)), "aria-invalid": state.invalid || undefined, className: joinClassNames('cratis-choice-field__native', parts?.className), "data-cratis-part": 'input', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined }));
9
+ const CheckboxBox = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-checkbox__box', parts?.className), "data-cratis-part": 'box', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, "aria-hidden": 'true', children: children }));
10
+ const CheckboxIndicator = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-checkbox__indicator', parts?.className), "data-cratis-part": 'indicator', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: children }));
11
+ const CheckboxFieldCore = ({ id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, label, checked, onChange, onBlur, invalid, className, pt, }) => {
12
+ const state = { disabled: pt?.input?.disabled, invalid, selected: checked };
13
+ return (jsxs("label", { ...pt?.root, className: joinClassNames('cratis-choice-field', pt?.root?.className, className), onBlur: onBlur, "data-cratis-part": 'root', "data-cratis-component": 'CheckboxField', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: [jsx(CheckboxInput, { parts: pt?.input, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, checked: checked, onChange: onChange, state: state }), jsx(CheckboxBox, { parts: pt?.box, state: state, children: jsx(CheckboxIndicator, { parts: pt?.indicator, state: state, children: "\u2713" }) }), label && jsx("span", { className: 'cratis-choice-field__label', children: label })] }));
14
+ };
15
+ const coreCheckboxDeclaration = Object.freeze({
16
+ mode: 'presentation',
17
+ fidelity: 'native',
18
+ render: CheckboxFieldCore,
19
+ });
5
20
  const CheckboxField = asCommandFormField((props) => {
6
21
  const accessibility = useFieldAccessibility(props, {
7
22
  id: props.pt?.input?.id,
8
23
  ariaLabel: props.pt?.input?.['aria-label'] ?? props.label,
9
24
  ariaDescribedBy: props.pt?.input?.['aria-describedby'],
10
25
  });
11
- return (jsxs(Fragment, { children: [jsxs("label", { ...props.pt?.root, className: ['cratis-choice-field', props.pt?.root?.className, props.className]
12
- .filter(Boolean)
13
- .join(' '), onBlur: props.onBlur, "data-cratis-part": 'root', "data-cratis-component": 'CheckboxField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": props.value || undefined, children: [jsx("input", { ...props.pt?.input, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, type: 'checkbox', checked: props.value, onChange: (event) => props.onChange(event.currentTarget.checked), "aria-invalid": props.invalid || undefined, className: ['cratis-choice-field__native', props.pt?.input?.className]
14
- .filter(Boolean)
15
- .join(' '), "data-cratis-part": 'input', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": props.value || undefined }), jsx("span", { ...props.pt?.box, className: ['cratis-checkbox__box', props.pt?.box?.className]
16
- .filter(Boolean)
17
- .join(' '), "data-cratis-part": 'box', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": props.value || undefined, "aria-hidden": 'true', children: jsx("span", { ...props.pt?.indicator, className: [
18
- 'cratis-checkbox__indicator',
19
- props.pt?.indicator?.className,
20
- ]
21
- .filter(Boolean)
22
- .join(' '), "data-cratis-part": 'indicator', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": props.value || undefined, children: "\u2713" }) }), props.label && (jsx("span", { className: 'cratis-choice-field__label', children: props.label }))] }), accessibility.hiddenError] }));
26
+ const declaration = unstable_useSlot('common.checkbox', coreCheckboxDeclaration);
27
+ return (jsxs(Fragment, { children: [renderSlot(declaration, {
28
+ id: accessibility.controlId,
29
+ 'aria-label': accessibility.ariaLabel,
30
+ 'aria-describedby': accessibility.ariaDescribedBy,
31
+ label: props.label,
32
+ checked: props.value,
33
+ onChange: (checked) => props.onChange(checked),
34
+ onBlur: props.onBlur,
35
+ invalid: props.invalid,
36
+ 'aria-invalid': props.invalid || undefined,
37
+ className: props.className,
38
+ pt: props.pt,
39
+ }), accessibility.hiddenError] }));
23
40
  }, { defaultValue: false });
24
41
 
25
42
  export { CheckboxField };
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxField.js","sources":["../../../../CommandForm/fields/CheckboxField.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 type { HTMLAttributes, InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link CheckboxField}. */\nexport interface CheckboxParts {\n /** Wrapping label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native checkbox input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual checkbox box. */\n box?: HTMLAttributes<HTMLSpanElement>;\n /** Visual checked indicator. */\n indicator?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst checkboxPartsMatchManifest: ExactPartKeys<CheckboxParts, PartsOf<'CheckboxField'>> = true;\nvoid checkboxPartsMatchManifest;\n\ninterface CheckboxFieldComponentProps\n extends WrappedFieldProps<boolean>,\n FieldAccessibilityProps {\n label?: string;\n className?: string;\n pt?: CheckboxParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** A checkbox field bound to a boolean property on an Arc command. */\nexport const CheckboxField = asCommandFormField<CheckboxFieldComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'] ?? props.label,\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n return (\n <>\n <label\n {...props.pt?.root}\n className={['cratis-choice-field', props.pt?.root?.className, props.className]\n .filter(Boolean)\n .join(' ')}\n onBlur={props.onBlur}\n data-cratis-part='root'\n data-cratis-component='CheckboxField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={props.value || undefined}\n >\n <input\n {...props.pt?.input}\n id={accessibility.controlId}\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n type='checkbox'\n checked={props.value}\n onChange={(event) => props.onChange(event.currentTarget.checked)}\n aria-invalid={props.invalid || undefined}\n className={['cratis-choice-field__native', props.pt?.input?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='input'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={props.value || undefined}\n />\n <span\n {...props.pt?.box}\n className={['cratis-checkbox__box', props.pt?.box?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='box'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={props.value || undefined}\n aria-hidden='true'\n >\n <span\n {...props.pt?.indicator}\n className={[\n 'cratis-checkbox__indicator',\n props.pt?.indicator?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='indicator'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={props.value || undefined}\n >\n ✓\n </span>\n </span>\n {props.label && (\n <span className='cratis-choice-field__label'>{props.label}</span>\n )}\n </label>\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: false },\n);\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;MAsCa,aAAa,GAAG,kBAAkB,CAC3C,CAAC,KAAK,KAAI;AACN,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EAAE;AAC/C,QAAA,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;AACvB,QAAA,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,YAAY,CAAC,IAAI,KAAK,CAAC,KAAK;QACzD,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,kBAAkB,CAAC;AACzD,KAAA,CAAC;IACF,QACIA,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACJD,IAAA,CAAA,OAAA,EAAA,EAAA,GACQ,KAAK,CAAC,EAAE,EAAE,IAAI,EAClB,SAAS,EAAE,CAAC,qBAAqB,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS;qBACxE,MAAM,CAAC,OAAO;qBACd,IAAI,CAAC,GAAG,CAAC,EACd,MAAM,EAAE,KAAK,CAAC,MAAM,EAAA,kBAAA,EACH,MAAM,2BACD,eAAe,EAAA,eAAA,EACtB,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAA,cAAA,EACvC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,KAAK,IAAI,SAAS,EAA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AS,EAAE;gCACP,4BAA4B;AAC5B,gCAAA,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS;AACjC;iCACI,MAAM,CAAC,OAAO;iCACd,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,WAAW,mBACb,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAA,cAAA,EACvC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,KAAK,IAAI,SAAS,EAAA,QAAA,EAAA,QAAA,EAAA,CAGpC,EAAA,CACJ,EACN,KAAK,CAAC,KAAK,KACRA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAE,KAAK,CAAC,KAAK,EAAA,CAAQ,CACpE,CAAA,EAAA,CACG,EACC,aAAa,CAAC,WAAW,CAAA,EAAA,CAC3B;AAEX,CAAC,EACD,EAAE,YAAY,EAAE,KAAK,EAAE;;"}
1
+ {"version":3,"file":"CheckboxField.js","sources":["../../../../CommandForm/fields/CheckboxField.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 type {\n FocusEventHandler,\n HTMLAttributes,\n InputHTMLAttributes,\n ReactNode,\n} from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport { unstable_useSlot } from '../../renderer/RendererContext';\nimport { renderSlot } from '../../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../../renderer/slots';\nimport type { CheckboxProps } from '../../Common/Checkbox';\nimport { joinClassNames, userChange, type ChoiceState } from './fieldSlotHelpers';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link CheckboxField}. */\nexport interface CheckboxParts {\n /** Wrapping label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native checkbox input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual checkbox box. */\n box?: HTMLAttributes<HTMLSpanElement>;\n /** Visual checked indicator. */\n indicator?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst checkboxPartsMatchManifest: ExactPartKeys<CheckboxParts, PartsOf<'CheckboxField'>> = true;\nvoid checkboxPartsMatchManifest;\n\ninterface CheckboxFieldComponentProps\n extends WrappedFieldProps<boolean>,\n FieldAccessibilityProps {\n label?: string;\n className?: string;\n pt?: CheckboxParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Props shared by the `CheckboxField` part components. */\ninterface CheckboxPartProps<T> {\n parts?: T;\n state: ChoiceState;\n}\n\n/** Native input of the `CheckboxField`. */\nconst CheckboxInput = ({\n parts,\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n checked,\n onChange,\n state,\n}: CheckboxPartProps<InputHTMLAttributes<HTMLInputElement>> &\n Pick<CheckboxProps, 'checked' | 'onChange' | 'id' | 'aria-label' | 'aria-describedby'>) => (\n <input\n {...parts}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n type='checkbox'\n checked={checked}\n onChange={(event) => onChange?.(event.currentTarget.checked, userChange(event))}\n aria-invalid={state.invalid || undefined}\n className={joinClassNames('cratis-choice-field__native', parts?.className)}\n data-cratis-part='input'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n />\n);\n\n/** Outer decorative box of the `CheckboxField`. */\nconst CheckboxBox = ({\n parts,\n state,\n children,\n}: CheckboxPartProps<HTMLAttributes<HTMLSpanElement>> & { children: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-checkbox__box', parts?.className)}\n data-cratis-part='box'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n aria-hidden='true'\n >\n {children}\n </span>\n);\n\n/** Inner decorative indicator of the `CheckboxField`. */\nconst CheckboxIndicator = ({\n parts,\n state,\n children,\n}: CheckboxPartProps<HTMLAttributes<HTMLSpanElement>> & { children?: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-checkbox__indicator', parts?.className)}\n data-cratis-part='indicator'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n {children}\n </span>\n);\n\n/** Core `CheckboxField` markup, used when no adapter supplies `common.checkbox`. */\nconst CheckboxFieldCore = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n label,\n checked,\n onChange,\n onBlur,\n invalid,\n className,\n pt,\n}: CheckboxProps) => {\n const state: ChoiceState = { disabled: pt?.input?.disabled, invalid, selected: checked };\n return (\n <label\n {...pt?.root}\n className={joinClassNames('cratis-choice-field', pt?.root?.className, className)}\n onBlur={onBlur as FocusEventHandler<Element> | undefined}\n data-cratis-part='root'\n data-cratis-component='CheckboxField'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n <CheckboxInput\n parts={pt?.input}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n checked={checked}\n onChange={onChange}\n state={state}\n />\n <CheckboxBox parts={pt?.box} state={state}>\n <CheckboxIndicator parts={pt?.indicator} state={state}>\n ✓\n </CheckboxIndicator>\n </CheckboxBox>\n {label && <span className='cratis-choice-field__label'>{label}</span>}\n </label>\n );\n};\n\n/** Frozen Core declaration resolved when no active renderer supplies `common.checkbox`. */\nconst coreCheckboxDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: CheckboxFieldCore,\n}) satisfies unstable_SlotDeclaration<'common.checkbox'>;\n\n\n/** A checkbox field bound to a boolean property on an Arc command. */\nexport const CheckboxField = asCommandFormField<CheckboxFieldComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'] ?? props.label,\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n const declaration = unstable_useSlot('common.checkbox', coreCheckboxDeclaration);\n return (\n <>\n {renderSlot(declaration, {\n id: accessibility.controlId,\n 'aria-label': accessibility.ariaLabel,\n 'aria-describedby': accessibility.ariaDescribedBy,\n label: props.label,\n checked: props.value,\n onChange: (checked) => props.onChange(checked),\n onBlur: props.onBlur,\n invalid: props.invalid,\n 'aria-invalid': props.invalid || undefined,\n className: props.className,\n pt: props.pt,\n })}\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: false },\n);\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;AAsDA,MAAM,aAAa,GAAG,CAAC,EACnB,KAAK,EACL,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,OAAO,EACP,QAAQ,EACR,KAAK,GAEiF,MACtFA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,KAAK,EACT,EAAE,EAAE,EAAE,EAAA,YAAA,EACM,SAAS,EAAA,kBAAA,EACH,eAAe,EACjC,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAA,cAAA,EACjE,KAAK,CAAC,OAAO,IAAI,SAAS,EACxC,SAAS,EAAE,cAAc,CAAC,6BAA6B,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EACzD,OAAO,EAAA,eAAA,EACT,KAAK,CAAC,QAAQ,IAAI,SAAS,EAAA,cAAA,EAC5B,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,QAAQ,IAAI,SAAS,EAAA,CAC5C,CACL;AAGD,MAAM,WAAW,GAAG,CAAC,EACjB,KAAK,EACL,KAAK,EACL,QAAQ,G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,CAAC,gBAAgB,CAAC,CAAC;CAChD;AAED,UAAU,uBACN,SAAQ,iBAAiB,CAAC,MAAM,CAAC,EAC7B,uBAAuB;IAC3B,IAAI,CAAC,EACC,MAAM,GACN,OAAO,GACP,UAAU,GACV,OAAO,GACP,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,KAAK,GACL,KAAK,GACL,QAAQ,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,6EAA6E;AAC7E,eAAO,MAAM,cAAc,sNAuC1B,CAAC"}
1
+ {"version":3,"file":"InputTextField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/InputTextField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAMxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAE9B,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC3B,4BAA4B;IAC5B,IAAI,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CAChD;AAED,UAAU,uBACN,SAAQ,iBAAiB,CAAC,MAAM,CAAC,EAC7B,uBAAuB;IAC3B,IAAI,CAAC,EACC,MAAM,GACN,OAAO,GACP,UAAU,GACV,OAAO,GACP,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,KAAK,GACL,KAAK,GACL,QAAQ,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA4DD,6EAA6E;AAC7E,eAAO,MAAM,cAAc,sNAiC1B,CAAC"}
@@ -1,21 +1,42 @@
1
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { asCommandFormField } from '@cratis/arc.react/commands';
3
+ import { unstable_useSlot } from '../../renderer/RendererContext.js';
4
+ import { renderSlot } from '../../renderer/renderSlot.js';
5
+ import { joinClassNames, userChange } from './fieldSlotHelpers.js';
3
6
  import { useFieldAccessibility } from './fieldAccessibility.js';
4
7
 
8
+ const slotTextInputTypes = ['text', 'email', 'password', 'search', 'tel', 'url'];
9
+ const isSlotTextInputType = (type) => type === undefined || slotTextInputTypes.includes(type);
10
+ const InputTextFieldCore = ({ id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, value, onChange, onBlur, placeholder, type = 'text', invalid, className, pt, }) => (jsx("input", { ...pt?.root, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, type: type, value: value, onChange: (event) => onChange?.(event.currentTarget.value, userChange(event)), onBlur: onBlur, placeholder: placeholder, "aria-invalid": invalid || undefined, "data-disabled": pt?.root?.disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": pt?.root?.readOnly || undefined, "data-cratis-component": 'InputTextField', "data-cratis-part": 'input', className: joinClassNames('cratis-field-input', 'cratis:w-full', pt?.root?.className, className) }));
11
+ const coreTextInputDeclaration = Object.freeze({
12
+ mode: 'presentation',
13
+ fidelity: 'native',
14
+ render: InputTextFieldCore,
15
+ });
16
+ const SlotTextInput = (props) => renderSlot(unstable_useSlot('common.textInput', coreTextInputDeclaration), props);
5
17
  const InputTextField = asCommandFormField((props) => {
6
18
  const accessibility = useFieldAccessibility(props, {
7
19
  id: props.pt?.root?.id,
8
20
  ariaLabel: props.pt?.root?.['aria-label'],
9
21
  ariaDescribedBy: props.pt?.root?.['aria-describedby'],
10
22
  });
11
- return (jsxs(Fragment, { children: [jsx("input", { ...props.pt?.root, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, type: props.type ?? 'text', value: props.value, onChange: (event) => props.onChange(event.currentTarget.value), onBlur: props.onBlur, placeholder: props.placeholder, "aria-invalid": props.invalid || undefined, "data-disabled": props.pt?.root?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.root?.readOnly || undefined, "data-cratis-component": 'InputTextField', "data-cratis-part": 'input', className: [
12
- 'cratis-field-input',
13
- 'cratis:w-full',
14
- props.pt?.root?.className,
15
- props.className,
16
- ]
17
- .filter(Boolean)
18
- .join(' ') }), accessibility.hiddenError] }));
23
+ const slotProps = {
24
+ id: accessibility.controlId,
25
+ 'aria-label': accessibility.ariaLabel,
26
+ 'aria-describedby': accessibility.ariaDescribedBy,
27
+ value: props.value,
28
+ onChange: (value) => props.onChange(value),
29
+ onBlur: props.onBlur,
30
+ placeholder: props.placeholder,
31
+ invalid: props.invalid,
32
+ 'aria-invalid': props.invalid || undefined,
33
+ className: props.className,
34
+ pt: props.pt,
35
+ };
36
+ const control = isSlotTextInputType(props.type)
37
+ ? jsx(SlotTextInput, { ...slotProps, type: props.type })
38
+ : jsx(InputTextFieldCore, { ...slotProps, type: props.type });
39
+ return (jsxs(Fragment, { children: [control, accessibility.hiddenError] }));
19
40
  }, { defaultValue: '' });
20
41
 
21
42
  export { InputTextField };
@@ -1 +1 @@
1
- {"version":3,"file":"InputTextField.js","sources":["../../../../CommandForm/fields/InputTextField.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 type { InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\n\n/** Stable part attributes for {@link InputTextField}. */\nexport interface InputTextParts {\n /** Native input element. */\n root?: InputHTMLAttributes<HTMLInputElement>;\n}\n\ninterface InputTextComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'color'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'url'\n | 'tel'\n | 'search';\n placeholder?: string;\n className?: string;\n pt?: InputTextParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** A single-line text field bound to a string property on an Arc command. */\nexport const InputTextField = asCommandFormField<InputTextComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.root?.id,\n ariaLabel: props.pt?.root?.['aria-label'],\n ariaDescribedBy: props.pt?.root?.['aria-describedby'],\n });\n return (\n <>\n <input\n {...props.pt?.root}\n id={accessibility.controlId}\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n type={props.type ?? 'text'}\n value={props.value}\n onChange={(event) => props.onChange(event.currentTarget.value)}\n onBlur={props.onBlur}\n placeholder={props.placeholder}\n aria-invalid={props.invalid || undefined}\n data-disabled={props.pt?.root?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-readonly={props.pt?.root?.readOnly || undefined}\n data-cratis-component='InputTextField'\n data-cratis-part='input'\n className={[\n 'cratis-field-input',\n 'cratis:w-full',\n props.pt?.root?.className,\n props.className,\n ]\n .filter(Boolean)\n .join(' ')}\n />\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;MAsCa,cAAc,GAAG,kBAAkB,CAC5C,CAAC,KAAK,KAAI;AACN,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EAAE;AAC/C,QAAA,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;QACtB,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,GAAG,YAAY,CAAC;QACzC,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,GAAG,kBAAkB,CAAC;AACxD,KAAA,CAAC;IACF,QACIA,4BACJC,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,KAAK,CAAC,EAAE,EAAE,IAAI,EAClB,EAAE,EAAE,aAAa,CAAC,SAAS,EAAA,YAAA,EACf,aAAa,CAAC,SAAS,sBACjB,aAAa,CAAC,eAAe,EAC/C,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM,EAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,EAC9D,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,WAAW,EAAE,KAAK,CAAC,WAAW,EAAA,cAAA,EAChB,KAAK,CAAC,OAAO,IAAI,SAAS,mBACzB,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,kBACtC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,EAAA,uBAAA,EAC9B,gBAAgB,EAAA,kBAAA,EACrB,OAAO,EACxB,SAAS,EAAE;oBACP,oBAAoB;oBACpB,eAAe;AACf,oBAAA,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS;AACzB,oBAAA,KAAK,CAAC,SAAS;AAClB;qBACI,MAAM,CAAC,OAAO;qBACd,IAAI,CAAC,GAAG,CAAC,EAAA,CAChB,EACO,aAAa,CAAC,WAAW,CAAA,EAAA,CAC3B;AAEX,CAAC,EACD,EAAE,YAAY,EAAE,EAAE,EAAE;;"}
1
+ {"version":3,"file":"InputTextField.js","sources":["../../../../CommandForm/fields/InputTextField.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 type { InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport { unstable_useSlot } from '../../renderer/RendererContext';\nimport { renderSlot } from '../../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../../renderer/slots';\nimport type { TextInputProps, TextInputType } from '../../Common/TextInput';\nimport { joinClassNames, userChange } from './fieldSlotHelpers';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\n\n/** Stable part attributes for {@link InputTextField}. */\nexport interface InputTextParts {\n /** Native input element. */\n root?: InputHTMLAttributes<HTMLInputElement>;\n}\n\ninterface InputTextComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n type?:\n | 'text'\n | 'email'\n | 'password'\n | 'color'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'url'\n | 'tel'\n | 'search';\n placeholder?: string;\n className?: string;\n pt?: InputTextParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Input types of {@link InputTextField} that `common.textInput` can present. */\nconst slotTextInputTypes: ReadonlyArray<string> = ['text', 'email', 'password', 'search', 'tel', 'url'];\n\n/** Whether an input type is covered by the `common.textInput` slot contract. */\nconst isSlotTextInputType = (type: string | undefined): type is TextInputType | undefined =>\n type === undefined || slotTextInputTypes.includes(type);\n\n/** Slot props widened to every native type so non-slot types keep the built-in markup. */\ntype TextInputCoreProps = Omit<TextInputProps, 'type'> & {\n type?: InputHTMLAttributes<HTMLInputElement>['type'];\n};\n\n/** Core InputTextField markup, used when no adapter supplies `common.textInput`. */\nconst InputTextFieldCore = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n value,\n onChange,\n onBlur,\n placeholder,\n type = 'text',\n invalid,\n className,\n pt,\n}: TextInputCoreProps) => (\n <input\n {...pt?.root}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n type={type}\n value={value}\n onChange={(event) => onChange?.(event.currentTarget.value, userChange(event))}\n onBlur={onBlur}\n placeholder={placeholder}\n aria-invalid={invalid || undefined}\n data-disabled={pt?.root?.disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={pt?.root?.readOnly || undefined}\n data-cratis-component='InputTextField'\n data-cratis-part='input'\n className={joinClassNames('cratis-field-input', 'cratis:w-full', pt?.root?.className, className)}\n />\n);\n\n/** Frozen Core declaration resolved when no active renderer supplies `common.textInput`. */\nconst coreTextInputDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: InputTextFieldCore,\n}) satisfies unstable_SlotDeclaration<'common.textInput'>;\n\n\n/** Resolves `common.textInput` and renders it; only mounted for types the slot covers. */\nconst SlotTextInput = (props: TextInputProps) =>\n renderSlot(unstable_useSlot('common.textInput', coreTextInputDeclaration), props);\n\n/** A single-line text field bound to a string property on an Arc command. */\nexport const InputTextField = asCommandFormField<InputTextComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.root?.id,\n ariaLabel: props.pt?.root?.['aria-label'],\n ariaDescribedBy: props.pt?.root?.['aria-describedby'],\n });\n const slotProps = {\n id: accessibility.controlId,\n 'aria-label': accessibility.ariaLabel,\n 'aria-describedby': accessibility.ariaDescribedBy,\n value: props.value,\n onChange: (value: string) => props.onChange(value),\n onBlur: props.onBlur,\n placeholder: props.placeholder,\n invalid: props.invalid,\n 'aria-invalid': props.invalid || undefined,\n className: props.className,\n pt: props.pt,\n };\n // Types the slot contract does not cover (color, date, ...) keep the built-in markup and\n // never resolve the slot, so a strict renderer without textInput cannot reject them.\n const control = isSlotTextInputType(props.type)\n ? <SlotTextInput {...slotProps} type={props.type} />\n : <InputTextFieldCore {...slotProps} type={props.type} />;\n return (\n <>\n {control}\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;AA2CA,MAAM,kBAAkB,GAA0B,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC;AAGvG,MAAM,mBAAmB,GAAG,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E;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/RadioButtonField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAI9B,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACvB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACxC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,wBAAwB;IACxB,GAAG,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACtC,iCAAiC;IACjC,SAAS,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC/C;AAKD,UAAU,8BACN,SAAQ,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,EACtC,uBAAuB;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,6NAyE5B,CAAC"}
1
+ {"version":3,"file":"RadioButtonField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/RadioButtonField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAER,cAAc,EACd,mBAAmB,EAEtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAMxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAI9B,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACvB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACxC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,wBAAwB;IACxB,GAAG,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACtC,iCAAiC;IACjC,SAAS,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC/C;AAKD,UAAU,8BACN,SAAQ,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,EACtC,uBAAuB;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA+HD,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,6NA+B5B,CAAC"}
@@ -1,7 +1,22 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { asCommandFormField } from '@cratis/arc.react/commands';
3
+ import { unstable_useSlot } from '../../renderer/RendererContext.js';
4
+ import { renderSlot } from '../../renderer/renderSlot.js';
5
+ import { joinClassNames, userChange } from './fieldSlotHelpers.js';
3
6
  import { useFieldAccessibility } from './fieldAccessibility.js';
4
7
 
8
+ const RadioButtonInput = ({ parts, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, name, checked, onChange, state, }) => (jsx("input", { ...parts, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, type: 'radio', name: name, checked: checked, onChange: (event) => event.currentTarget.checked && onChange?.(true, userChange(event)), "aria-invalid": state.invalid || undefined, className: joinClassNames('cratis-choice-field__native', parts?.className), "data-cratis-part": 'input', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined }));
9
+ const RadioButtonBox = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-radio__box', parts?.className), "data-cratis-part": 'box', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, "aria-hidden": 'true', children: children }));
10
+ const RadioButtonIndicator = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-radio__indicator', parts?.className), "data-cratis-part": 'indicator', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: children }));
11
+ const RadioButtonFieldCore = ({ id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, name, label, checked, onChange, onBlur, invalid, className, pt, }) => {
12
+ const state = { disabled: pt?.input?.disabled, invalid, selected: checked };
13
+ return (jsxs("label", { ...pt?.root, className: joinClassNames('cratis-choice-field', pt?.root?.className, className), onBlur: onBlur, "data-cratis-part": 'root', "data-cratis-component": 'RadioButtonField', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: [jsx(RadioButtonInput, { parts: pt?.input, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, name: name, checked: checked, onChange: onChange, state: state }), jsx(RadioButtonBox, { parts: pt?.box, state: state, children: jsx(RadioButtonIndicator, { parts: pt?.indicator, state: state }) }), label && jsx("span", { className: 'cratis-choice-field__label', children: label })] }));
14
+ };
15
+ const coreRadioButtonDeclaration = Object.freeze({
16
+ mode: 'presentation',
17
+ fidelity: 'native',
18
+ render: RadioButtonFieldCore,
19
+ });
5
20
  const RadioButtonField = asCommandFormField((props) => {
6
21
  const accessibility = useFieldAccessibility(props, {
7
22
  id: props.pt?.input?.id,
@@ -9,18 +24,22 @@ const RadioButtonField = asCommandFormField((props) => {
9
24
  ariaDescribedBy: props.pt?.input?.['aria-describedby'],
10
25
  });
11
26
  const selected = props.value === props.buttonValue;
12
- return (jsxs(Fragment, { children: [jsxs("label", { ...props.pt?.root, className: ['cratis-choice-field', props.pt?.root?.className, props.className]
13
- .filter(Boolean)
14
- .join(' '), onBlur: props.onBlur, "data-cratis-part": 'root', "data-cratis-component": 'RadioButtonField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined, children: [jsx("input", { ...props.pt?.input, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, type: 'radio', name: props.name, checked: selected, onChange: (event) => {
15
- if (event.currentTarget.checked)
16
- props.onChange(props.buttonValue);
17
- }, "aria-invalid": props.invalid || undefined, className: ['cratis-choice-field__native', props.pt?.input?.className]
18
- .filter(Boolean)
19
- .join(' '), "data-cratis-part": 'input', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined }), jsx("span", { ...props.pt?.box, className: ['cratis-radio__box', props.pt?.box?.className]
20
- .filter(Boolean)
21
- .join(' '), "data-cratis-part": 'box', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined, "aria-hidden": 'true', children: jsx("span", { ...props.pt?.indicator, className: ['cratis-radio__indicator', props.pt?.indicator?.className]
22
- .filter(Boolean)
23
- .join(' '), "data-cratis-part": 'indicator', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined }) }), props.label && (jsx("span", { className: 'cratis-choice-field__label', children: props.label }))] }), accessibility.hiddenError] }));
27
+ const declaration = unstable_useSlot('common.radio', coreRadioButtonDeclaration);
28
+ return (jsxs(Fragment, { children: [renderSlot(declaration, {
29
+ id: accessibility.controlId,
30
+ 'aria-label': accessibility.ariaLabel,
31
+ 'aria-describedby': accessibility.ariaDescribedBy,
32
+ name: props.name,
33
+ value: props.buttonValue,
34
+ label: props.label,
35
+ checked: selected,
36
+ onChange: (checked) => checked && props.onChange(props.buttonValue),
37
+ onBlur: props.onBlur,
38
+ invalid: props.invalid,
39
+ 'aria-invalid': props.invalid || undefined,
40
+ className: props.className,
41
+ pt: props.pt,
42
+ }), accessibility.hiddenError] }));
24
43
  }, { defaultValue: '' });
25
44
 
26
45
  export { RadioButtonField };
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonField.js","sources":["../../../../CommandForm/fields/RadioButtonField.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 type { HTMLAttributes, InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link RadioButtonField}. */\nexport interface RadioParts {\n /** Wrapping option label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native radio input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual radio box. */\n box?: HTMLAttributes<HTMLSpanElement>;\n /** Visual selected indicator. */\n indicator?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst radioPartsMatchManifest: ExactPartKeys<RadioParts, PartsOf<'RadioButtonField'>> = true;\nvoid radioPartsMatchManifest;\n\ninterface RadioButtonFieldComponentProps\n extends WrappedFieldProps<string | number>,\n FieldAccessibilityProps {\n label?: string;\n buttonValue: string | number;\n /** Native group name shared by every option bound to the same property. */\n name: string;\n className?: string;\n pt?: RadioParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** A single radio option bound to a string or number property on an Arc command. */\nexport const RadioButtonField = asCommandFormField<RadioButtonFieldComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'] ?? props.label,\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n const selected = props.value === props.buttonValue;\n return (\n <>\n <label\n {...props.pt?.root}\n className={['cratis-choice-field', props.pt?.root?.className, props.className]\n .filter(Boolean)\n .join(' ')}\n onBlur={props.onBlur}\n data-cratis-part='root'\n data-cratis-component='RadioButtonField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={selected || undefined}\n >\n <input\n {...props.pt?.input}\n id={accessibility.controlId}\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n type='radio'\n name={props.name}\n checked={selected}\n onChange={(event) => {\n if (event.currentTarget.checked) props.onChange(props.buttonValue);\n }}\n aria-invalid={props.invalid || undefined}\n className={['cratis-choice-field__native', props.pt?.input?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='input'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={selected || undefined}\n />\n <span\n {...props.pt?.box}\n className={['cratis-radio__box', props.pt?.box?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='box'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={selected || undefined}\n aria-hidden='true'\n >\n <span\n {...props.pt?.indicator}\n className={['cratis-radio__indicator', props.pt?.indicator?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='indicator'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-selected={selected || undefined}\n />\n </span>\n {props.label && (\n <span className='cratis-choice-field__label'>{props.label}</span>\n )}\n </label>\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;MAyCa,gBAAgB,GAAG,kBAAkB,CAC9C,CAAC,KAA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AS,EAAA,eAAA,EACzB,QAAQ,IAAI,SAAS,GACtC,EAAA,CACC,EACN,KAAK,CAAC,KAAK,KACRA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAE,KAAK,CAAC,KAAK,EAAA,CAAQ,CACpE,CAAA,EAAA,CACG,EACC,aAAa,CAAC,WAAW,CAAA,EAAA,CAC3B;AAEX,CAAC,EACD,EAAE,YAAY,EAAE,EAAE,EAAE;;"}
1
+ {"version":3,"file":"RadioButtonField.js","sources":["../../../../CommandForm/fields/RadioButtonField.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 type {\n FocusEventHandler,\n HTMLAttributes,\n InputHTMLAttributes,\n ReactNode,\n} from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport { unstable_useSlot } from '../../renderer/RendererContext';\nimport { renderSlot } from '../../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../../renderer/slots';\nimport type { RadioProps } from '../../Common/Radio';\nimport { joinClassNames, userChange, type ChoiceState } from './fieldSlotHelpers';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link RadioButtonField}. */\nexport interface RadioParts {\n /** Wrapping option label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native radio input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual radio box. */\n box?: HTMLAttributes<HTMLSpanElement>;\n /** Visual selected indicator. */\n indicator?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst radioPartsMatchManifest: ExactPartKeys<RadioParts, PartsOf<'RadioButtonField'>> = true;\nvoid radioPartsMatchManifest;\n\ninterface RadioButtonFieldComponentProps\n extends WrappedFieldProps<string | number>,\n FieldAccessibilityProps {\n label?: string;\n buttonValue: string | number;\n /** Native group name shared by every option bound to the same property. */\n name: string;\n className?: string;\n pt?: RadioParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Props shared by the `RadioButtonField` part components. */\ninterface RadioButtonPartProps<T> {\n parts?: T;\n state: ChoiceState;\n}\n\n/** Native input of the `RadioButtonField`. */\nconst RadioButtonInput = ({\n parts,\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n name,\n checked,\n onChange,\n state,\n}: RadioButtonPartProps<InputHTMLAttributes<HTMLInputElement>> &\n Pick<RadioProps, 'checked' | 'onChange' | 'id' | 'aria-label' | 'aria-describedby' | 'name'>) => (\n <input\n {...parts}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n type='radio'\n name={name}\n checked={checked}\n onChange={(event) => event.currentTarget.checked && onChange?.(true, userChange(event))}\n aria-invalid={state.invalid || undefined}\n className={joinClassNames('cratis-choice-field__native', parts?.className)}\n data-cratis-part='input'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n />\n);\n\n/** Outer decorative box of the `RadioButtonField`. */\nconst RadioButtonBox = ({\n parts,\n state,\n children,\n}: RadioButtonPartProps<HTMLAttributes<HTMLSpanElement>> & { children: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-radio__box', parts?.className)}\n data-cratis-part='box'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n aria-hidden='true'\n >\n {children}\n </span>\n);\n\n/** Inner decorative indicator of the `RadioButtonField`. */\nconst RadioButtonIndicator = ({\n parts,\n state,\n children,\n}: RadioButtonPartProps<HTMLAttributes<HTMLSpanElement>> & { children?: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-radio__indicator', parts?.className)}\n data-cratis-part='indicator'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n {children}\n </span>\n);\n\n/** Core `RadioButtonField` markup, used when no adapter supplies `common.radio`. */\nconst RadioButtonFieldCore = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n name,\n label,\n checked,\n onChange,\n onBlur,\n invalid,\n className,\n pt,\n}: RadioProps) => {\n const state: ChoiceState = { disabled: pt?.input?.disabled, invalid, selected: checked };\n return (\n <label\n {...pt?.root}\n className={joinClassNames('cratis-choice-field', pt?.root?.className, className)}\n onBlur={onBlur as FocusEventHandler<Element> | undefined}\n data-cratis-part='root'\n data-cratis-component='RadioButtonField'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n <RadioButtonInput\n parts={pt?.input}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n name={name}\n checked={checked}\n onChange={onChange}\n state={state}\n />\n <RadioButtonBox parts={pt?.box} state={state}>\n <RadioButtonIndicator parts={pt?.indicator} state={state}></RadioButtonIndicator>\n </RadioButtonBox>\n {label && <span className='cratis-choice-field__label'>{label}</span>}\n </label>\n );\n};\n\n/** Frozen Core declaration resolved when no active renderer supplies `common.radio`. */\nconst coreRadioButtonDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: RadioButtonFieldCore,\n}) satisfies unstable_SlotDeclaration<'common.radio'>;\n\n\n/** A single radio option bound to a string or number property on an Arc command. */\nexport const RadioButtonField = asCommandFormField<RadioButtonFieldComponentProps>(\n (props) => {\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'] ?? props.label,\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n const selected = props.value === props.buttonValue;\n const declaration = unstable_useSlot('common.radio', coreRadioButtonDeclaration);\n return (\n <>\n {renderSlot(declaration, {\n id: accessibility.controlId,\n 'aria-label': accessibility.ariaLabel,\n 'aria-describedby': accessibility.ariaDescribedBy,\n name: props.name,\n value: props.buttonValue,\n label: props.label,\n checked: selected,\n onChange: (checked) => checked && props.onChange(props.buttonValue),\n onBlur: props.onBlur,\n invalid: props.invalid,\n 'aria-invalid': props.invalid || undefined,\n className: props.className,\n pt: props.pt,\n })}\n {accessibility.hiddenError}\n </>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;AAyDA,MAAM,gBAAgB,GAAG,CAAC,EACtB,KAAK,EACL,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,KAAK,GAEuF,MAC5FA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,KAAK,EACT,EAAE,EAAE,EAAE,gBACM,SAAS,EAAA,kBAAA,EACH,eAAe,EACjC,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,aAAa,CAAC,OAAO,IAAI,QAAQ,GAAG,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAA,cAAA,EACzE,KAAK,CAAC,OAAO,IAAI,SAAS,EACxC,SAAS,EAAE,cAAc,CAAC,6BAA6B,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EACzD,OAAO,EAAA,eAAA,EACT,KAAK,CAAC,QAAQ,IAAI,SAAS,EAAA,cAAA,EAC5B,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,QAAQ,IAAI,SAAS,EAAA,CAC5C,CACL;AAGD,MAAM,cAAc,GAAG,CAAC,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACsE,MAC9EA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,KAAK,EACT,SAAS,EAAE,cAAc,CAAC,mBAAmB,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC/C,KAAK,EAAA,e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eAAe;IAC5B,mCAAmC;IACnC,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,wBAAwB;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC1C,0BAA0B;IAC1B,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,wBAAwB;IACxB,GAAG,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACtC,iCAAiC;IACjC,SAAS,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC/C;AAKD,UAAU,6BACN,SAAQ,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,EACtC,uBAAuB;IAC3B,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;IACnC,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAiHD,oFAAoF;AACpF,eAAO,MAAM,eAAe,4NA0D3B,CAAC"}
@@ -1,48 +1,50 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useId } from 'react';
2
+ import { useId, Fragment } from 'react';
3
3
  import { asCommandFormField } from '@cratis/arc.react/commands';
4
+ import { unstable_useSlot } from '../../renderer/RendererContext.js';
5
+ import { renderSlot } from '../../renderer/renderSlot.js';
6
+ import { joinClassNames, userChange } from './fieldSlotHelpers.js';
4
7
  import { useFieldAccessibility } from './fieldAccessibility.js';
5
8
 
9
+ const RadioOptionInput = ({ parts, name, checked, onChange, state, }) => (jsx("input", { ...parts, type: 'radio', name: name, checked: checked, onChange: (event) => event.currentTarget.checked && onChange?.(true, userChange(event)), "aria-invalid": state.invalid || undefined, className: joinClassNames('cratis-choice-field__native', parts?.className), "data-cratis-part": 'input', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined }));
10
+ const RadioOptionBox = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-radio__box', parts?.className), "data-cratis-part": 'box', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, "aria-hidden": 'true', children: children }));
11
+ const RadioOptionIndicator = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-radio__indicator', parts?.className), "data-cratis-part": 'indicator', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: children }));
12
+ const RadioOptionCore = ({ name, label, checked, onChange, onBlur, invalid, pt, }) => {
13
+ const state = { disabled: pt?.input?.disabled, invalid, selected: checked };
14
+ return (jsxs("label", { ...pt?.root, className: joinClassNames('cratis-choice-field', pt?.root?.className), onBlur: onBlur, "data-cratis-part": 'option', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: [jsx(RadioOptionInput, { parts: pt?.input, name: name, checked: checked, onChange: onChange, state: state }), jsx(RadioOptionBox, { parts: pt?.box, state: state, children: jsx(RadioOptionIndicator, { parts: pt?.indicator, state: state }) }), jsx("span", { className: 'cratis-choice-field__label', children: label })] }));
15
+ };
16
+ const coreRadioOptionDeclaration = Object.freeze({
17
+ mode: 'presentation',
18
+ fidelity: 'native',
19
+ render: RadioOptionCore,
20
+ });
6
21
  const RadioGroupField = asCommandFormField((props) => {
7
22
  const generatedName = useId();
8
23
  const name = props.name ?? generatedName;
24
+ const declaration = unstable_useSlot('common.radio', coreRadioOptionDeclaration);
9
25
  const accessibility = useFieldAccessibility(props, {
10
26
  id: props.pt?.root?.id,
11
27
  ariaLabel: props.pt?.root?.['aria-label'],
12
28
  ariaDescribedBy: props.pt?.root?.['aria-describedby'],
13
29
  });
14
- return (jsxs("div", { ...props.pt?.root, id: accessibility.controlId, role: 'radiogroup', "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, "aria-invalid": props.invalid || undefined, className: [
15
- 'cratis-radio-group',
16
- `cratis-radio-group--${props.layout ?? 'vertical'}`,
17
- props.pt?.root?.className,
18
- props.className,
19
- ]
20
- .filter(Boolean)
21
- .join(' '), "data-cratis-part": 'root', "data-cratis-component": 'RadioGroupField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, children: [props.options.map((option) => {
30
+ return (jsxs("div", { ...props.pt?.root, id: accessibility.controlId, role: 'radiogroup', "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, "aria-invalid": props.invalid || undefined, className: joinClassNames('cratis-radio-group', `cratis-radio-group--${props.layout ?? 'vertical'}`, props.pt?.root?.className, props.className), "data-cratis-part": 'root', "data-cratis-component": 'RadioGroupField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, children: [props.options.map((option) => {
22
31
  const value = option[props.optionValue];
23
- const label = String(option[props.optionLabel] ?? value);
24
- const selected = props.value === value;
25
- return (jsxs("label", { ...props.pt?.option, className: [
26
- 'cratis-choice-field',
27
- props.pt?.option?.className,
28
- ]
29
- .filter(Boolean)
30
- .join(' '), onBlur: props.onBlur, "data-cratis-part": 'option', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined, children: [jsx("input", { ...props.pt?.input, type: 'radio', name: name, checked: selected, onChange: (event) => {
31
- if (event.currentTarget.checked)
32
- props.onChange(value);
33
- }, "aria-invalid": props.invalid || undefined, className: [
34
- 'cratis-choice-field__native',
35
- props.pt?.input?.className,
36
- ]
37
- .filter(Boolean)
38
- .join(' '), "data-cratis-part": 'input', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined }), jsx("span", { ...props.pt?.box, className: ['cratis-radio__box', props.pt?.box?.className]
39
- .filter(Boolean)
40
- .join(' '), "data-cratis-part": 'box', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined, "aria-hidden": 'true', children: jsx("span", { ...props.pt?.indicator, className: [
41
- 'cratis-radio__indicator',
42
- props.pt?.indicator?.className,
43
- ]
44
- .filter(Boolean)
45
- .join(' '), "data-cratis-part": 'indicator', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-selected": selected || undefined }) }), jsx("span", { className: 'cratis-choice-field__label', children: label })] }, String(value)));
32
+ return (jsx(Fragment, { children: renderSlot(declaration, {
33
+ name,
34
+ value,
35
+ label: String(option[props.optionLabel] ?? value),
36
+ checked: props.value === value,
37
+ onChange: (checked) => checked && props.onChange(value),
38
+ onBlur: props.onBlur,
39
+ invalid: props.invalid,
40
+ 'aria-invalid': props.invalid || undefined,
41
+ pt: {
42
+ root: props.pt?.option,
43
+ input: props.pt?.input,
44
+ box: props.pt?.box,
45
+ indicator: props.pt?.indicator,
46
+ },
47
+ }) }, String(value)));
46
48
  }), accessibility.hiddenError] }));
47
49
  }, { defaultValue: '' });
48
50