@cratis/components 4.42.1 → 4.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/Canvas/Canvas.d.ts.map +1 -1
  3. package/dist/esm/Canvas/Canvas.js +16 -109
  4. package/dist/esm/Canvas/Canvas.js.map +1 -1
  5. package/dist/esm/Canvas/CanvasWorldLayers.d.ts +22 -0
  6. package/dist/esm/Canvas/CanvasWorldLayers.d.ts.map +1 -0
  7. package/dist/esm/Canvas/CanvasWorldLayers.js +27 -0
  8. package/dist/esm/Canvas/CanvasWorldLayers.js.map +1 -0
  9. package/dist/esm/Canvas/useCanvasSurface.d.ts +57 -0
  10. package/dist/esm/Canvas/useCanvasSurface.d.ts.map +1 -0
  11. package/dist/esm/Canvas/useCanvasSurface.js +112 -0
  12. package/dist/esm/Canvas/useCanvasSurface.js.map +1 -0
  13. package/dist/esm/CommandDialog/CommandStepperContent.d.ts.map +1 -1
  14. package/dist/esm/CommandDialog/CommandStepperContent.js +31 -119
  15. package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
  16. package/dist/esm/CommandDialog/CommandStepperList.d.ts +19 -0
  17. package/dist/esm/CommandDialog/CommandStepperList.d.ts.map +1 -0
  18. package/dist/esm/CommandDialog/CommandStepperList.js +20 -0
  19. package/dist/esm/CommandDialog/CommandStepperList.js.map +1 -0
  20. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts +20 -0
  21. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts.map +1 -0
  22. package/dist/esm/CommandDialog/CommandStepperNavigation.js +15 -0
  23. package/dist/esm/CommandDialog/CommandStepperNavigation.js.map +1 -0
  24. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts +20 -0
  25. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts.map +1 -0
  26. package/dist/esm/CommandDialog/CommandStepperPanels.js +9 -0
  27. package/dist/esm/CommandDialog/CommandStepperPanels.js.map +1 -0
  28. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts +23 -0
  29. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts.map +1 -0
  30. package/dist/esm/CommandDialog/CommandStepperStepParts.js +9 -0
  31. package/dist/esm/CommandDialog/CommandStepperStepParts.js.map +1 -0
  32. package/dist/esm/CommandDialog/commandStepperFields.d.ts +6 -0
  33. package/dist/esm/CommandDialog/commandStepperFields.d.ts.map +1 -0
  34. package/dist/esm/CommandDialog/commandStepperFields.js +54 -0
  35. package/dist/esm/CommandDialog/commandStepperFields.js.map +1 -0
  36. package/dist/esm/CommandDialog/joinClassNames.d.ts +3 -0
  37. package/dist/esm/CommandDialog/joinClassNames.d.ts.map +1 -0
  38. package/dist/esm/CommandDialog/joinClassNames.js +4 -0
  39. package/dist/esm/CommandDialog/joinClassNames.js.map +1 -0
  40. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts +20 -0
  41. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts.map +1 -0
  42. package/dist/esm/CommandDialog/resolveStepperLabels.js +8 -0
  43. package/dist/esm/CommandDialog/resolveStepperLabels.js.map +1 -0
  44. package/dist/esm/CommandDialog/useStepValidation.d.ts +7 -0
  45. package/dist/esm/CommandDialog/useStepValidation.d.ts.map +1 -0
  46. package/dist/esm/CommandDialog/useStepValidation.js +14 -0
  47. package/dist/esm/CommandDialog/useStepValidation.js.map +1 -0
  48. package/dist/esm/CommandDialog/useStepperState.d.ts +30 -0
  49. package/dist/esm/CommandDialog/useStepperState.d.ts.map +1 -0
  50. package/dist/esm/CommandDialog/useStepperState.js +37 -0
  51. package/dist/esm/CommandDialog/useStepperState.js.map +1 -0
  52. package/dist/esm/CommandForm/fields/ChipsField.d.ts +1 -1
  53. package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
  54. package/dist/esm/CommandForm/fields/ChipsField.js +7 -39
  55. package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
  56. package/dist/esm/CommandForm/fields/ChipsInput.d.ts +18 -0
  57. package/dist/esm/CommandForm/fields/ChipsInput.d.ts.map +1 -0
  58. package/dist/esm/CommandForm/fields/ChipsInput.js +12 -0
  59. package/dist/esm/CommandForm/fields/ChipsInput.js.map +1 -0
  60. package/dist/esm/CommandForm/fields/ChipsItem.d.ts +14 -0
  61. package/dist/esm/CommandForm/fields/ChipsItem.d.ts.map +1 -0
  62. package/dist/esm/CommandForm/fields/ChipsItem.js +14 -0
  63. package/dist/esm/CommandForm/fields/ChipsItem.js.map +1 -0
  64. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts +19 -0
  65. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts.map +1 -0
  66. package/dist/esm/CommandForm/fields/useChipsDraft.js +19 -0
  67. package/dist/esm/CommandForm/fields/useChipsDraft.js.map +1 -0
  68. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  69. package/dist/esm/Common/CratisComponentsProvider.js +1 -44
  70. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  71. package/dist/esm/Common/legacyLocaleMessages.d.ts +7 -0
  72. package/dist/esm/Common/legacyLocaleMessages.d.ts.map +1 -0
  73. package/dist/esm/Common/legacyLocaleMessages.js +43 -0
  74. package/dist/esm/Common/legacyLocaleMessages.js.map +1 -0
  75. package/dist/esm/DataTables/DataTableCore.d.ts +1 -1
  76. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  77. package/dist/esm/DataTables/DataTableCore.js +12 -66
  78. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  79. package/dist/esm/DataTables/DataTableHead.d.ts +23 -0
  80. package/dist/esm/DataTables/DataTableHead.d.ts.map +1 -0
  81. package/dist/esm/DataTables/DataTableHead.js +12 -0
  82. package/dist/esm/DataTables/DataTableHead.js.map +1 -0
  83. package/dist/esm/DataTables/DataTableRows.d.ts +19 -0
  84. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -0
  85. package/dist/esm/DataTables/DataTableRows.js +7 -0
  86. package/dist/esm/DataTables/DataTableRows.js.map +1 -0
  87. package/dist/esm/DataTables/DataTableTable.d.ts +20 -0
  88. package/dist/esm/DataTables/DataTableTable.d.ts.map +1 -0
  89. package/dist/esm/DataTables/DataTableTable.js +10 -0
  90. package/dist/esm/DataTables/DataTableTable.js.map +1 -0
  91. package/dist/esm/DataTables/useDataTableRows.d.ts +40 -0
  92. package/dist/esm/DataTables/useDataTableRows.d.ts.map +1 -0
  93. package/dist/esm/DataTables/useDataTableRows.js +49 -0
  94. package/dist/esm/DataTables/useDataTableRows.js.map +1 -0
  95. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ type StepperMessages = {
2
+ stepper?: {
3
+ next?: string;
4
+ previous?: string;
5
+ submit?: string;
6
+ };
7
+ } | undefined;
8
+ interface StepperLabelOverrides {
9
+ nextLabel?: string;
10
+ previousLabel?: string;
11
+ okLabel?: string;
12
+ }
13
+ /** Resolves the navigation labels: explicit prop, then the provider's message, then the English default. */
14
+ export declare const resolveStepperLabels: (messages: StepperMessages, overrides: StepperLabelOverrides) => {
15
+ next: string;
16
+ previous: string;
17
+ ok: string;
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=resolveStepperLabels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveStepperLabels.d.ts","sourceRoot":"","sources":["../../../CommandDialog/resolveStepperLabels.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,SAAS,CAAC;AAEvG,UAAU,qBAAqB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4GAA4G;AAC5G,eAAO,MAAM,oBAAoB,aAAc,eAAe,aAAa,qBAAqB;IAC5F,IAAI;IACJ,QAAQ;IACR,EAAE;CACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ const resolveStepperLabels = (messages, overrides) => ({
2
+ next: overrides.nextLabel ?? messages?.stepper?.next ?? 'Next',
3
+ previous: overrides.previousLabel ?? messages?.stepper?.previous ?? 'Previous',
4
+ ok: overrides.okLabel ?? messages?.stepper?.submit ?? 'Submit',
5
+ });
6
+
7
+ export { resolveStepperLabels };
8
+ //# sourceMappingURL=resolveStepperLabels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveStepperLabels.js","sources":["../../../CommandDialog/resolveStepperLabels.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\ntype StepperMessages = { stepper?: { next?: string; previous?: string; submit?: string } } | undefined;\n\ninterface StepperLabelOverrides {\n nextLabel?: string;\n previousLabel?: string;\n okLabel?: string;\n}\n\n/** Resolves the navigation labels: explicit prop, then the provider's message, then the English default. */\nexport const resolveStepperLabels = (messages: StepperMessages, overrides: StepperLabelOverrides) => ({\n next: overrides.nextLabel ?? messages?.stepper?.next ?? 'Next',\n previous: overrides.previousLabel ?? messages?.stepper?.previous ?? 'Previous',\n ok: overrides.okLabel ?? messages?.stepper?.submit ?? 'Submit',\n});\n"],"names":[],"mappings":"AAYO,MAAM,oBAAoB,GAAG,CAAC,QAAyB,EAAE,SAAgC,MAAM;IAClG,IAAI,EAAE,SAAS,CAAC,SAAS,IAAI,QAAQ,EAAE,OAAO,EAAE,IAAI,IAAI,MAAM;IAC9D,QAAQ,EAAE,SAAS,CAAC,aAAa,IAAI,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,UAAU;IAC9E,EAAE,EAAE,SAAS,CAAC,OAAO,IAAI,QAAQ,EAAE,OAAO,EAAE,MAAM,IAAI,QAAQ;AACjE,CAAA;;"}
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { StepperPanelProps } from './StepperPanel.js';
3
+ /**
4
+ * Derives the per-step error flags from the step panels' fields and reports them upward.
5
+ */
6
+ export declare const useStepValidation: (panels: React.ReactElement<StepperPanelProps>[], getFieldError: ((fieldName: string) => unknown) | undefined, onStepErrorsChange: ((stepErrors: boolean[]) => void) | undefined) => boolean[];
7
+ //# sourceMappingURL=useStepValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStepValidation.d.ts","sourceRoot":"","sources":["../../../CommandDialog/useStepValidation.ts"],"names":[],"mappings":"AAGA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAGxD;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAClB,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,iBAChC,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,sBACvC,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,cAoBpE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { useMemo, useEffect } from 'react';
2
+ import { extractFieldNamesFromNode } from './commandStepperFields.js';
3
+
4
+ const useStepValidation = (panels, getFieldError, onStepErrorsChange) => {
5
+ const stepFieldNames = useMemo(() => panels.map((panel) => extractFieldNamesFromNode(panel.props.children)), [panels]);
6
+ const stepErrors = useMemo(() => stepFieldNames.map((fields) => fields.some((fieldName) => !!getFieldError?.(fieldName))), [stepFieldNames, getFieldError]);
7
+ useEffect(() => {
8
+ onStepErrorsChange?.(stepErrors);
9
+ }, [onStepErrorsChange, stepErrors]);
10
+ return stepErrors;
11
+ };
12
+
13
+ export { useStepValidation };
14
+ //# sourceMappingURL=useStepValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStepValidation.js","sources":["../../../CommandDialog/useStepValidation.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 React, { useEffect, useMemo } from 'react';\nimport type { StepperPanelProps } from './StepperPanel';\nimport { extractFieldNamesFromNode } from './commandStepperFields';\n\n/**\n * Derives the per-step error flags from the step panels' fields and reports them upward.\n */\nexport const useStepValidation = (\n panels: React.ReactElement<StepperPanelProps>[],\n getFieldError: ((fieldName: string) => unknown) | undefined,\n onStepErrorsChange: ((stepErrors: boolean[]) => void) | undefined,\n) => {\n const stepFieldNames = useMemo(\n () => panels.map((panel) => extractFieldNamesFromNode(panel.props.children)),\n [panels],\n );\n\n const stepErrors = useMemo(\n () =>\n stepFieldNames.map((fields) =>\n fields.some((fieldName) => !!getFieldError?.(fieldName)),\n ),\n [stepFieldNames, getFieldError],\n );\n\n useEffect(() => {\n onStepErrorsChange?.(stepErrors);\n }, [onStepErrorsChange, stepErrors]);\n\n return stepErrors;\n};\n"],"names":[],"mappings":";;;AAUO,MAAM,iBAAiB,GAAG,CAC7B,MAA+C,EAC/C,aAA2D,EAC3D,kBAAiE,KACjE;AACA,IAAA,MAAM,cAAc,GAAG,OAAO,CAC1B,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,yBAAyB,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAC5E,CAAC,MAAM,CAAC,CACX;AAED,IAAA,MAAM,UAAU,GAAG,OAAO,CACtB,MACI,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,KACtB,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC,CAC3D,EACL,CAAC,cAAc,EAAE,aAAa,CAAC,CAClC;IAED,SAAS,CAAC,MAAK;AACX,QAAA,kBAAkB,GAAG,UAAU,CAAC;AACpC,IAAA,CAAC,EAAE,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;AAEpC,IAAA,OAAO,UAAU;AACrB;;"}
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { StepperPanelProps } from './StepperPanel.js';
3
+ import type { StepperChangeEvent } from './CommandStepper.js';
4
+ interface StepperStateInput {
5
+ children: React.ReactNode;
6
+ activeStep: number;
7
+ visitedSteps: Set<number>;
8
+ linear: boolean;
9
+ getFieldError?: (fieldName: string) => unknown;
10
+ onStepErrorsChange?: (stepErrors: boolean[]) => void;
11
+ onActiveStepChange?: (stepIndex: number) => void;
12
+ onVisitedStepsChange?: (visitedSteps: Set<number>) => void;
13
+ onChangeStep?: (event: StepperChangeEvent) => void;
14
+ }
15
+ /**
16
+ * Derives the rendered steps, the clamped current step, the validation state and the
17
+ * navigation gate of a stepper from its controlled props.
18
+ */
19
+ export declare const useStepperState: ({ children, activeStep, visitedSteps, linear, getFieldError, onStepErrorsChange, onActiveStepChange, onVisitedStepsChange, onChangeStep, }: StepperStateInput) => {
20
+ panels: React.ReactElement<StepperPanelProps, string | React.JSXElementConstructor<any>>[];
21
+ currentStep: number;
22
+ isFirstStep: boolean;
23
+ isLastStep: boolean;
24
+ stepErrors: boolean[];
25
+ isCurrentStepInvalid: boolean;
26
+ hasAnyStepErrors: boolean;
27
+ changeStep: (index: number, fromHeader?: boolean) => void;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=useStepperState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStepperState.d.ts","sourceRoot":"","sources":["../../../CommandDialog/useStepperState.ts"],"names":[],"mappings":"AAGA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAGxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAkB,CAAC;AAG3D,UAAU,iBAAiB;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC3D,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACtD;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,+IAUzB,iBAAiB;;;;;;;;wBAmBW,MAAM;CAuBpC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { useMemo } from 'react';
2
+ import { getStepPanels } from './stepChildren.js';
3
+ import { transitionStep } from './transitionStep.js';
4
+ import { useStepValidation } from './useStepValidation.js';
5
+
6
+ const useStepperState = ({ children, activeStep, visitedSteps, linear, getFieldError, onStepErrorsChange, onActiveStepChange, onVisitedStepsChange, onChangeStep, }) => {
7
+ const panels = useMemo(() => getStepPanels(children), [children]);
8
+ const stepCount = panels.length;
9
+ const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));
10
+ const stepErrors = useStepValidation(panels, getFieldError, onStepErrorsChange);
11
+ const isCurrentStepInvalid = stepErrors[currentStep] ?? false;
12
+ const changeStep = (index, fromHeader = false) => transitionStep({
13
+ index,
14
+ currentStep,
15
+ stepCount,
16
+ isCurrentStepInvalid,
17
+ linear,
18
+ fromHeader,
19
+ visitedSteps,
20
+ onActiveStepChange,
21
+ onVisitedStepsChange,
22
+ onChangeStep,
23
+ });
24
+ return {
25
+ panels,
26
+ currentStep,
27
+ isFirstStep: currentStep <= 0,
28
+ isLastStep: currentStep >= stepCount - 1,
29
+ stepErrors,
30
+ isCurrentStepInvalid,
31
+ hasAnyStepErrors: stepErrors.some((hasError) => hasError),
32
+ changeStep,
33
+ };
34
+ };
35
+
36
+ export { useStepperState };
37
+ //# sourceMappingURL=useStepperState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStepperState.js","sources":["../../../CommandDialog/useStepperState.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 React, { useMemo } from 'react';\nimport type { StepperPanelProps } from './StepperPanel';\nimport { getStepPanels } from './stepChildren';\nimport { transitionStep } from './transitionStep';\nimport type { StepperChangeEvent } from './CommandStepper';\nimport { useStepValidation } from './useStepValidation';\n\ninterface StepperStateInput {\n children: React.ReactNode;\n activeStep: number;\n visitedSteps: Set<number>;\n linear: boolean;\n getFieldError?: (fieldName: string) => unknown;\n onStepErrorsChange?: (stepErrors: boolean[]) => void;\n onActiveStepChange?: (stepIndex: number) => void;\n onVisitedStepsChange?: (visitedSteps: Set<number>) => void;\n onChangeStep?: (event: StepperChangeEvent) => void;\n}\n\n/**\n * Derives the rendered steps, the clamped current step, the validation state and the\n * navigation gate of a stepper from its controlled props.\n */\nexport const useStepperState = ({\n children,\n activeStep,\n visitedSteps,\n linear,\n getFieldError,\n onStepErrorsChange,\n onActiveStepChange,\n onVisitedStepsChange,\n onChangeStep,\n}: StepperStateInput) => {\n // The steps that actually render. Conditional steps (`{condition && <StepperPanel/>}`)\n // leave falsy children behind, so the count, the per-step validation state and what the\n // Stepper renders are all derived from this one list — they cannot drift apart.\n const panels = useMemo(\n () => getStepPanels(children) as React.ReactElement<StepperPanelProps>[],\n [children],\n );\n const stepCount = panels.length;\n\n // A conditional step can vanish after the user has advanced past it, which leaves the\n // incoming index pointing at a step that is no longer rendered. Clamp it into the set that\n // is, so the panel shown, the validation state read and the buttons offered all belong to a\n // step that exists.\n const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));\n\n const stepErrors = useStepValidation(panels, getFieldError, onStepErrorsChange);\n const isCurrentStepInvalid = stepErrors[currentStep] ?? false;\n\n const changeStep = (index: number, fromHeader = false) => transitionStep({\n index,\n currentStep,\n stepCount,\n isCurrentStepInvalid,\n linear,\n fromHeader,\n visitedSteps,\n onActiveStepChange,\n onVisitedStepsChange,\n onChangeStep,\n });\n\n return {\n panels,\n currentStep,\n isFirstStep: currentStep <= 0,\n isLastStep: currentStep >= stepCount - 1,\n stepErrors,\n isCurrentStepInvalid,\n hasAnyStepErrors: stepErrors.some((hasError) => hasError),\n changeStep,\n };\n};\n"],"names":[],"mappings":";;;;;AA0BO,MAAM,eAAe,GAAG,CAAC,EAC5B,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,GACI,KAAI;AAIpB,IAAA,MAAM,MAAM,GAAG,OAAO,CAClB,MAAM,aAAa,CAAC,QAAQ,CAA4C,EACxE,CAAC,QAAQ,CAAC,CACb;AACD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM;IAM/B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAEjF,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,kBAAkB,CAAC;IAC/E,MAAM,oBAAoB,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,KAAK;AAE7D,IAAA,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,UAAU,GAAG,KAAK,KAAK,cAAc,CAAC;QACrE,KAAK;QACL,WAAW;QACX,SAAS;QACT,oBAAoB;QACpB,MAAM;QACN,UAAU;QACV,YAAY;QACZ,kBAAkB;QAClB,oBAAoB;QACpB,YAAY;AACf,KAAA,CAAC;IAEF,OAAO;QACH,MAAM;QACN,WAAW;QACX,WAAW,EAAE,WAAW,IAAI,CAAC;AAC7B,QAAA,UAAU,EAAE,WAAW,IAAI,SAAS,GAAG,CAAC;QACxC,UAAU;QACV,oBAAoB;QACpB,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;QACzD,UAAU;KACb;AACL;;"}
@@ -1,4 +1,4 @@
1
- import { type HTMLAttributes, type InputHTMLAttributes } from 'react';
1
+ import type { HTMLAttributes, InputHTMLAttributes } from 'react';
2
2
  import { type WrappedFieldProps } from '@cratis/arc.react/commands';
