@cratis/components 4.42.3 → 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.
- package/compat-manifest.json +67 -13
- package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js +29 -12
- package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.js +30 -9
- package/dist/esm/CommandForm/fields/InputTextField.js.map +1 -1
- package/dist/esm/CommandForm/fields/RadioButtonField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/RadioButtonField.js +31 -12
- package/dist/esm/CommandForm/fields/RadioButtonField.js.map +1 -1
- package/dist/esm/CommandForm/fields/RadioGroupField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/RadioGroupField.js +34 -32
- package/dist/esm/CommandForm/fields/RadioGroupField.js.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.js +25 -9
- package/dist/esm/CommandForm/fields/TextAreaField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ToggleSwitchField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ToggleSwitchField.js +29 -9
- package/dist/esm/CommandForm/fields/ToggleSwitchField.js.map +1 -1
- package/dist/esm/CommandForm/fields/fieldSlotHelpers.d.ts +13 -0
- package/dist/esm/CommandForm/fields/fieldSlotHelpers.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/fieldSlotHelpers.js +8 -0
- package/dist/esm/CommandForm/fields/fieldSlotHelpers.js.map +1 -0
- package/dist/esm/Dialogs/DialogFooter.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogFooter.js +28 -9
- package/dist/esm/Dialogs/DialogFooter.js.map +1 -1
- package/dist/esm/Dialogs/DialogFooterButton.d.ts +16 -0
- package/dist/esm/Dialogs/DialogFooterButton.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogFooterButton.js +23 -0
- package/dist/esm/Dialogs/DialogFooterButton.js.map +1 -0
- package/dist/esm/renderer/index.d.ts +1 -1
- package/dist/esm/renderer/index.d.ts.map +1 -1
- package/dist/esm/renderer/index.js +1 -1
- package/dist/esm/renderer/manifest.d.ts.map +1 -1
- package/dist/esm/renderer/manifest.js +23 -3
- package/dist/esm/renderer/manifest.js.map +1 -1
- package/dist/esm/renderer/presentation.d.ts +45 -2
- package/dist/esm/renderer/presentation.d.ts.map +1 -1
- package/dist/esm/renderer/presentation.js +113 -29
- package/dist/esm/renderer/presentation.js.map +1 -1
- package/dist/esm/renderer/resolve.d.ts +4 -1
- package/dist/esm/renderer/resolve.d.ts.map +1 -1
- package/dist/esm/renderer/resolve.js +24 -15
- package/dist/esm/renderer/resolve.js.map +1 -1
- package/dist/esm/styles.Canvas.css +40 -22
- package/dist/esm/styles.CommandDialog.css +42 -23
- package/dist/esm/styles.CommandForm.css +45 -25
- package/dist/esm/styles.CommandStepper.css +42 -23
- package/dist/esm/styles.Common.css +40 -22
- package/dist/esm/styles.ConfigurationEditor.css +12 -5
- package/dist/esm/styles.DataPage.css +57 -32
- package/dist/esm/styles.DataTables.css +57 -32
- package/dist/esm/styles.Dialogs.css +6 -4
- package/dist/esm/styles.Display.css +38 -20
- package/dist/esm/styles.Dropdown.css +45 -25
- package/dist/esm/styles.Filter.css +8 -7
- package/dist/esm/styles.IconPicker.css +6 -2
- package/dist/esm/styles.MarkdownEditor.css +2 -1
- package/dist/esm/styles.Notifications.css +4 -3
- package/dist/esm/styles.ObjectContentEditor.css +40 -22
- package/dist/esm/styles.ObjectNavigationalBar.css +36 -19
- package/dist/esm/styles.PivotViewer.css +12 -9
- package/dist/esm/styles.SchemaEditor.css +68 -38
- package/dist/esm/styles.TimeMachine.css +2 -1
- package/dist/esm/styles.Toolbar.css +51 -32
- package/dist/esm/styles.css +109 -65
- package/dist/esm/styles.renderer.builtin.css +59 -33
- package/dist/esm/theme.css +12 -0
- package/dist/esm/themes/designsystemet.css +103 -0
- package/dist/esm/tokens.css +12 -0
- package/package.json +3 -2
package/compat-manifest.json
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"@cratis/components.conformance",
|
|
11
11
|
"@cratis/components.mui",
|
|
12
12
|
"@cratis/components.primereact",
|
|
13
|
-
"@cratis/components.primereact10"
|
|
13
|
+
"@cratis/components.primereact10",
|
|
14
|
+
"@cratis/components.designsystemet"
|
|
14
15
|
],
|
|
15
16
|
"privateEvidence": [
|
|
16
17
|
{
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"@cratis/components.conformance": ">=4 <5",
|
|
61
62
|
"@cratis/components.mui": ">=4 <5",
|
|
62
63
|
"@cratis/components.primereact": ">=4 <5",
|
|
63
|
-
"@cratis/components.primereact10": ">=4 <5"
|
|
64
|
+
"@cratis/components.primereact10": ">=4 <5",
|
|
65
|
+
"@cratis/components.designsystemet": ">=4 <5"
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
},
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
{
|
|
69
71
|
"name": "@cratis/components",
|
|
70
72
|
"role": "core",
|
|
71
|
-
"version": "4.
|
|
73
|
+
"version": "4.44.0",
|
|
72
74
|
"releaseMajorRange": ">=4 <5",
|
|
73
75
|
"independentRelease": false,
|
|
74
76
|
"private": false,
|
|
@@ -92,7 +94,7 @@
|
|
|
92
94
|
{
|
|
93
95
|
"name": "@cratis/eslint-plugin-components",
|
|
94
96
|
"role": "eslint",
|
|
95
|
-
"version": "4.
|
|
97
|
+
"version": "4.44.0",
|
|
96
98
|
"releaseMajorRange": ">=4 <5",
|
|
97
99
|
"independentRelease": false,
|
|
98
100
|
"private": false,
|
|
@@ -105,7 +107,7 @@
|
|
|
105
107
|
{
|
|
106
108
|
"name": "@cratis/components.migrator",
|
|
107
109
|
"role": "migrator",
|
|
108
|
-
"version": "4.
|
|
110
|
+
"version": "4.44.0",
|
|
109
111
|
"releaseMajorRange": ">=4 <5",
|
|
110
112
|
"independentRelease": false,
|
|
111
113
|
"private": false,
|
|
@@ -116,13 +118,13 @@
|
|
|
116
118
|
{
|
|
117
119
|
"name": "@cratis/components.conformance",
|
|
118
120
|
"role": "conformance",
|
|
119
|
-
"version": "4.
|
|
121
|
+
"version": "4.44.0",
|
|
120
122
|
"releaseMajorRange": ">=4 <5",
|
|
121
123
|
"independentRelease": false,
|
|
122
124
|
"private": false,
|
|
123
125
|
"packageAccess": "public",
|
|
124
126
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.
|
|
127
|
+
"@cratis/components": "4.44.0",
|
|
126
128
|
"react": "^19.0.0",
|
|
127
129
|
"react-dom": "^19.0.0"
|
|
128
130
|
},
|
|
@@ -132,13 +134,13 @@
|
|
|
132
134
|
{
|
|
133
135
|
"name": "@cratis/components.mui",
|
|
134
136
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.
|
|
137
|
+
"version": "4.44.0",
|
|
136
138
|
"releaseMajorRange": ">=4 <5",
|
|
137
139
|
"independentRelease": false,
|
|
138
140
|
"private": false,
|
|
139
141
|
"packageAccess": "public",
|
|
140
142
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.
|
|
143
|
+
"@cratis/components": "4.44.0",
|
|
142
144
|
"@emotion/react": ">=11.5 <12",
|
|
143
145
|
"@emotion/styled": ">=11.11 <12",
|
|
144
146
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +190,13 @@
|
|
|
188
190
|
{
|
|
189
191
|
"name": "@cratis/components.primereact",
|
|
190
192
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.
|
|
193
|
+
"version": "4.44.0",
|
|
192
194
|
"releaseMajorRange": ">=4 <5",
|
|
193
195
|
"independentRelease": false,
|
|
194
196
|
"private": false,
|
|
195
197
|
"packageAccess": "public",
|
|
196
198
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.
|
|
199
|
+
"@cratis/components": "4.44.0",
|
|
198
200
|
"@primereact/core": ">=11 <12",
|
|
199
201
|
"@primereact/ui": ">=11 <12",
|
|
200
202
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +258,13 @@
|
|
|
256
258
|
{
|
|
257
259
|
"name": "@cratis/components.primereact10",
|
|
258
260
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.
|
|
261
|
+
"version": "4.44.0",
|
|
260
262
|
"releaseMajorRange": ">=4 <5",
|
|
261
263
|
"independentRelease": false,
|
|
262
264
|
"private": false,
|
|
263
265
|
"packageAccess": "public",
|
|
264
266
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.
|
|
267
|
+
"@cratis/components": "4.44.0",
|
|
266
268
|
"primereact": ">=10.9.9 <11",
|
|
267
269
|
"react": "^19.0.0",
|
|
268
270
|
"react-dom": "^19.0.0"
|
|
@@ -300,6 +302,58 @@
|
|
|
300
302
|
"tsyringe": "4.10.0"
|
|
301
303
|
}
|
|
302
304
|
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "@cratis/components.designsystemet",
|
|
308
|
+
"role": "renderer-adapter",
|
|
309
|
+
"version": "4.44.0",
|
|
310
|
+
"releaseMajorRange": ">=4 <5",
|
|
311
|
+
"independentRelease": false,
|
|
312
|
+
"private": false,
|
|
313
|
+
"packageAccess": "public",
|
|
314
|
+
"peerDependencies": {
|
|
315
|
+
"@cratis/components": "4.44.0",
|
|
316
|
+
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
317
|
+
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
318
|
+
"react": "^19.0.0",
|
|
319
|
+
"react-dom": "^19.0.0"
|
|
320
|
+
},
|
|
321
|
+
"upstream": {
|
|
322
|
+
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
323
|
+
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
324
|
+
"react": "^19.0.0",
|
|
325
|
+
"react-dom": "^19.0.0"
|
|
326
|
+
},
|
|
327
|
+
"rendererAbi": 1,
|
|
328
|
+
"rendererProfile": "stable-presentation/v1",
|
|
329
|
+
"verifiedPeers": {
|
|
330
|
+
"minimum": {
|
|
331
|
+
"@cratis/arc": "22.16.0",
|
|
332
|
+
"@cratis/arc.react": "22.16.0",
|
|
333
|
+
"@cratis/fundamentals": "7.19.2",
|
|
334
|
+
"@digdir/designsystemet-css": "1.24.0",
|
|
335
|
+
"@digdir/designsystemet-react": "1.24.0",
|
|
336
|
+
"@types/react": "19.0.0",
|
|
337
|
+
"react": "19.0.0",
|
|
338
|
+
"react-dom": "19.0.0",
|
|
339
|
+
"reflect-metadata": "0.2.2",
|
|
340
|
+
"rxjs": "7.8.2",
|
|
341
|
+
"tsyringe": "4.10.0"
|
|
342
|
+
},
|
|
343
|
+
"current": {
|
|
344
|
+
"@cratis/arc": "22.16.0",
|
|
345
|
+
"@cratis/arc.react": "22.16.0",
|
|
346
|
+
"@cratis/fundamentals": "7.19.2",
|
|
347
|
+
"@digdir/designsystemet-css": "1.24.0",
|
|
348
|
+
"@digdir/designsystemet-react": "1.24.0",
|
|
349
|
+
"@types/react": "19.2.18",
|
|
350
|
+
"react": "19.2.8",
|
|
351
|
+
"react-dom": "19.2.8",
|
|
352
|
+
"reflect-metadata": "0.2.2",
|
|
353
|
+
"rxjs": "7.8.2",
|
|
354
|
+
"tsyringe": "4.10.0"
|
|
355
|
+
}
|
|
356
|
+
}
|
|
303
357
|
}
|
|
304
358
|
]
|
|
305
359
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/CheckboxField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CheckboxField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/CheckboxField.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,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;IAC3B,GAAG,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACtC,gCAAgC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC/C;AAKD,UAAU,2BACN,SAAQ,iBAAiB,CAAC,OAAO,CAAC,EAC9B,uBAAuB;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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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,EAAA,aAAA,EAC3B,MAAM,EAAA,QAAA,EAElBA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,KAAK,CAAC,EAAE,EAAE,SAAS,EACvB,SAAS,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,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
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
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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/**
|
|
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,CAAC,IAAwB,KACjD,IAAI,KAAK,SAAS,IAAI,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC;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["../../../../CommandForm/fields/RadioButtonField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,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,e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AA,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":";;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E;gBACrB,EAAE,EAAE,aAAa,CAAC,SAAS;gBAC3B,YAAY,EAAE,aAAa,CAAC,SAAS;gBACrC,kBAAkB,EAAE,aAAa,CAAC,eAAe;gBACjD,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,KAAK,EAAE,KAAK,CAAC,WAAW;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,OAAO,EAAE,QAAQ;AACjB,gBAAA,QAAQ,EAAE,CAAC,OAAO,KAAK,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC;gBACnE,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;AACtB,gBAAA,cAAc,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS;gBAC1C,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,EAAE,EAAE,KAAK,CAAC,EAAE;AACf,aAAA,CAAC,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CAC3B;AAEX,CAAC,EACD,EAAE,YAAY,EAAE,EAAE,EAAE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroupField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/RadioGroupField.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"RadioGroupField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/RadioGroupField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAIH,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAE3B,MAAM,OAAO,CAAC;AACf,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAMxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAI9B,0DAA0D;AAC1D,MAAM,WAAW,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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
props.
|
|
28
|
-
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|