@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.
- package/compat-manifest.json +13 -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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroupField.js","sources":["../../../../CommandForm/fields/RadioGroupField.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 { useId, type HTMLAttributes, type 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 RadioGroupField}. */\nexport interface RadioGroupParts {\n /** Semantic radiogroup wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One option label. */\n option?: 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 radioGroupPartsMatchManifest: ExactPartKeys<RadioGroupParts, PartsOf<'RadioGroupField'>> = true;\nvoid radioGroupPartsMatchManifest;\n\ninterface RadioGroupFieldComponentProps\n extends WrappedFieldProps<string | number>,\n FieldAccessibilityProps {\n options: Array<Record<string, unknown>>;\n optionLabel: string;\n optionValue: string;\n layout?: 'horizontal' | 'vertical';\n /** Native radio-group name. Generated automatically when omitted. */\n name?: string;\n className?: string;\n pt?: RadioGroupParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** A visible radio group bound to a string or number property on an Arc command. */\nexport const RadioGroupField = asCommandFormField<RadioGroupFieldComponentProps>(\n (props) => {\n const generatedName = useId();\n const name = props.name ?? generatedName;\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\n return (\n <div\n {...props.pt?.root}\n id={accessibility.controlId}\n role='radiogroup'\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n aria-invalid={props.invalid || undefined}\n className={[\n 'cratis-radio-group',\n `cratis-radio-group--${props.layout ?? 'vertical'}`,\n props.pt?.root?.className,\n props.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='root'\n data-cratis-component='RadioGroupField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n >\n {props.options.map((option) => {\n const value = option[props.optionValue] as string | number;\n const label = String(option[props.optionLabel] ?? value);\n const selected = props.value === value;\n return (\n <label\n key={String(value)}\n {...props.pt?.option}\n className={[\n 'cratis-choice-field',\n props.pt?.option?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n onBlur={props.onBlur}\n data-cratis-part='option'\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 type='radio'\n name={name}\n checked={selected}\n onChange={(event) => {\n if (event.currentTarget.checked) props.onChange(value);\n }}\n aria-invalid={props.invalid || undefined}\n className={[\n 'cratis-choice-field__native',\n props.pt?.input?.className,\n ]\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={[\n 'cratis-radio__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={selected || undefined}\n />\n </span>\n <span className='cratis-choice-field__label'>{label}</span>\n </label>\n );\n })}\n {accessibility.hiddenError}\n </div>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;MA6Ca,eAAe,GAAG,kBAAkB,CAC7C,CAAC,KAAK,KAAI;AACN,IAAA,MAAM,aAAa,GAAG,KAAK,EAAE;AAC7B,IAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,aAAa;AACxC,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EA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AAC,EAAE,EAAE,GAAG,EAAE,SAAS;iCACpD,MAAM,CAAC,OAAO;AACd,iCAAA,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,KAAK,mBACP,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,kBACvC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,QAAQ,IAAI,SAAS,iBACxB,MAAM,EAAA,QAAA,EAElBA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,KAAK,CAAC,EAAE,EAAE,SAAS,EACvB,SAAS,EAAE;oCACP,yBAAyB;AACzB,oCAAA,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS;AACjC;qCACI,MAAM,CAAC,OAAO;AACd,qCAAA,IAAI,CAAC,GAAG,CAAC,sBACG,WAAW,EAAA,eAAA,EACb,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,kBACvC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,QAAQ,IAAI,SAAS,EAAA,CACtC,GACC,EACPA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,4BAA4B,YAAE,KAAK,EAAA,CAAQ,KA3DtD,MAAM,CAAC,KAAK,CAAC,CA4Dd;AAEhB,YAAA,CAAC,CAAC,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CACxB;AAEd,CAAC,EACD,EAAE,YAAY,EAAE,EAAE,EAAE;;"}
|
|
1
|
+
{"version":3,"file":"RadioGroupField.js","sources":["../../../../CommandForm/fields/RadioGroupField.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 {\n Fragment,\n useId,\n type FocusEventHandler,\n type HTMLAttributes,\n type InputHTMLAttributes,\n type 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 RadioGroupField}. */\nexport interface RadioGroupParts {\n /** Semantic radiogroup wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One option label. */\n option?: 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 radioGroupPartsMatchManifest: ExactPartKeys<RadioGroupParts, PartsOf<'RadioGroupField'>> = true;\nvoid radioGroupPartsMatchManifest;\n\ninterface RadioGroupFieldComponentProps\n extends WrappedFieldProps<string | number>,\n FieldAccessibilityProps {\n options: Array<Record<string, unknown>>;\n optionLabel: string;\n optionValue: string;\n layout?: 'horizontal' | 'vertical';\n /** Native radio-group name. Generated automatically when omitted. */\n name?: string;\n className?: string;\n pt?: RadioGroupParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Props shared by the `RadioGroupField` option part components. */\ninterface RadioOptionPartProps<T> {\n parts?: T;\n state: ChoiceState;\n}\n\n/** Native input of the `RadioGroupField` option. */\nconst RadioOptionInput = ({\n parts,\n name,\n checked,\n onChange,\n state,\n}: RadioOptionPartProps<InputHTMLAttributes<HTMLInputElement>> &\n Pick<RadioProps, 'checked' | 'onChange' | 'name'>) => (\n <input\n {...parts}\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 `RadioGroupField` option. */\nconst RadioOptionBox = ({\n parts,\n state,\n children,\n}: RadioOptionPartProps<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 `RadioGroupField` option. */\nconst RadioOptionIndicator = ({\n parts,\n state,\n children,\n}: RadioOptionPartProps<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 `RadioGroupField` option markup, used when no adapter supplies `common.radio`. */\nconst RadioOptionCore = ({\n name,\n label,\n checked,\n onChange,\n onBlur,\n invalid,\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)}\n onBlur={onBlur as FocusEventHandler<Element> | undefined}\n data-cratis-part='option'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n <RadioOptionInput\n parts={pt?.input}\n name={name}\n checked={checked}\n onChange={onChange}\n state={state}\n />\n <RadioOptionBox parts={pt?.box} state={state}>\n <RadioOptionIndicator parts={pt?.indicator} state={state}></RadioOptionIndicator>\n </RadioOptionBox>\n <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 coreRadioOptionDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: RadioOptionCore,\n}) satisfies unstable_SlotDeclaration<'common.radio'>;\n\n\n/** A visible radio group bound to a string or number property on an Arc command. */\nexport const RadioGroupField = asCommandFormField<RadioGroupFieldComponentProps>(\n (props) => {\n const generatedName = useId();\n const name = props.name ?? generatedName;\n const declaration = unstable_useSlot('common.radio', coreRadioOptionDeclaration);\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\n return (\n <div\n {...props.pt?.root}\n id={accessibility.controlId}\n role='radiogroup'\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n aria-invalid={props.invalid || undefined}\n className={joinClassNames(\n 'cratis-radio-group',\n `cratis-radio-group--${props.layout ?? 'vertical'}`,\n props.pt?.root?.className,\n props.className,\n )}\n data-cratis-part='root'\n data-cratis-component='RadioGroupField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n >\n {props.options.map((option) => {\n const value = option[props.optionValue] as string | number;\n return (\n <Fragment key={String(value)}>\n {renderSlot(declaration, {\n name,\n value,\n label: String(option[props.optionLabel] ?? value),\n checked: props.value === value,\n onChange: (checked) => checked && props.onChange(value),\n onBlur: props.onBlur,\n invalid: props.invalid,\n 'aria-invalid': props.invalid || undefined,\n pt: {\n root: props.pt?.option,\n input: props.pt?.input,\n box: props.pt?.box,\n indicator: props.pt?.indicator,\n },\n })}\n </Fragment>\n );\n })}\n {accessibility.hiddenError}\n </div>\n );\n },\n { defaultValue: '' },\n);\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;AA+DA,MAAM,gBAAgB,GAAG,CAAC,EACtB,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,KAAK,GAE4C,MACjDA,GAAA,CAAA,OAAA,EAAA,EAA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"file":"TextAreaField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/TextAreaField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAMxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAE9B,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC1B,+BAA+B;IAC/B,IAAI,CAAC,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;CACtD;AAED,UAAU,2BACN,SAAQ,iBAAiB,CAAC,MAAM,CAAC,EAC7B,uBAAuB;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA8CD,4EAA4E;AAC5E,eAAO,MAAM,aAAa,0NA8BzB,CAAC"}
|
|
@@ -1,22 +1,38 @@
|
|
|
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 TextAreaFieldCore = ({ id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, value, onChange, onBlur, placeholder, rows, cols, invalid, className, pt, }) => (jsx("textarea", { ...pt?.root, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, value: value, onChange: (event) => onChange?.(event.currentTarget.value, userChange(event)), onBlur: onBlur, placeholder: placeholder, rows: rows, cols: cols, "aria-invalid": invalid || undefined, "data-disabled": pt?.root?.disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": pt?.root?.readOnly || undefined, "data-cratis-component": 'TextAreaField', "data-cratis-part": 'textarea', className: joinClassNames('cratis-field-input', 'cratis-field-textarea', 'cratis:w-full', pt?.root?.className, className) }));
|
|
9
|
+
const coreTextAreaDeclaration = Object.freeze({
|
|
10
|
+
mode: 'presentation',
|
|
11
|
+
fidelity: 'native',
|
|
12
|
+
render: TextAreaFieldCore,
|
|
13
|
+
});
|
|
5
14
|
const TextAreaField = asCommandFormField((props) => {
|
|
6
15
|
const accessibility = useFieldAccessibility(props, {
|
|
7
16
|
id: props.pt?.root?.id,
|
|
8
17
|
ariaLabel: props.pt?.root?.['aria-label'],
|
|
9
18
|
ariaDescribedBy: props.pt?.root?.['aria-describedby'],
|
|
10
19
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const declaration = unstable_useSlot('common.textArea', coreTextAreaDeclaration);
|
|
21
|
+
return (jsxs(Fragment, { children: [renderSlot(declaration, {
|
|
22
|
+
id: accessibility.controlId,
|
|
23
|
+
'aria-label': accessibility.ariaLabel,
|
|
24
|
+
'aria-describedby': accessibility.ariaDescribedBy,
|
|
25
|
+
value: props.value,
|
|
26
|
+
onChange: (value) => props.onChange(value),
|
|
27
|
+
onBlur: props.onBlur,
|
|
28
|
+
placeholder: props.placeholder,
|
|
29
|
+
rows: props.rows ?? 5,
|
|
30
|
+
cols: props.cols,
|
|
31
|
+
invalid: props.invalid,
|
|
32
|
+
'aria-invalid': props.invalid || undefined,
|
|
33
|
+
className: props.className,
|
|
34
|
+
pt: props.pt,
|
|
35
|
+
}), accessibility.hiddenError] }));
|
|
20
36
|
}, { defaultValue: '' });
|
|
21
37
|
|
|
22
38
|
export { TextAreaField };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaField.js","sources":["../../../../CommandForm/fields/TextAreaField.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 { TextareaHTMLAttributes } 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 TextAreaField}. */\nexport interface TextAreaParts {\n /** Native textarea element. */\n root?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n}\n\ninterface TextAreaFieldComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n placeholder?: string;\n rows?: number;\n cols?: number;\n className?: string;\n pt?: TextAreaParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/**
|
|
1
|
+
{"version":3,"file":"TextAreaField.js","sources":["../../../../CommandForm/fields/TextAreaField.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 { TextareaHTMLAttributes } 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 { TextAreaProps } from '../../Common/TextArea';\nimport { joinClassNames, userChange } from './fieldSlotHelpers';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\n\n/** Stable part attributes for {@link TextAreaField}. */\nexport interface TextAreaParts {\n /** Native textarea element. */\n root?: TextareaHTMLAttributes<HTMLTextAreaElement>;\n}\n\ninterface TextAreaFieldComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n placeholder?: string;\n rows?: number;\n cols?: number;\n className?: string;\n pt?: TextAreaParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Core TextAreaField markup, used when no adapter supplies `common.textArea`. */\nconst TextAreaFieldCore = ({\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n value,\n onChange,\n onBlur,\n placeholder,\n rows,\n cols,\n invalid,\n className,\n pt,\n}: TextAreaProps) => (\n <textarea\n {...pt?.root}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n value={value}\n onChange={(event) => onChange?.(event.currentTarget.value, userChange(event))}\n onBlur={onBlur}\n placeholder={placeholder}\n rows={rows}\n cols={cols}\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='TextAreaField'\n data-cratis-part='textarea'\n className={joinClassNames('cratis-field-input', 'cratis-field-textarea', 'cratis:w-full', pt?.root?.className, className)}\n />\n);\n\n/** Frozen Core declaration resolved when no active renderer supplies `common.textArea`. */\nconst coreTextAreaDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: TextAreaFieldCore,\n}) satisfies unstable_SlotDeclaration<'common.textArea'>;\n\n\n/** A multi-line text field bound to a string property on an Arc command. */\nexport const TextAreaField = asCommandFormField<TextAreaFieldComponentProps>(\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 declaration = unstable_useSlot('common.textArea', coreTextAreaDeclaration);\n return (\n <>\n {renderSlot(declaration, {\n id: accessibility.controlId,\n 'aria-label': accessibility.ariaLabel,\n 'aria-describedby': accessibility.ariaDescribedBy,\n value: props.value,\n onChange: (value) => props.onChange(value),\n onBlur: props.onBlur,\n placeholder: props.placeholder,\n rows: props.rows ?? 5,\n cols: props.cols,\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":";;;;;;;AAkCA,MAAM,iBAAiB,GAAG,CAAC,EACvB,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,SAAS,EACT,EAAE,GACU,MACZA,GAAA,CAAA,UAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,EAAE,EAAE,EAAE,EAAA,YAAA,EACM,SAAS,EAAA,kBAAA,EACH,eAAe,EACjC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAC7E,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EAAA,cAAA,EACI,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,EAAE,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,kBAChC,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,EAAE,EAAE,IAAI,EAAE,QAAQ,IAAI,SAAS,EAAA,uBAAA,EACxB,eAAe,EAAA,kBAAA,EACpB,UAAU,EAC3B,SAAS,EAAE,cAAc,CAAC,oBAAoB,EAAE,uBAAuB,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAAA,CAC3H,CACL;AAGD,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC;AAC1C,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,MAAM,EAAE,iBAAiB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ToggleSwitchField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ToggleSwitchField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ToggleSwitchField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ToggleSwitchField.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,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAC9B,sBAAsB;IACtB,IAAI,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACxC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,2BAA2B;IAC3B,OAAO,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAC1C,4BAA4B;IAC5B,MAAM,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAC5C;AAKD,UAAU,+BACN,SAAQ,iBAAiB,CAAC,OAAO,CAAC,EAC9B,uBAAuB;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,iBAAiB,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA4HD,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,8NA4B7B,CAAC"}
|
|
@@ -1,22 +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 SwitchInput = ({ parts, id, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, checked, onChange, state, }) => (jsx("input", { ...parts, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, type: 'checkbox', role: 'switch', 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 SwitchControl = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-switch__control', parts?.className), "data-cratis-part": 'control', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, "aria-hidden": 'true', children: children }));
|
|
10
|
+
const SwitchHandle = ({ parts, state, children, }) => (jsx("span", { ...parts, className: joinClassNames('cratis-switch__handle', parts?.className), "data-cratis-part": 'handle', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: children }));
|
|
11
|
+
const ToggleSwitchFieldCore = ({ 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": 'ToggleSwitchField', "data-disabled": state.disabled || undefined, "data-invalid": state.invalid || undefined, "data-selected": state.selected || undefined, children: [jsx(SwitchInput, { parts: pt?.input, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, checked: checked, onChange: onChange, state: state }), jsx(SwitchControl, { parts: pt?.control, state: state, children: jsx(SwitchHandle, { parts: pt?.handle, state: state }) }), label && jsx("span", { className: 'cratis-choice-field__label', children: label })] }));
|
|
14
|
+
};
|
|
15
|
+
const coreSwitchDeclaration = Object.freeze({
|
|
16
|
+
mode: 'presentation',
|
|
17
|
+
fidelity: 'native',
|
|
18
|
+
render: ToggleSwitchFieldCore,
|
|
19
|
+
});
|
|
5
20
|
const ToggleSwitchField = 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
|
-
|
|
26
|
+
const declaration = unstable_useSlot('common.switch', coreSwitchDeclaration);
|
|
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] }));
|
|
20
40
|
}, { defaultValue: false });
|
|
21
41
|
|
|
22
42
|
export { ToggleSwitchField };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleSwitchField.js","sources":["../../../../CommandForm/fields/ToggleSwitchField.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 ToggleSwitchField}. */\nexport interface ToggleSwitchParts {\n /** Wrapping label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native checkbox with switch semantics. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual switch track. */\n control?: HTMLAttributes<HTMLSpanElement>;\n /** Visual switch handle. */\n handle?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst toggleSwitchPartsMatchManifest: ExactPartKeys<ToggleSwitchParts, PartsOf<'ToggleSwitchField'>> = true;\nvoid toggleSwitchPartsMatchManifest;\n\ninterface ToggleSwitchFieldComponentProps\n extends WrappedFieldProps<boolean>,\n FieldAccessibilityProps {\n label?: string;\n className?: string;\n pt?: ToggleSwitchParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** An on/off switch bound to a boolean property on an Arc command. */\nexport const ToggleSwitchField = asCommandFormField<ToggleSwitchFieldComponentProps>(\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='ToggleSwitchField'\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 role='switch'\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?.control}\n className={['cratis-switch__control', props.pt?.control?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='control'\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?.handle}\n className={['cratis-switch__handle', props.pt?.handle?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='handle'\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.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,iBAAiB,GAAG,kBAAkB,CAC/C,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,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wBAAwB,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS;6BAC7D,MAAM,CAAC,OAAO;6BACd,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,SAAS,EAAA,eAAA,EACX,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,iBAC3B,MAAM,EAAA,QAAA,EAElBA,iBACQ,KAAK,CAAC,EAAE,EAAE,MAAM,EACpB,SAAS,EAAE,CAAC,uBAAuB,EAAE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS;iCAC3D,MAAM,CAAC,OAAO;iCACd,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,QAAQ,mBACV,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,CACzC,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,KAAK,EAAE;;"}
|
|
1
|
+
{"version":3,"file":"ToggleSwitchField.js","sources":["../../../../CommandForm/fields/ToggleSwitchField.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 { SwitchProps } from '../../Common/Switch';\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 ToggleSwitchField}. */\nexport interface ToggleSwitchParts {\n /** Wrapping label. */\n root?: HTMLAttributes<HTMLLabelElement>;\n /** Native checkbox with switch semantics. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visual switch track. */\n control?: HTMLAttributes<HTMLSpanElement>;\n /** Visual switch handle. */\n handle?: HTMLAttributes<HTMLSpanElement>;\n}\n\nconst toggleSwitchPartsMatchManifest: ExactPartKeys<ToggleSwitchParts, PartsOf<'ToggleSwitchField'>> = true;\nvoid toggleSwitchPartsMatchManifest;\n\ninterface ToggleSwitchFieldComponentProps\n extends WrappedFieldProps<boolean>,\n FieldAccessibilityProps {\n label?: string;\n className?: string;\n pt?: ToggleSwitchParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\n/** Props shared by the `ToggleSwitchField` part components. */\ninterface SwitchPartProps<T> {\n parts?: T;\n state: ChoiceState;\n}\n\n/** Native input of the `ToggleSwitchField`. */\nconst SwitchInput = ({\n parts,\n id,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n checked,\n onChange,\n state,\n}: SwitchPartProps<InputHTMLAttributes<HTMLInputElement>> &\n Pick<SwitchProps, '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 role='switch'\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 control of the `ToggleSwitchField`. */\nconst SwitchControl = ({\n parts,\n state,\n children,\n}: SwitchPartProps<HTMLAttributes<HTMLSpanElement>> & { children: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-switch__control', parts?.className)}\n data-cratis-part='control'\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 handle of the `ToggleSwitchField`. */\nconst SwitchHandle = ({\n parts,\n state,\n children,\n}: SwitchPartProps<HTMLAttributes<HTMLSpanElement>> & { children?: ReactNode }) => (\n <span\n {...parts}\n className={joinClassNames('cratis-switch__handle', parts?.className)}\n data-cratis-part='handle'\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 `ToggleSwitchField` markup, used when no adapter supplies `common.switch`. */\nconst ToggleSwitchFieldCore = ({\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}: SwitchProps) => {\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='ToggleSwitchField'\n data-disabled={state.disabled || undefined}\n data-invalid={state.invalid || undefined}\n data-selected={state.selected || undefined}\n >\n <SwitchInput\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 <SwitchControl parts={pt?.control} state={state}>\n <SwitchHandle parts={pt?.handle} state={state}></SwitchHandle>\n </SwitchControl>\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.switch`. */\nconst coreSwitchDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: ToggleSwitchFieldCore,\n}) satisfies unstable_SlotDeclaration<'common.switch'>;\n\n\n/** An on/off switch bound to a boolean property on an Arc command. */\nexport const ToggleSwitchField = asCommandFormField<ToggleSwitchFieldComponentProps>(\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.switch', coreSwitchDeclaration);\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,WAAW,GAAG,CAAC,EACjB,KAAK,EACL,EAAE,EACF,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,OAAO,EACP,QAAQ,EACR,KAAK,GAE+E,MACpFA,kBACQ,KAAK,EACT,EAAE,EAAE,EAAE,EAAA,YAAA,EACM,SAAS,EAAA,kBAAA,EACH,eAAe,EACjC,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,KAAK,KAAK,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CA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
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type { ChangeMeta } from '../../types/ChangeMeta.js';
|
|
3
|
+
/** Joins the truthy class names with a single space. */
|
|
4
|
+
export declare const joinClassNames: (...names: Array<string | undefined>) => string;
|
|
5
|
+
/** Metadata describing a change that originated from a native user event. */
|
|
6
|
+
export declare const userChange: (event: ChangeEvent) => ChangeMeta;
|
|
7
|
+
/** Choice-control state handed from a Core component to its part components. */
|
|
8
|
+
export interface ChoiceState {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
invalid?: boolean;
|
|
11
|
+
selected?: boolean;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=fieldSlotHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldSlotHelpers.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/fieldSlotHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAAwB,CAAC;AAKzD,wDAAwD;AACxD,eAAO,MAAM,cAAc,aAAc,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,WAC/B,CAAC;AAEpC,6EAA6E;AAC7E,eAAO,MAAM,UAAU,UAAW,WAAW,KAAG,UAG9C,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldSlotHelpers.js","sources":["../../../../CommandForm/fields/fieldSlotHelpers.ts"],"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 { ChangeEvent } from 'react';\nimport type { ChangeMeta } from '../../types/ChangeMeta';\n\n// Internal helpers for the CommandForm field Core slot implementations. They emit no\n// data-cratis-part markers, so part ownership stays in each field's own source file.\n\n/** Joins the truthy class names with a single space. */\nexport const joinClassNames = (...names: Array<string | undefined>) =>\n names.filter(Boolean).join(' ');\n\n/** Metadata describing a change that originated from a native user event. */\nexport const userChange = (event: ChangeEvent): ChangeMeta => ({\n source: 'user',\n nativeEvent: event.nativeEvent,\n});\n\n/** Choice-control state handed from a Core component to its part components. */\nexport interface ChoiceState {\n disabled?: boolean;\n invalid?: boolean;\n selected?: boolean;\n}\n"],"names":[],"mappings":"MAUa,cAAc,GAAG,CAAC,GAAG,KAAgC,KAC9D,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG;MAGrB,UAAU,GAAG,CAAC,KAAkB,MAAkB;AAC3D,IAAA,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,KAAK,CAAC,WAAW;AACjC,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogFooter.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogFooter.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogFooter.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogFooter.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAAuB,CAAC;AAS1D,UAAU,UAAU;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACvB;AAyGD,kCAAkC;AAClC,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACrD,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5C;AA4BD,kFAAkF;AAClF,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAyBpD,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
|
|
3
3
|
import { classNames } from '../ClassNames/classNames.js';
|
|
4
|
+
import { useFooterButton } from './DialogFooterButton.js';
|
|
5
|
+
import { renderSlot } from '../renderer/renderSlot.js';
|
|
4
6
|
|
|
5
7
|
const footerButtonsFor = (buttons, labels, focus) => {
|
|
6
8
|
const primary = (result, label) => ({ result, label, primary: true, focused: focus.confirm });
|
|
@@ -32,11 +34,6 @@ const suppressRepeatedActivation = (event) => {
|
|
|
32
34
|
if (event.repeat && isActivationKey(event.key))
|
|
33
35
|
event.preventDefault();
|
|
34
36
|
};
|
|
35
|
-
const buttonAttributes = (kind, part) => ({
|
|
36
|
-
...part,
|
|
37
|
-
type: 'button',
|
|
38
|
-
className: classNames('cratis-dialog__button', `cratis-dialog__button--${kind}`, part?.className),
|
|
39
|
-
});
|
|
40
37
|
const primaryAria = (isBusy) => ({
|
|
41
38
|
'aria-disabled': isBusy || undefined,
|
|
42
39
|
'aria-busy': isBusy || undefined,
|
|
@@ -46,10 +43,32 @@ const activate = (isBusy, onResult, result) => () => {
|
|
|
46
43
|
onResult(result);
|
|
47
44
|
};
|
|
48
45
|
const PrimaryButton = ({ button, isBusy, isValid, pt, confirmRef, onResult }) => {
|
|
49
|
-
const
|
|
50
|
-
return (
|
|
46
|
+
const declaration = useFooterButton();
|
|
47
|
+
return renderSlot(declaration, {
|
|
48
|
+
label: button.label,
|
|
49
|
+
type: 'button',
|
|
50
|
+
variant: 'solid',
|
|
51
|
+
autoFocus: button.focused,
|
|
52
|
+
onClick: activate(isBusy, onResult, button.result),
|
|
53
|
+
onKeyDown: suppressRepeatedActivation,
|
|
54
|
+
disabled: !isValid,
|
|
55
|
+
...primaryAria(isBusy),
|
|
56
|
+
icon: isBusy ? jsx("span", { className: 'cratis-dialog__spinner', "aria-hidden": 'true' }) : undefined,
|
|
57
|
+
pt: { root: pt?.confirm },
|
|
58
|
+
}, confirmRef);
|
|
59
|
+
};
|
|
60
|
+
const SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }) => {
|
|
61
|
+
const declaration = useFooterButton();
|
|
62
|
+
return renderSlot(declaration, {
|
|
63
|
+
label: button.label,
|
|
64
|
+
type: 'button',
|
|
65
|
+
variant: 'outline',
|
|
66
|
+
autoFocus: button.focused,
|
|
67
|
+
onClick: activate(isBusy, onResult, button.result),
|
|
68
|
+
disabled: isBusy,
|
|
69
|
+
pt: { root: pt?.cancel },
|
|
70
|
+
}, button.focused ? cancelRef : null);
|
|
51
71
|
};
|
|
52
|
-
const SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }) => (jsx("button", { ...buttonAttributes('secondary', pt?.cancel), "data-cratis-part": 'cancel', "data-disabled": isBusy || undefined, "data-busy": isBusy || undefined, ref: button.focused ? cancelRef : undefined, onClick: activate(isBusy, onResult, button.result), disabled: isBusy, autoFocus: button.focused, children: jsx("span", { children: button.label }) }));
|
|
53
72
|
const FooterButtons = ({ buttons, labels, focus, isBusy, isValid, pt, confirmRef, cancelRef, onResult }) => {
|
|
54
73
|
if (typeof buttons !== 'number')
|
|
55
74
|
return buttons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogFooter.js","sources":["../../../Dialogs/DialogFooter.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 { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DialogParts, DialogProps } from './Dialog';\nimport type { DialogLabels } from './resolveDialogLabels';\n\ninterface FooterButton {\n result: DialogResult;\n label: string;\n primary: boolean;\n focused: boolean;\n}\n\ninterface FocusFlags {\n confirm: boolean;\n dismissing: boolean;\n}\n\n/**\n * Describes the predefined footer buttons of a button set.\n * @param buttons The dialog's predefined button set.\n * @param labels The resolved labels.\n * @param focus Which button kind receives the initial focus.\n * @returns The buttons in display order; empty for an unknown set.\n */\nconst footerButtonsFor = (buttons: DialogButtons, labels: DialogLabels, focus: FocusFlags): FooterButton[] => {\n const primary = (result: DialogResult, label: string): FooterButton => ({ result, label, primary: true, focused: focus.confirm });\n const secondary = (result: DialogResult, label: string, focused = focus.dismissing): FooterButton => ({\n result,\n label,\n primary: false,\n focused,\n });\n\n switch (buttons) {\n case DialogButtons.Ok:\n return [primary(DialogResult.Ok, labels.ok)];\n case DialogButtons.OkCancel:\n return [primary(DialogResult.Ok, labels.ok), secondary(DialogResult.Cancelled, labels.cancel)];\n case DialogButtons.YesNo:\n return [primary(DialogResult.Yes, labels.yes), secondary(DialogResult.No, labels.no)];\n case DialogButtons.YesNoCancel:\n return [\n primary(DialogResult.Yes, labels.yes),\n secondary(DialogResult.No, labels.no, false),\n secondary(DialogResult.Cancelled, labels.cancel),\n ];\n default:\n return [];\n }\n};\n\ninterface ButtonProps {\n button: FooterButton;\n isBusy: boolean;\n pt: DialogParts | undefined;\n onResult: (result: DialogResult) => void;\n}\n\ninterface PrimaryButtonProps extends ButtonProps {\n isValid: boolean;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n}\n\ninterface SecondaryButtonProps extends ButtonProps {\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n}\n\nconst isActivationKey = (key: string) => key === 'Enter' || key === ' ';\n\n// A held key must not re-submit when focus returns after a refusal.\nconst suppressRepeatedActivation = (event: React.KeyboardEvent) => {\n if (event.repeat && isActivationKey(event.key)) event.preventDefault();\n};\n\nconst buttonAttributes = (kind: 'primary' | 'secondary', part: DialogParts['confirm']) => ({\n ...part,\n type: 'button' as const,\n className: classNames('cratis-dialog__button', `cratis-dialog__button--${kind}`, part?.className),\n});\n\nconst primaryAria = (isBusy: boolean) => ({\n 'aria-disabled': isBusy || undefined,\n 'aria-busy': isBusy || undefined,\n});\n\nconst activate = (isBusy: boolean, onResult: (result: DialogResult) => void, result: DialogResult) => () => {\n if (!isBusy) onResult(result);\n};\n\nconst PrimaryButton = ({ button, isBusy, isValid, pt, confirmRef, onResult }: PrimaryButtonProps) => {\n const isDisabled = !isValid || isBusy;\n return (\n <button\n {...buttonAttributes('primary', pt?.confirm)}\n {...primaryAria(isBusy)}\n data-cratis-part='confirm'\n data-disabled={isDisabled || undefined}\n data-busy={isBusy || undefined}\n ref={confirmRef}\n onClick={activate(isBusy, onResult, button.result)}\n onKeyDown={suppressRepeatedActivation}\n disabled={!isValid}\n autoFocus={button.focused}\n >\n {isBusy && <span className='cratis-dialog__spinner' aria-hidden='true' />}\n <span>{button.label}</span>\n </button>\n );\n};\n\nconst SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }: SecondaryButtonProps) => (\n <button\n {...buttonAttributes('secondary', pt?.cancel)}\n data-cratis-part='cancel'\n data-disabled={isBusy || undefined}\n data-busy={isBusy || undefined}\n ref={button.focused ? cancelRef : undefined}\n onClick={activate(isBusy, onResult, button.result)}\n disabled={isBusy}\n autoFocus={button.focused}\n >\n <span>{button.label}</span>\n </button>\n);\n\n/** Props of the dialog footer. */\nexport interface DialogFooterProps {\n buttons: NonNullable<DialogProps['buttons']>;\n labels: DialogLabels;\n focus: FocusFlags;\n isBusy: boolean;\n isValid: boolean;\n pt: DialogParts | undefined;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n onResult: (result: DialogResult) => void;\n}\n\nconst FooterButtons = ({ buttons, labels, focus, isBusy, isValid, pt, confirmRef, cancelRef, onResult }: DialogFooterProps) => {\n if (typeof buttons !== 'number') return buttons;\n return footerButtonsFor(buttons, labels, focus).map((button) =>\n button.primary ? (\n <PrimaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n isValid={isValid}\n pt={pt}\n confirmRef={confirmRef}\n onResult={onResult}\n />\n ) : (\n <SecondaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n pt={pt}\n cancelRef={cancelRef}\n onResult={onResult}\n />\n ),\n );\n};\n\n/** The dialog footer holding either the predefined buttons or a custom footer. */\nexport const DialogFooter = (props: DialogFooterProps) => {\n const { buttons, isBusy, pt } = props;\n // The predefined footer keeps the confirm button focusable while busy, so only a custom\n // footer needs the whole scope disabled; predefined secondary buttons disable themselves.\n const isFooterScopeBusy = isBusy && typeof buttons !== 'number';\n\n return (\n <footer\n {...pt?.footer}\n className={classNames('cratis-dialog__footer', pt?.footer?.className)}\n style={pt?.footer?.style}\n data-cratis-part='footer'\n >\n <fieldset\n className='cratis-dialog__busy-scope cratis-dialog__busy-scope--footer'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isFooterScopeBusy}\n inert={isFooterScopeBusy}\n aria-busy={isBusy || undefined}\n >\n <FooterButtons {...props} />\n </fieldset>\n </footer>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA4BA,MAAM,gBAAgB,GAAG,CAAC,OAAsB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;"}
|
|
1
|
+
{"version":3,"file":"DialogFooter.js","sources":["../../../Dialogs/DialogFooter.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 { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DialogParts, DialogProps } from './Dialog';\nimport { renderFooterButton, useFooterButton } from './DialogFooterButton';\nimport type { DialogLabels } from './resolveDialogLabels';\n\ninterface FooterButton {\n result: DialogResult;\n label: string;\n primary: boolean;\n focused: boolean;\n}\n\ninterface FocusFlags {\n confirm: boolean;\n dismissing: boolean;\n}\n\n/**\n * Describes the predefined footer buttons of a button set.\n * @param buttons The dialog's predefined button set.\n * @param labels The resolved labels.\n * @param focus Which button kind receives the initial focus.\n * @returns The buttons in display order; empty for an unknown set.\n */\nconst footerButtonsFor = (buttons: DialogButtons, labels: DialogLabels, focus: FocusFlags): FooterButton[] => {\n const primary = (result: DialogResult, label: string): FooterButton => ({ result, label, primary: true, focused: focus.confirm });\n const secondary = (result: DialogResult, label: string, focused = focus.dismissing): FooterButton => ({\n result,\n label,\n primary: false,\n focused,\n });\n\n switch (buttons) {\n case DialogButtons.Ok:\n return [primary(DialogResult.Ok, labels.ok)];\n case DialogButtons.OkCancel:\n return [primary(DialogResult.Ok, labels.ok), secondary(DialogResult.Cancelled, labels.cancel)];\n case DialogButtons.YesNo:\n return [primary(DialogResult.Yes, labels.yes), secondary(DialogResult.No, labels.no)];\n case DialogButtons.YesNoCancel:\n return [\n primary(DialogResult.Yes, labels.yes),\n secondary(DialogResult.No, labels.no, false),\n secondary(DialogResult.Cancelled, labels.cancel),\n ];\n default:\n return [];\n }\n};\n\ninterface ButtonProps {\n button: FooterButton;\n isBusy: boolean;\n pt: DialogParts | undefined;\n onResult: (result: DialogResult) => void;\n}\n\ninterface PrimaryButtonProps extends ButtonProps {\n isValid: boolean;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n}\n\ninterface SecondaryButtonProps extends ButtonProps {\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n}\n\nconst isActivationKey = (key: string) => key === 'Enter' || key === ' ';\n\n// A held key must not re-submit when focus returns after a refusal.\nconst suppressRepeatedActivation = (event: React.KeyboardEvent) => {\n if (event.repeat && isActivationKey(event.key)) event.preventDefault();\n};\n\nconst primaryAria = (isBusy: boolean) => ({\n 'aria-disabled': isBusy || undefined,\n 'aria-busy': isBusy || undefined,\n});\n\nconst activate = (isBusy: boolean, onResult: (result: DialogResult) => void, result: DialogResult) => () => {\n if (!isBusy) onResult(result);\n};\n\nconst PrimaryButton = ({ button, isBusy, isValid, pt, confirmRef, onResult }: PrimaryButtonProps) => {\n const declaration = useFooterButton();\n return renderFooterButton(\n declaration,\n {\n label: button.label,\n type: 'button',\n variant: 'solid',\n autoFocus: button.focused,\n onClick: activate(isBusy, onResult, button.result),\n onKeyDown: suppressRepeatedActivation,\n disabled: !isValid,\n ...primaryAria(isBusy),\n icon: isBusy ? <span className='cratis-dialog__spinner' aria-hidden='true' /> : undefined,\n pt: { root: pt?.confirm },\n },\n confirmRef,\n );\n};\n\nconst SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }: SecondaryButtonProps) => {\n const declaration = useFooterButton();\n return renderFooterButton(\n declaration,\n {\n label: button.label,\n type: 'button',\n variant: 'outline',\n autoFocus: button.focused,\n onClick: activate(isBusy, onResult, button.result),\n disabled: isBusy,\n pt: { root: pt?.cancel },\n },\n button.focused ? cancelRef : null,\n );\n};\n\n/** Props of the dialog footer. */\nexport interface DialogFooterProps {\n buttons: NonNullable<DialogProps['buttons']>;\n labels: DialogLabels;\n focus: FocusFlags;\n isBusy: boolean;\n isValid: boolean;\n pt: DialogParts | undefined;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n onResult: (result: DialogResult) => void;\n}\n\nconst FooterButtons = ({ buttons, labels, focus, isBusy, isValid, pt, confirmRef, cancelRef, onResult }: DialogFooterProps) => {\n if (typeof buttons !== 'number') return buttons;\n return footerButtonsFor(buttons, labels, focus).map((button) =>\n button.primary ? (\n <PrimaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n isValid={isValid}\n pt={pt}\n confirmRef={confirmRef}\n onResult={onResult}\n />\n ) : (\n <SecondaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n pt={pt}\n cancelRef={cancelRef}\n onResult={onResult}\n />\n ),\n );\n};\n\n/** The dialog footer holding either the predefined buttons or a custom footer. */\nexport const DialogFooter = (props: DialogFooterProps) => {\n const { buttons, isBusy, pt } = props;\n // The predefined footer keeps the confirm button focusable while busy, so only a custom\n // footer needs the whole scope disabled; predefined secondary buttons disable themselves.\n const isFooterScopeBusy = isBusy && typeof buttons !== 'number';\n\n return (\n <footer\n {...pt?.footer}\n className={classNames('cratis-dialog__footer', pt?.footer?.className)}\n style={pt?.footer?.style}\n data-cratis-part='footer'\n >\n <fieldset\n className='cratis-dialog__busy-scope cratis-dialog__busy-scope--footer'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isFooterScopeBusy}\n inert={isFooterScopeBusy}\n aria-busy={isBusy || undefined}\n >\n <FooterButtons {...props} />\n </fieldset>\n </footer>\n );\n};\n"],"names":["renderFooterButton","_jsx"],"mappings":";;;;;;AA6BA,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,MAAoB,EAAE,KAAiB,KAAoB;IACzG,MAAM,OAAO,GAAG,CAAC,MAAoB,EAAE,KAAa,MAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACjI,IAAA,MAAM,SAAS,GAAG,CAAC,MAAoB,EAAE,KAAa,EAAE,OAAO,GAAG,KAAK,CAAC,UAAU,MAAoB;QAClG,MAAM;QACN,KAAK;AACL,QAAA,OAA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AO,KAAK,QAAQ;AAE/D,IAAA,QACIA,GAAA,CAAA,QAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,UAAU,CAAC,uBAAuB,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EACrE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAA,kBAAA,EACP,QAAQ,EAAA,QAAA,EAEzBA,GAAA,CAAA,UAAA,EAAA,EACI,SAAS,EAAC,6DAA6D,EAAA,kBAAA,EACtD,YAAY,EAAA,WAAA,EAClB,MAAM,IAAI,SAAS,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,iBAAiB,EAAA,WAAA,EACb,MAAM,IAAI,SAAS,EAAA,QAAA,EAE9BA,GAAA,CAAC,aAAa,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACrB,EAAA,CACN;AAEjB;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ButtonProps } from '../Common/Button.js';
|
|
2
|
+
import { renderSlot } from '../renderer/renderSlot.js';
|
|
3
|
+
import type { unstable_SlotDeclaration } from '../renderer/slots.js';
|
|
4
|
+
/** Core presentation of a footer button, used when no adapter provides `common.button`. */
|
|
5
|
+
export declare const footerButtonDeclaration: Readonly<{
|
|
6
|
+
mode: "presentation";
|
|
7
|
+
fidelity: "native";
|
|
8
|
+
render: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the declaration a footer button renders through.
|
|
12
|
+
* @returns The active adapter's `common.button` declaration, or the core footer button.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useFooterButton: () => unstable_SlotDeclaration<"common.button">;
|
|
15
|
+
export { renderSlot as renderFooterButton };
|
|
16
|
+
//# sourceMappingURL=DialogFooterButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogFooterButton.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogFooterButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAmB,CAAC;AA6DlE,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB;;;;EAIkB,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe,iDAAmE,CAAC;AAEhG,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
4
|
+
import { unstable_useSlot } from '../renderer/RendererContext.js';
|
|
5
|
+
|
|
6
|
+
const PrimaryFooterButton = forwardRef(function PrimaryFooterButton({ label, icon, pt, type, disabled, autoFocus, onClick, onKeyDown, 'aria-disabled': ariaDisabled, 'aria-busy': ariaBusy }, ref) {
|
|
7
|
+
return (jsxs("button", { ...pt?.root, type: type, className: classNames('cratis-dialog__button', 'cratis-dialog__button--primary', pt?.root?.className), "aria-disabled": ariaDisabled, "aria-busy": ariaBusy, "data-cratis-part": 'confirm', "data-disabled": disabled || ariaDisabled ? true : undefined, "data-busy": ariaBusy ? true : undefined, ref: ref, onClick: onClick, onKeyDown: onKeyDown, disabled: disabled, autoFocus: autoFocus, children: [icon, jsx("span", { children: label })] }));
|
|
8
|
+
});
|
|
9
|
+
const SecondaryFooterButton = forwardRef(function SecondaryFooterButton({ label, pt, type, disabled, autoFocus, onClick }, ref) {
|
|
10
|
+
return (jsx("button", { ...pt?.root, type: type, className: classNames('cratis-dialog__button', 'cratis-dialog__button--secondary', pt?.root?.className), "data-cratis-part": 'cancel', "data-disabled": disabled || undefined, "data-busy": disabled || undefined, ref: ref, onClick: onClick, disabled: disabled, autoFocus: autoFocus, children: jsx("span", { children: label }) }));
|
|
11
|
+
});
|
|
12
|
+
const DialogFooterButtonImplementation = forwardRef(function DialogFooterButtonImplementation(props, ref) {
|
|
13
|
+
return props.variant === 'solid' ? jsx(PrimaryFooterButton, { ...props, ref: ref }) : jsx(SecondaryFooterButton, { ...props, ref: ref });
|
|
14
|
+
});
|
|
15
|
+
const footerButtonDeclaration = Object.freeze({
|
|
16
|
+
mode: 'presentation',
|
|
17
|
+
fidelity: 'native',
|
|
18
|
+
render: DialogFooterButtonImplementation,
|
|
19
|
+
});
|
|
20
|
+
const useFooterButton = () => unstable_useSlot('common.button', footerButtonDeclaration);
|
|
21
|
+
|
|
22
|
+
export { footerButtonDeclaration, useFooterButton };
|
|
23
|
+
//# sourceMappingURL=DialogFooterButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogFooterButton.js","sources":["../../../Dialogs/DialogFooterButton.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 { forwardRef } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { ButtonProps } from '../Common/Button';\nimport { unstable_useSlot } from '../renderer/RendererContext';\nimport { renderSlot } from '../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../renderer/slots';\n\n/**\n * The predefined footer buttons resolve through the `common.button` slot. The button kind travels as\n * the slot's `variant`: `solid` is the confirming (primary) button, `outline` a dismissing one.\n */\n\nconst PrimaryFooterButton = forwardRef<HTMLButtonElement, ButtonProps>(function PrimaryFooterButton(\n { label, icon, pt, type, disabled, autoFocus, onClick, onKeyDown, 'aria-disabled': ariaDisabled, 'aria-busy': ariaBusy },\n ref,\n) {\n return (\n <button\n {...pt?.root}\n type={type}\n className={classNames('cratis-dialog__button', 'cratis-dialog__button--primary', pt?.root?.className)}\n aria-disabled={ariaDisabled}\n aria-busy={ariaBusy}\n data-cratis-part='confirm'\n data-disabled={disabled || ariaDisabled ? true : undefined}\n data-busy={ariaBusy ? true : undefined}\n ref={ref}\n onClick={onClick}\n onKeyDown={onKeyDown}\n disabled={disabled}\n autoFocus={autoFocus}\n >\n {icon}\n <span>{label}</span>\n </button>\n );\n});\n\nconst SecondaryFooterButton = forwardRef<HTMLButtonElement, ButtonProps>(function SecondaryFooterButton(\n { label, pt, type, disabled, autoFocus, onClick },\n ref,\n) {\n return (\n <button\n {...pt?.root}\n type={type}\n className={classNames('cratis-dialog__button', 'cratis-dialog__button--secondary', pt?.root?.className)}\n data-cratis-part='cancel'\n data-disabled={disabled || undefined}\n data-busy={disabled || undefined}\n ref={ref}\n onClick={onClick}\n disabled={disabled}\n autoFocus={autoFocus}\n >\n <span>{label}</span>\n </button>\n );\n});\n\nconst DialogFooterButtonImplementation = forwardRef<HTMLButtonElement, ButtonProps>(\n function DialogFooterButtonImplementation(props, ref) {\n return props.variant === 'solid' ? <PrimaryFooterButton {...props} ref={ref} /> : <SecondaryFooterButton {...props} ref={ref} />;\n },\n);\n\n/** Core presentation of a footer button, used when no adapter provides `common.button`. */\nexport const footerButtonDeclaration = Object.freeze({\n mode: 'presentation',\n fidelity: 'native',\n render: DialogFooterButtonImplementation,\n}) satisfies unstable_SlotDeclaration<'common.button'>;\n\n/**\n * Resolves the declaration a footer button renders through.\n * @returns The active adapter's `common.button` declaration, or the core footer button.\n */\nexport const useFooterButton = () => unstable_useSlot('common.button', footerButtonDeclaration);\n\nexport { renderSlot as renderFooterButton };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAeA,MAAM,mBAAmB,GAAG,UAAU,CAAiC,SAAS,mBAAmB,CAC/F,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,EACxH,GAAG,EAAA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