3
3
  import { type FieldAccessibilityProps } from './fieldAccessibility.js';
4
4
  /** Stable part attributes for {@link ChipsField}. */
@@ -1 +1 @@
1
- {"version":3,"file":"ChipsField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ChipsField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAM9B,qDAAqD;AACrD,MAAM,WAAW,UAAU;IACvB,qBAAqB;IACrB,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,yBAAyB;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IACvC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACvD,gCAAgC;IAChC,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CACjD;AAKD,UAAU,wBACN,SAAQ,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,uBAAuB;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB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AO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA0DD,wEAAwE;AACxE,eAAO,MAAM,UAAU,uNAErB,CAAC"}
@@ -1,55 +1,23 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useState } from 'react';
3
2
  import { asCommandFormField } from '@cratis/arc.react/commands';
4
3
  import { useFieldAccessibility } from './fieldAccessibility.js';
5
- import { appendChipCandidates } from './chipValues.js';
6
- import { useCratisIcon } from '../../configuration/useCratisIcon.js';
4
+ import { classNames } from '../../ClassNames/classNames.js';
5
+ import { ChipsInput } from './ChipsInput.js';
6
+ import { ChipsItem } from './ChipsItem.js';
7
+ import { useChipsDraft } from './useChipsDraft.js';
7
8
 
8
9
  const ChipsControl = (props) => {
9
- const [draft, setDraft] = useState('');
10
- const icon = useCratisIcon();
10
+ const { draft, setDraft, commit } = useChipsDraft(props);
11
11
  const accessibility = useFieldAccessibility(props, {
12
12
  id: props.pt?.input?.id,
13
13
  ariaLabel: props.pt?.input?.['aria-label'],
14
14
  ariaDescribedBy: props.pt?.input?.['aria-describedby'],
15
15
  });
16
- const commit = () => {
17
- const candidates = (props.separator ? draft.split(props.separator) : [draft])
18
- .map((value) => value.trim())
19
- .filter(Boolean);
20
- if (candidates.length === 0)
21
- return;
22
- props.onChange(appendChipCandidates(props.value, candidates, props.max, props.allowDuplicate ?? false));
23
- setDraft('');
24
- };
25
- return (jsxs("div", { ...props.pt?.root, className: [
26
- 'cratis-chips-field',
27
- 'cratis:w-full',
28
- props.pt?.root?.className,
29
- props.className,
30
- ]
31
- .filter(Boolean)
32
- .join(' '), onBlur: (event) => {
16
+ return (jsxs("div", { ...props.pt?.root, className: classNames('cratis-chips-field', 'cratis:w-full', props.pt?.root?.className, props.className), onBlur: (event) => {
33
17
  props.onBlur?.();
34
18
  if (props.addOnBlur && !event.currentTarget.contains(event.relatedTarget))
35
19
  commit();
36
- }, "data-cratis-part": 'root', "data-cratis-component": 'ChipsField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, children: [props.value.map((item, index) => (jsxs("span", { ...props.pt?.item, className: ['cratis-chips-field__item', props.pt?.item?.className]
37
- .filter(Boolean)
38
- .join(' '), "data-cratis-part": 'item', "data-selected": true, children: [jsx("span", { children: item }), jsx("button", { ...props.pt?.remove, type: 'button', className: [
39
- 'cratis-chips-field__remove',
40
- props.pt?.remove?.className,
41
- ]
42
- .filter(Boolean)
43
- .join(' '), "data-cratis-part": 'remove', "data-disabled": props.pt?.remove?.disabled || undefined, "data-selected": true, "aria-label": typeof props.removeAriaLabel === 'function'
44
- ? props.removeAriaLabel(item, index)
45
- : (props.removeAriaLabel ?? `Remove ${item}`), onClick: () => props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index)), children: icon('remove', '×') })] }, `${item}-${index}`))), jsx("input", { ...props.pt?.input, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, value: draft, onChange: (event) => setDraft(event.target.value), onKeyDown: (event) => {
46
- if (event.key === 'Enter') {
47
- event.preventDefault();
48
- commit();
49
- }
50
- }, placeholder: props.placeholder, "aria-invalid": props.invalid || undefined, "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, className: ['cratis-chips-field__input', props.pt?.input?.className]
51
- .filter(Boolean)
52
- .join(' '), "data-cratis-part": 'input' }), accessibility.hiddenError] }));
20
+ }, "data-cratis-part": 'root', "data-cratis-component": 'ChipsField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, children: [props.value.map((item, index) => (jsx(ChipsItem, { item: item, index: index, removeAriaLabel: props.removeAriaLabel, parts: props.pt, onRemove: () => props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index)) }, `${item}-${index}`))), jsx(ChipsInput, { id: accessibility.controlId, ariaLabel: accessibility.ariaLabel, ariaDescribedBy: accessibility.ariaDescribedBy, draft: draft, onDraftChange: setDraft, onCommit: commit, placeholder: props.placeholder, invalid: props.invalid, parts: props.pt }), accessibility.hiddenError] }));
53
21
  };
54
22
  const ChipsField = asCommandFormField(ChipsControl, {
55
23
  defaultValue: [],
@@ -1 +1 @@
1
- {"version":3,"file":"ChipsField.js","sources":["../../../../CommandForm/fields/ChipsField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useState, 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 { appendChipCandidates } from './chipValues';\nimport { useCratisIcon } from '../../configuration/useCratisIcon';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link ChipsField}. */\nexport interface ChipsParts {\n /** Field wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One selected chip. */\n item?: HTMLAttributes<HTMLSpanElement>;\n /** Chip removal button. */\n remove?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Native draft-value input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n}\n\nconst chipsPartsMatchManifest: ExactPartKeys<ChipsParts, PartsOf<'ChipsField'>> = true;\nvoid chipsPartsMatchManifest;\n\ninterface ChipsFieldComponentProps\n extends WrappedFieldProps<string[]>, FieldAccessibilityProps {\n placeholder?: string;\n max?: number;\n separator?: string;\n addOnBlur?: boolean;\n allowDuplicate?: boolean;\n /** Builds a remove-button label, or supplies one shared localized label. */\n removeAriaLabel?: string | ((item: string, index: number) => string);\n className?: string;\n pt?: ChipsParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\nconst ChipsControl = (props: ChipsFieldComponentProps) => {\n const [draft, setDraft] = useState('');\n const icon = useCratisIcon();\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'],\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n\n const commit = () => {\n const candidates = (props.separator ? draft.split(props.separator) : [draft])\n .map((value) => value.trim())\n .filter(Boolean);\n if (candidates.length === 0) return;\n props.onChange(\n appendChipCandidates(\n props.value,\n candidates,\n props.max,\n props.allowDuplicate ?? false,\n ),\n );\n setDraft('');\n };\n\n return (\n <div\n {...props.pt?.root}\n className={[\n 'cratis-chips-field',\n 'cratis:w-full',\n props.pt?.root?.className,\n props.className,\n ]\n .filter(Boolean)\n .join(' ')}\n onBlur={(event) => {\n props.onBlur?.();\n if (props.addOnBlur && !event.currentTarget.contains(event.relatedTarget))\n commit();\n }}\n data-cratis-part='root'\n data-cratis-component='ChipsField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-readonly={props.pt?.input?.readOnly || undefined}\n >\n {props.value.map((item, index) => (\n <span\n key={`${item}-${index}`}\n {...props.pt?.item}\n className={['cratis-chips-field__item', props.pt?.item?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='item'\n data-selected\n >\n <span>{item}</span>\n <button\n {...props.pt?.remove}\n type='button'\n className={[\n 'cratis-chips-field__remove',\n props.pt?.remove?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='remove'\n data-disabled={props.pt?.remove?.disabled || undefined}\n data-selected\n aria-label={\n typeof props.removeAriaLabel === 'function'\n ? props.removeAriaLabel(item, index)\n : (props.removeAriaLabel ?? `Remove ${item}`)\n }\n onClick={() =>\n props.onChange(\n props.value.filter((_, itemIndex) => itemIndex !== index),\n )\n }\n >\n {icon('remove', '×')}\n </button>\n </span>\n ))}\n <input\n {...props.pt?.input}\n id={accessibility.controlId}\n aria-label={accessibility.ariaLabel}\n aria-describedby={accessibility.ariaDescribedBy}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n commit();\n }\n }}\n placeholder={props.placeholder}\n aria-invalid={props.invalid || undefined}\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-readonly={props.pt?.input?.readOnly || undefined}\n className={['cratis-chips-field__input', props.pt?.input?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='input'\n />\n {accessibility.hiddenError}\n </div>\n );\n};\n\n/** A token input bound to a string array property on an Arc command. */\nexport const ChipsField = asCommandFormField<ChipsFieldComponentProps>(ChipsControl, {\n defaultValue: [],\n});\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,KAA+B,KAAI;IACrD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;AACtC,IAAA,MAAM,IAAI,GAAG,aAAa,EAAE;AAC5B,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EAAE;AAC/C,QAAA,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QACvB,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,YAAY,CAAC;QAC1C,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,kBAAkB,CAAC;AACzD,KAAA,CAAC;IAEF,MAAM,MAAM,GAAG,MAAK;QAChB,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,K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Aa,CAAC,SAAS,EAAA,YAAA,EACf,aAAa,CAAC,SAAS,EAAA,kBAAA,EACjB,aAAa,CAAC,eAAe,EAC/C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,SAAS,EAAE,CAAC,KAAK,KAAI;AACjB,oBAAA,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;wBACvB,KAAK,CAAC,cAAc,EAAE;AACtB,wBAAA,MAAM,EAAE;oBACZ;gBACJ,CAAC,EACD,WAAW,EAAE,KAAK,CAAC,WAAW,EAAA,cAAA,EAChB,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAA,cAAA,EACvC,KAAK,CAAC,OAAO,IAAI,SAAS,EAAA,eAAA,EACzB,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EACrD,SAAS,EAAE,CAAC,2BAA2B,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS;qBAC9D,MAAM,CAAC,OAAO;AACd,qBAAA,IAAI,CAAC,GAAG,CAAC,EAAA,kBAAA,EACG,OAAO,EAAA,CAC1B,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CACxB;AAEd,CAAC;AAGM,MAAM,UAAU,GAAG,kBAAkB,CAA2B,YAAY,EAAE;AACjF,IAAA,YAAY,EAAE,EAAE;AACnB,CAAA;;"}
1
+ {"version":3,"file":"ChipsField.js","sources":["../../../../CommandForm/fields/ChipsField.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 { classNames } from '../../ClassNames/classNames';\nimport { ChipsInput } from './ChipsInput';\nimport { ChipsItem } from './ChipsItem';\nimport { useChipsDraft } from './useChipsDraft';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link ChipsField}. */\nexport interface ChipsParts {\n /** Field wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One selected chip. */\n item?: HTMLAttributes<HTMLSpanElement>;\n /** Chip removal button. */\n remove?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Native draft-value input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n}\n\nconst chipsPartsMatchManifest: ExactPartKeys<ChipsParts, PartsOf<'ChipsField'>> = true;\nvoid chipsPartsMatchManifest;\n\ninterface ChipsFieldComponentProps\n extends WrappedFieldProps<string[]>, FieldAccessibilityProps {\n placeholder?: string;\n max?: number;\n separator?: string;\n addOnBlur?: boolean;\n allowDuplicate?: boolean;\n /** Builds a remove-button label, or supplies one shared localized label. */\n removeAriaLabel?: string | ((item: string, index: number) => string);\n className?: string;\n pt?: ChipsParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\nconst ChipsControl = (props: ChipsFieldComponentProps) => {\n const { draft, setDraft, commit } = useChipsDraft(props);\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'],\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n\n return (\n <div\n {...props.pt?.root}\n className={classNames(\n 'cratis-chips-field',\n 'cratis:w-full',\n props.pt?.root?.className,\n props.className,\n )}\n onBlur={(event) => {\n props.onBlur?.();\n if (props.addOnBlur && !event.currentTarget.contains(event.relatedTarget))\n commit();\n }}\n data-cratis-part='root'\n data-cratis-component='ChipsField'\n data-disabled={props.pt?.input?.disabled || undefined}\n data-invalid={props.invalid || undefined}\n data-readonly={props.pt?.input?.readOnly || undefined}\n >\n {props.value.map((item, index) => (\n <ChipsItem\n key={`${item}-${index}`}\n item={item}\n index={index}\n removeAriaLabel={props.removeAriaLabel}\n parts={props.pt}\n onRemove={() =>\n props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index))\n }\n />\n ))}\n <ChipsInput\n id={accessibility.controlId}\n ariaLabel={accessibility.ariaLabel}\n ariaDescribedBy={accessibility.ariaDescribedBy}\n draft={draft}\n onDraftChange={setDraft}\n onCommit={commit}\n placeholder={props.placeholder}\n invalid={props.invalid}\n parts={props.pt}\n />\n {accessibility.hiddenError}\n </div>\n );\n};\n\n/** A token input bound to a string array property on an Arc command. */\nexport const ChipsField = asCommandFormField<ChipsFieldComponentProps>(ChipsControl, {\n defaultValue: [],\n});\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AA8CA,MAAM,YAAY,GAAG,CAAC,KAA+B,KAAI;AACrD,IAAA,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC;AACxD,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EAAE;AAC/C,QAAA,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QACvB,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,YAAY,CAAC;QAC1C,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,kBAAkB,CAAC;AACzD,KAAA,CAAC;AAEF,IAAA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAA,GACQ,KAAK,CAAC,EAAE,EAAE,IAAI,EAClB,SAAS,EAAE,UAAU,CACjB,oBAAoB,EACpB,eAAe,EACf,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EACzB,KAAK,CAAC,SAAS,CAClB,EACD,MAAM,EAAE,CAAC,KAAK,KAAI;AACd,YAAA,KAAK,CAAC,MAAM,IAAI;AAChB,YAAA,IAAI,KAAK,CAAC,SAAS,IAAI,CA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B,CAAA;;"}
@@ -0,0 +1,18 @@
1
+ import type { ChipsParts } from './ChipsField.js';
2
+ /** Props for {@link ChipsInput}. */
3
+ export interface ChipsInputProps {
4
+ id?: string;
5
+ ariaLabel?: string;
6
+ ariaDescribedBy?: string;
7
+ draft: string;
8
+ onDraftChange: (draft: string) => void;
9
+ /** Called when Enter is pressed in the input. */
10
+ onCommit: () => void;
11
+ placeholder?: string;
12
+ invalid?: boolean;
13
+ /** The field's part attributes. */
14
+ parts?: ChipsParts;
15
+ }
16
+ /** The native draft-value input of a chips field. */
17
+ export declare const ChipsInput: ({ id, ariaLabel, ariaDescribedBy, draft, onDraftChange, onCommit, placeholder, invalid, parts: pt, }: ChipsInputProps) => import("react").JSX.Element;
18
+ //# sourceMappingURL=ChipsInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipsInput.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ChipsInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE/C,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iDAAiD;IACjD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,qDAAqD;AACrD,eAAO,MAAM,UAAU,yGAUpB,eAAe,gCAsBjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { classNames } from '../../ClassNames/classNames.js';
3
+
4
+ const ChipsInput = ({ id, ariaLabel, ariaDescribedBy, draft, onDraftChange, onCommit, placeholder, invalid, parts: pt, }) => (jsx("input", { ...pt?.input, id: id, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, value: draft, onChange: (event) => onDraftChange(event.target.value), onKeyDown: (event) => {
5
+ if (event.key === 'Enter') {
6
+ event.preventDefault();
7
+ onCommit();
8
+ }
9
+ }, placeholder: placeholder, "aria-invalid": invalid || undefined, "data-disabled": pt?.input?.disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": pt?.input?.readOnly || undefined, className: classNames('cratis-chips-field__input', pt?.input?.className), "data-cratis-part": 'input' }));
10
+
11
+ export { ChipsInput };
12
+ //# sourceMappingURL=ChipsInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipsInput.js","sources":["../../../../CommandForm/fields/ChipsInput.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 { classNames } from '../../ClassNames/classNames';\nimport type { ChipsParts } from './ChipsField';\n\n/** Props for {@link ChipsInput}. */\nexport interface ChipsInputProps {\n id?: string;\n ariaLabel?: string;\n ariaDescribedBy?: string;\n draft: string;\n onDraftChange: (draft: string) => void;\n /** Called when Enter is pressed in the input. */\n onCommit: () => void;\n placeholder?: string;\n invalid?: boolean;\n /** The field's part attributes. */\n parts?: ChipsParts;\n}\n\n/** The native draft-value input of a chips field. */\nexport const ChipsInput = ({\n id,\n ariaLabel,\n ariaDescribedBy,\n draft,\n onDraftChange,\n onCommit,\n placeholder,\n invalid,\n parts: pt,\n}: ChipsInputProps) => (\n <input\n {...pt?.input}\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n value={draft}\n onChange={(event) => onDraftChange(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n onCommit();\n }\n }}\n placeholder={placeholder}\n aria-invalid={invalid || undefined}\n data-disabled={pt?.input?.disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={pt?.input?.readOnly || undefined}\n className={classNames('cratis-chips-field__input', pt?.input?.className)}\n data-cratis-part='input'\n />\n);\n"],"names":["_jsx"],"mappings":";;;AAsBO,MAAM,UAAU,GAAG,CAAC,EACvB,EAAE,EACF,SAAS,EACT,eAAe,EACf,KAAK,EACL,aAAa,EACb,QAAQ,EACR,WAAW,EACX,OAAO,EACP,KAAK,EAAE,EAAE,GACK,MACdA,GAAA,CAAA,OAAA,EAAA,EAAA,GACQ,EAAE,EAAE,KAAK,EACb,EAAE,EAAE,EAAE,EAAA,YAAA,EACM,SAAS,sBACH,eAAe,EACjC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,KAAK,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,SAAS,EAAE,CAAC,KAAK,KAAI;AACjB,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE;YACvB,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,QAAQ,EAAE;QACd;IACJ,CAAC,EACD,WAAW,EAAE,WAAW,kBACV,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,kBACjC,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAC/C,SAAS,EAAE,UAAU,CAAC,2BAA2B,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EACvD,OAAO,EAAA,CAC1B;;"}
@@ -0,0 +1,14 @@
1
+ import type { ChipsParts } from './ChipsField.js';
2
+ /** Props for {@link ChipsItem}. */
3
+ export interface ChipsItemProps {
4
+ item: string;
5
+ index: number;
6
+ /** Builds a remove-button label, or supplies one shared localized label. */
7
+ removeAriaLabel?: string | ((item: string, index: number) => string);
8
+ /** The field's part attributes. */
9
+ parts?: ChipsParts;
10
+ onRemove: () => void;
11
+ }
12
+ /** One selected chip with its remove button. */
13
+ export declare const ChipsItem: ({ item, index, removeAriaLabel, parts: pt, onRemove }: ChipsItemProps) => import("react").JSX.Element;
14
+ //# sourceMappingURL=ChipsItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipsItem.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ChipsItem.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE/C,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IACrE,mCAAmC;IACnC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AASD,gDAAgD;AAChD,eAAO,MAAM,SAAS,0DAA2D,cAAc,gCAwB9F,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { classNames } from '../../ClassNames/classNames.js';
3
+ import { useCratisIcon } from '../../configuration/useCratisIcon.js';
4
+
5
+ const removeLabel = ({ item, index, removeAriaLabel }) => typeof removeAriaLabel === 'function'
6
+ ? removeAriaLabel(item, index)
7
+ : (removeAriaLabel ?? `Remove ${item}`);
8
+ const ChipsItem = ({ item, index, removeAriaLabel, parts: pt, onRemove }) => {
9
+ const icon = useCratisIcon();
10
+ return (jsxs("span", { ...pt?.item, className: classNames('cratis-chips-field__item', pt?.item?.className), "data-cratis-part": 'item', "data-selected": true, children: [jsx("span", { children: item }), jsx("button", { ...pt?.remove, type: 'button', className: classNames('cratis-chips-field__remove', pt?.remove?.className), "data-cratis-part": 'remove', "data-disabled": pt?.remove?.disabled || undefined, "data-selected": true, "aria-label": removeLabel({ item, index, removeAriaLabel }), onClick: onRemove, children: icon('remove', '×') })] }));
11
+ };
12
+
13
+ export { ChipsItem };
14
+ //# sourceMappingURL=ChipsItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChipsItem.js","sources":["../../../../CommandForm/fields/ChipsItem.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 { classNames } from '../../ClassNames/classNames';\nimport { useCratisIcon } from '../../configuration/useCratisIcon';\nimport type { ChipsParts } from './ChipsField';\n\n/** Props for {@link ChipsItem}. */\nexport interface ChipsItemProps {\n item: string;\n index: number;\n /** Builds a remove-button label, or supplies one shared localized label. */\n removeAriaLabel?: string | ((item: string, index: number) => string);\n /** The field's part attributes. */\n parts?: ChipsParts;\n onRemove: () => void;\n}\n\nconst removeLabel = (\n { item, index, removeAriaLabel }: Pick<ChipsItemProps, 'item' | 'index' | 'removeAriaLabel'>,\n) =>\n typeof removeAriaLabel === 'function'\n ? removeAriaLabel(item, index)\n : (removeAriaLabel ?? `Remove ${item}`);\n\n/** One selected chip with its remove button. */\nexport const ChipsItem = ({ item, index, removeAriaLabel, parts: pt, onRemove }: ChipsItemProps) => {\n const icon = useCratisIcon();\n return (\n <span\n {...pt?.item}\n className={classNames('cratis-chips-field__item', pt?.item?.className)}\n data-cratis-part='item'\n data-selected\n >\n <span>{item}</span>\n <button\n {...pt?.remove}\n type='button'\n className={classNames('cratis-chips-field__remove', pt?.remove?.className)}\n data-cratis-part='remove'\n data-disabled={pt?.remove?.disabled || undefined}\n data-selected\n aria-label={removeLabel({ item, index, removeAriaLabel })}\n onClick={onRemove}\n >\n {icon('remove', '×')}\n </button>\n </span>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAkBA,MAAM,WAAW,GAAG,CAChB,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAA8D,KAE5F,OAAO,eAAe,KAAK;AACvB,MAAE,eAAe,CAAC,IAAI,EAAE,KAAK;OAC1B,eAAe,IAAI,UAAU,IAAI,CAAA,CAAE,CAAC;AAGxC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAkB,KAAI;AAC/F,IAAA,MAAM,IAAI,GAAG,aAAa,EAAE;AAC5B,IAAA,QACIA,IAAA,CAAA,MAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,UAAU,CAAC,0BAA0B,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAA,kBAAA,EACrD,MAAM,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAGvBC,wBAAO,IAAI,EAAA,CAAQ,EACnBA,GAAA,CAAA,QAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EACzD,QAAQ,EAAA,eAAA,EACV,EAAE,EAAE,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAA,eAAA,EAAA,IAAA,EAAA,YAAA,EAEpC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,EACzD,OAAO,EAAE,QAAQ,EAAA,QAAA,EAEhB,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAA,CACf,CAAA,EAAA,CACN;AAEf;;"}
@@ -0,0 +1,19 @@
1
+ /** What {@link useChipsDraft} needs from the field. */
2
+ export interface ChipsDraftSource {
3
+ value: string[];
4
+ onChange: (value: string[]) => void;
5
+ separator?: string;
6
+ max?: number;
7
+ allowDuplicate?: boolean;
8
+ }
9
+ /**
10
+ * Holds the text being typed into a chips field and turns it into chips on commit.
11
+ * @param source The field value and the rules for adding to it.
12
+ * @returns The draft text, its setter, and the commit action.
13
+ */
14
+ export declare const useChipsDraft: ({ value, onChange, separator, max, allowDuplicate }: ChipsDraftSource) => {
15
+ draft: string;
16
+ setDraft: import("react").Dispatch<import("react").SetStateAction<string>>;
17
+ commit: () => void;
18
+ };
19
+ //# sourceMappingURL=useChipsDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChipsDraft.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/useChipsDraft.ts"],"names":[],"mappings":"AAMA,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,wDAAyD,gBAAgB;;;;CAalG,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { useState } from 'react';
2
+ import { appendChipCandidates } from './chipValues.js';
3
+
4
+ const useChipsDraft = ({ value, onChange, separator, max, allowDuplicate }) => {
5
+ const [draft, setDraft] = useState('');
6
+ const commit = () => {
7
+ const candidates = (separator ? draft.split(separator) : [draft])
8
+ .map((candidate) => candidate.trim())
9
+ .filter(Boolean);
10
+ if (candidates.length === 0)
11
+ return;
12
+ onChange(appendChipCandidates(value, candidates, max, allowDuplicate ?? false));
13
+ setDraft('');
14
+ };
15
+ return { draft, setDraft, commit };
16
+ };
17
+
18
+ export { useChipsDraft };
19
+ //# sourceMappingURL=useChipsDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChipsDraft.js","sources":["../../../../CommandForm/fields/useChipsDraft.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 { useState } from 'react';\nimport { appendChipCandidates } from './chipValues';\n\n/** What {@link useChipsDraft} needs from the field. */\nexport interface ChipsDraftSource {\n value: string[];\n onChange: (value: string[]) => void;\n separator?: string;\n max?: number;\n allowDuplicate?: boolean;\n}\n\n/**\n * Holds the text being typed into a chips field and turns it into chips on commit.\n * @param source The field value and the rules for adding to it.\n * @returns The draft text, its setter, and the commit action.\n */\nexport const useChipsDraft = ({ value, onChange, separator, max, allowDuplicate }: ChipsDraftSource) => {\n const [draft, setDraft] = useState('');\n\n const commit = () => {\n const candidates = (separator ? draft.split(separator) : [draft])\n .map((candidate) => candidate.trim())\n .filter(Boolean);\n if (candidates.length === 0) return;\n onChange(appendChipCandidates(value, candidates, max, allowDuplicate ?? false));\n setDraft('');\n };\n\n return { draft, setDraft, commit };\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,aAAa,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,EAAoB,KAAI;IACnG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC;IAEtC,MAAM,MAAM,GAAG,MAAK;AAChB,QAAA,MAAM,UAAU,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;aAC3D,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,EAAE;aACnC,MAAM,CAAC,OAAO,CAAC;AACpB,QAAA,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE;AAC7B,QAAA,QAAQ,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc,IAAI,KAAK,CAAC,CAAC;QAC/E,QAAQ,CAAC,EAAE,CAAC;AAChB,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE;AACtC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CratisComponentsProvider.d.ts","sourceRoot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,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACnC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;IAC9C;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,2BAA2B;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,UAC7B,sBAAsB,GAAG,SAAS,KAC1C,sBAIF,CAAC;AAWF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,kIAUlC,6BAA6B,gCA+B/B,CAAC"}
@@ -8,6 +8,7 @@ import { unstable_RendererRoot } from '../renderer/RendererContext.js';
8
8
  import { CratisComponentsContext } from '../configuration/CratisComponentsContext.js';
9
9
  export { useCratisComponentsConfig } from '../configuration/CratisComponentsContext.js';
10
10
  import { cratisDefaults } from '../configuration/CratisComponentsDefaults.js';
11
+ import { withLegacyLocaleMessages } from './legacyLocaleMessages.js';
11
12
 
12
13
  const RendererRoot = unstable_RendererRoot;
13
14
  const mergeCratisComponentsConfig = (value) => {
@@ -15,50 +16,6 @@ const mergeCratisComponentsConfig = (value) => {
15
16
  const merged = merge(cratisDefaults, rest);
16
17
  return icons ? { ...merged, icons: { ...cratisDefaults.icons, ...icons } } : merged;
17
18
  };
18
- const withLegacyLocaleMessages = (config, explicitMessages) => {
19
- const legacy = config.locale ? config.locales?.[config.locale] : undefined;
20
- if (!legacy)
21
- return config;
22
- return {
23
- ...config,
24
- messages: {
25
- ...config.messages,
26
- paginator: {
27
- ...config.messages?.paginator,
28
- navigation: explicitMessages?.paginator?.navigation ??
29
- legacy.aria?.navigation ??
30
- config.messages?.paginator?.navigation,
31
- first: explicitMessages?.paginator?.first ??
32
- legacy.aria?.firstPageLabel ??
33
- config.messages?.paginator?.first,
34
- previous: explicitMessages?.paginator?.previous ??
35
- legacy.aria?.prevPageLabel ??
36
- config.messages?.paginator?.previous,
37
- next: explicitMessages?.paginator?.next ??
38
- legacy.aria?.nextPageLabel ??
39
- config.messages?.paginator?.next,
40
- last: explicitMessages?.paginator?.last ??
41
- legacy.aria?.lastPageLabel ??
42
- config.messages?.paginator?.last,
43
- },
44
- datePicker: {
45
- ...config.messages?.datePicker,
46
- today: explicitMessages?.datePicker?.today ??
47
- legacy.today ??
48
- config.messages?.datePicker?.today,
49
- clear: explicitMessages?.datePicker?.clear ??
50
- legacy.clear ??
51
- config.messages?.datePicker?.clear,
52
- openCalendar: explicitMessages?.datePicker?.openCalendar ??
53
- config.messages?.datePicker?.openCalendar,
54
- previousMonth: explicitMessages?.datePicker?.previousMonth ??
55
- config.messages?.datePicker?.previousMonth,
56
- nextMonth: explicitMessages?.datePicker?.nextMonth ??
57
- config.messages?.datePicker?.nextMonth,
58
- },
59
- },
60
- };
61
- };
62
19
  const validLocale = (locale) => {
63
20
  if (!locale)
64
21
  return 'en-US';