@cratis/components 4.42.1 → 4.42.3
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 +11 -11
- package/dist/esm/Canvas/Canvas.d.ts.map +1 -1
- package/dist/esm/Canvas/Canvas.js +16 -109
- package/dist/esm/Canvas/Canvas.js.map +1 -1
- package/dist/esm/Canvas/CanvasWorldLayers.d.ts +22 -0
- package/dist/esm/Canvas/CanvasWorldLayers.d.ts.map +1 -0
- package/dist/esm/Canvas/CanvasWorldLayers.js +27 -0
- package/dist/esm/Canvas/CanvasWorldLayers.js.map +1 -0
- package/dist/esm/Canvas/useCanvasSurface.d.ts +57 -0
- package/dist/esm/Canvas/useCanvasSurface.d.ts.map +1 -0
- package/dist/esm/Canvas/useCanvasSurface.js +112 -0
- package/dist/esm/Canvas/useCanvasSurface.js.map +1 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts +9 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js +19 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js.map +1 -0
- package/dist/esm/Chat/ChatTopicList.d.ts +2 -2
- package/dist/esm/Chat/ChatTopicList.d.ts.map +1 -1
- package/dist/esm/Chat/ChatTopicList.js +5 -20
- package/dist/esm/Chat/ChatTopicList.js.map +1 -1
- package/dist/esm/Chat/ChatTopicRow.d.ts +22 -0
- package/dist/esm/Chat/ChatTopicRow.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicRow.js +23 -0
- package/dist/esm/Chat/ChatTopicRow.js.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts +8 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.js +7 -0
- package/dist/esm/Chat/ChatTopicStartButton.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperContent.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperContent.js +31 -119
- package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperList.d.ts +19 -0
- package/dist/esm/CommandDialog/CommandStepperList.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperList.js +20 -0
- package/dist/esm/CommandDialog/CommandStepperList.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts +20 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.js +15 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.d.ts +20 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.js +9 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts +23 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.js +9 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.js.map +1 -0
- package/dist/esm/CommandDialog/commandStepperFields.d.ts +6 -0
- package/dist/esm/CommandDialog/commandStepperFields.d.ts.map +1 -0
- package/dist/esm/CommandDialog/commandStepperFields.js +54 -0
- package/dist/esm/CommandDialog/commandStepperFields.js.map +1 -0
- package/dist/esm/CommandDialog/joinClassNames.d.ts +3 -0
- package/dist/esm/CommandDialog/joinClassNames.d.ts.map +1 -0
- package/dist/esm/CommandDialog/joinClassNames.js +4 -0
- package/dist/esm/CommandDialog/joinClassNames.js.map +1 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.d.ts +20 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.d.ts.map +1 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.js +8 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.js.map +1 -0
- package/dist/esm/CommandDialog/useStepValidation.d.ts +7 -0
- package/dist/esm/CommandDialog/useStepValidation.d.ts.map +1 -0
- package/dist/esm/CommandDialog/useStepValidation.js +14 -0
- package/dist/esm/CommandDialog/useStepValidation.js.map +1 -0
- package/dist/esm/CommandDialog/useStepperState.d.ts +30 -0
- package/dist/esm/CommandDialog/useStepperState.d.ts.map +1 -0
- package/dist/esm/CommandDialog/useStepperState.js +37 -0
- package/dist/esm/CommandDialog/useStepperState.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsField.d.ts +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js +6 -42
- package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsInput.d.ts +18 -0
- package/dist/esm/CommandForm/fields/ChipsInput.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsInput.js +12 -0
- package/dist/esm/CommandForm/fields/ChipsInput.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsItem.d.ts +14 -0
- package/dist/esm/CommandForm/fields/ChipsItem.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsItem.js +14 -0
- package/dist/esm/CommandForm/fields/ChipsItem.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js +11 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.js +4 -14
- package/dist/esm/CommandForm/fields/PasswordField.js.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts +17 -0
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts +13 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js +9 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js.map +1 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.d.ts +19 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.js +19 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.js.map +1 -0
- package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
- package/dist/esm/Common/CratisComponentsProvider.js +1 -44
- package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
- package/dist/esm/Common/legacyLocaleMessages.d.ts +7 -0
- package/dist/esm/Common/legacyLocaleMessages.d.ts.map +1 -0
- package/dist/esm/Common/legacyLocaleMessages.js +43 -0
- package/dist/esm/Common/legacyLocaleMessages.js.map +1 -0
- package/dist/esm/DataTables/DataTableCore.d.ts +1 -1
- package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableCore.js +12 -66
- package/dist/esm/DataTables/DataTableCore.js.map +1 -1
- package/dist/esm/DataTables/DataTableHead.d.ts +23 -0
- package/dist/esm/DataTables/DataTableHead.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableHead.js +12 -0
- package/dist/esm/DataTables/DataTableHead.js.map +1 -0
- package/dist/esm/DataTables/DataTableRows.d.ts +19 -0
- package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableRows.js +7 -0
- package/dist/esm/DataTables/DataTableRows.js.map +1 -0
- package/dist/esm/DataTables/DataTableTable.d.ts +20 -0
- package/dist/esm/DataTables/DataTableTable.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableTable.js +10 -0
- package/dist/esm/DataTables/DataTableTable.js.map +1 -0
- package/dist/esm/DataTables/TablePaginatorImplementation.js +1 -1
- package/dist/esm/DataTables/useDataTableRows.d.ts +40 -0
- package/dist/esm/DataTables/useDataTableRows.d.ts.map +1 -0
- package/dist/esm/DataTables/useDataTableRows.js +49 -0
- package/dist/esm/DataTables/useDataTableRows.js.map +1 -0
- package/dist/esm/Dialogs/DialogImplementation.js +1 -1
- package/dist/esm/Dropdown/useDropdownState.js +1 -1
- package/dist/esm/Filter/FilterPanel.d.ts +69 -0
- package/dist/esm/Filter/FilterPanel.d.ts.map +1 -1
- package/dist/esm/Filter/FilterPanel.js +6 -21
- package/dist/esm/Filter/FilterPanel.js.map +1 -1
- package/dist/esm/Filter/FilterPanelContent.d.ts +14 -0
- package/dist/esm/Filter/FilterPanelContent.d.ts.map +1 -0
- package/dist/esm/Filter/FilterPanelContent.js +8 -0
- package/dist/esm/Filter/FilterPanelContent.js.map +1 -0
- package/dist/esm/Filter/usePortalTarget.d.ts +13 -0
- package/dist/esm/Filter/usePortalTarget.d.ts.map +1 -0
- package/dist/esm/Filter/usePortalTarget.js +24 -0
- package/dist/esm/Filter/usePortalTarget.js.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts +11 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.js +14 -0
- package/dist/esm/Notifications/ToastCloseButton.js.map +1 -0
- package/dist/esm/Notifications/ToastContent.d.ts +10 -0
- package/dist/esm/Notifications/ToastContent.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastContent.js +7 -0
- package/dist/esm/Notifications/ToastContent.js.map +1 -0
- package/dist/esm/Notifications/Toaster.d.ts.map +1 -1
- package/dist/esm/Notifications/Toaster.js +8 -17
- package/dist/esm/Notifications/Toaster.js.map +1 -1
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts +4 -0
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts.map +1 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js +20 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js.map +1 -0
- package/dist/esm/PivotViewer/PivotViewer.d.ts +1 -1
- package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +24 -31
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts +40 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts.map +1 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js +13 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts +37 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js +35 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js.map +1 -0
- package/dist/esm/TimeMachine/EventCard.d.ts +9 -0
- package/dist/esm/TimeMachine/EventCard.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventCard.js +8 -0
- package/dist/esm/TimeMachine/EventCard.js.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts +11 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.js +7 -0
- package/dist/esm/TimeMachine/EventSeparator.js.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts +14 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js +9 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts +10 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js +6 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js.map +1 -0
- package/dist/esm/TimeMachine/EventsView.d.ts +1 -1
- package/dist/esm/TimeMachine/EventsView.d.ts.map +1 -1
- package/dist/esm/TimeMachine/EventsView.js +6 -39
- package/dist/esm/TimeMachine/EventsView.js.map +1 -1
- package/dist/esm/TimeMachine/useScrollEdges.d.ts +13 -0
- package/dist/esm/TimeMachine/useScrollEdges.d.ts.map +1 -0
- package/dist/esm/TimeMachine/useScrollEdges.js +40 -0
- package/dist/esm/TimeMachine/useScrollEdges.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarFolder.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperList.js","sources":["../../../CommandDialog/CommandStepperList.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 React from 'react';\nimport type { StepperPanelProps } from './StepperPanel';\nimport { joinClassNames } from './joinClassNames';\nimport { StepNumber, StepSeparator, StepTitle, type StepPartProps, type StepperPt } from './CommandStepperStepParts';\n\ninterface CommandStepperListProps {\n panels: React.ReactElement<StepperPanelProps>[];\n currentStep: number;\n visitedSteps: Set<number>;\n stepErrors: boolean[];\n linear: boolean;\n stepperId: string;\n isBusy: boolean;\n hasAnyStepErrors: boolean;\n pt: StepperPt;\n onHeaderClick: (index: number) => void;\n}\n\ninterface StepProps extends StepPartProps {\n panel: React.ReactElement<StepperPanelProps>;\n index: number;\n isLast: boolean;\n headerDisabled: boolean;\n stepperId: string;\n onHeaderClick: (index: number) => void;\n}\n\nconst headerIdOf = (pt: StepperPt, stepperId: string, index: number) =>\n pt?.header?.id ?? `${stepperId}-step-${index}`;\n\nconst StepHeader = ({ panel, index, headerDisabled, stepperId, onHeaderClick, ...part }: Omit<StepProps, 'isLast'>) => {\n const { pt, selected, visited, invalid, isBusy } = part;\n return (\n <button\n {...pt?.header}\n type='button'\n id={headerIdOf(pt, stepperId, index)}\n className={joinClassNames('cratis-command-stepper__header', pt?.header?.className)}\n data-cratis-part='header'\n data-part='header'\n data-busy={isBusy || undefined}\n data-disabled={headerDisabled || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n disabled={headerDisabled}\n aria-current={selected ? 'step' : undefined}\n onClick={() => onHeaderClick(index)}\n >\n <StepNumber {...part} index={index} />\n <StepTitle {...part} header={panel.props.header} />\n </button>\n );\n};\n\nconst CommandStepperStep = ({ isLast, ...header }: StepProps) => {\n const { pt, selected, visited, invalid, isBusy } = header;\n return (\n <li\n {...pt?.step}\n className={joinClassNames('cratis-command-stepper__step', pt?.step?.className)}\n data-cratis-part='step'\n data-part='step'\n data-active={selected || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n data-invalid={invalid || undefined}\n data-busy={isBusy || undefined}\n >\n <StepHeader {...header} />\n <StepSeparator pt={pt} selected={selected} visited={visited} invalid={invalid} isBusy={isBusy} isLast={isLast} />\n </li>\n );\n};\n\n/** The step header list of the stepper. */\nexport const CommandStepperList = ({\n panels,\n currentStep,\n visitedSteps,\n stepErrors,\n linear,\n stepperId,\n isBusy,\n hasAnyStepErrors,\n pt,\n onHeaderClick,\n}: CommandStepperListProps) => (\n <ol\n {...pt?.list}\n className={joinClassNames('cratis-command-stepper__list', pt?.list?.className)}\n data-cratis-part='list'\n data-part='list'\n data-busy={isBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {panels.map((panel, index) => {\n const selected = index === currentStep;\n return (\n <CommandStepperStep\n key={index}\n panel={panel}\n index={index}\n isLast={index >= panels.length - 1}\n selected={selected}\n visited={visitedSteps.has(index)}\n invalid={stepErrors[index] ?? false}\n headerDisabled={linear && !selected}\n stepperId={stepperId}\n isBusy={isBusy}\n pt={pt}\n onHeaderClick={onHeaderClick}\n />\n );\n })}\n </ol>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA8BA,MAAM,UAAU,GAAG,CAAC,EAAa,EAAE,SAAiB,EAAE,KAAa,KAC/D,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,GAAG,SAAS,CAAA,MAAA,EAAS,KAAK,CAAA,CAAE;AAElD,MAAM,UAAU,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,EAA6B,KAAI;AAClH,IAAA,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IACvD,QACIA,oBACQ,EAAE,EAAE,MAAM,EACd,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,EACpC,SAAS,EAAE,cAAc,CAAC,gCAAgC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EACjE,QAAQ,EAAA,WAAA,EACf,QAAQ,EAAA,WAAA,EACP,MAAM,IAAI,SAAS,EAAA,eAAA,EACf,cAAc,IAAI,SAAS,EAAA,cAAA,EAC5B,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,QAAQ,IAAI,SAAS,kBACtB,OAAO,IAAI,SAAS,EAClC,QAAQ,EAAE,cAAc,EAAA,cAAA,EACV,QAAQ,GAAG,MAAM,GAAG,SAAS,EAC3C,OAAO,EAAE,MAAM,aAAa,CAAC,KAAK,CAAC,aAEnCC,GAAA,CAAC,UAAU,EAAA,EAAA,GAAK,IAAI,EAAE,KAAK,EAAE,KAAK,EAAA,CAAI,EACtCA,GAAA,CAAC,SAAS,EAAA,EAAA,GAAK,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAA,CAAI,CAAA,EAAA,CAC9C;AAEjB,CAAC;AAED,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAa,KAAI;AAC5D,IAAA,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM;AACzD,IAAA,QACID,IAAA,CAAA,IAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,cAAc,CAAC,8BAA8B,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC7D,MAAM,eACb,MAAM,EAAA,aAAA,EACH,QAAQ,IAAI,SAAS,EAAA,eAAA,EACnB,QAAQ,IAAI,SAAS,kBACtB,OAAO,IAAI,SAAS,EAAA,cAAA,EACpB,OAAO,IAAI,SAAS,EAAA,WAAA,EACvB,MAAM,IAAI,SAAS,EAAA,QAAA,EAAA,CAE9BC,GAAA,CAAC,UAAU,EAAA,EAAA,GAAK,MAAM,EAAA,CAAI,EAC1BA,GAAA,CAAC,aAAa,IAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAA,CAAI,CAAA,EAAA,CAChH;AAEb,CAAC;AAGM,MAAM,kBAAkB,GAAG,CAAC,EAC/B,MAAM,EACN,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,EAAE,EACF,aAAa,GACS,MACtBA,GAAA,CAAA,IAAA,EAAA,EAAA,GACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,cAAc,CAAC,8BAA8B,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC7D,MAAM,eACb,MAAM,EAAA,WAAA,EACL,MAAM,IAAI,SAAS,EAAA,cAAA,EAChB,gBAAgB,IAAI,SAAS,EAAA,QAAA,EAE1C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAI;AACzB,QAAA,MAAM,QAAQ,GAAG,KAAK,KAAK,WAAW;AACtC,QAAA,QACIA,GAAA,CAAC,kBAAkB,EAAA,EAEf,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAClC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAChC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,EACnC,cAAc,EAAE,MAAM,IAAI,CAAC,QAAQ,EACnC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,EAAE,EACN,aAAa,EAAE,aAAa,EAAA,EAXvB,KAAK,CAYZ;IAEV,CAAC,CAAC,EAAA,CACD;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface CommandStepperNavigationProps {
|
|
2
|
+
isFirstStep: boolean;
|
|
3
|
+
isLastStep: boolean;
|
|
4
|
+
showSubmit: boolean;
|
|
5
|
+
isBusy: boolean;
|
|
6
|
+
isSubmitting: boolean;
|
|
7
|
+
isSubmitDisabled: boolean;
|
|
8
|
+
isCurrentStepInvalid: boolean;
|
|
9
|
+
hasAnyStepErrors: boolean;
|
|
10
|
+
previousLabel: string;
|
|
11
|
+
nextLabel: string;
|
|
12
|
+
okLabel: string;
|
|
13
|
+
onPrevious: () => void;
|
|
14
|
+
onNext: () => void;
|
|
15
|
+
onSubmit?: () => void | Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** The built-in Previous / Next / Submit buttons of the stepper. */
|
|
18
|
+
export declare const CommandStepperNavigation: ({ isFirstStep, isLastStep, showSubmit, isBusy, isSubmitting, isSubmitDisabled, isCurrentStepInvalid, hasAnyStepErrors, previousLabel, nextLabel, okLabel, onPrevious, onNext, onSubmit, }: CommandStepperNavigationProps) => import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=CommandStepperNavigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperNavigation.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepperNavigation.tsx"],"names":[],"mappings":"AAKA,UAAU,6BAA6B;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC;AAED,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,8LAelC,6BAA6B,gCAmD/B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Button } from '../Common/Button.js';
|
|
3
|
+
|
|
4
|
+
const CommandStepperNavigation = ({ isFirstStep, isLastStep, showSubmit, isBusy, isSubmitting, isSubmitDisabled, isCurrentStepInvalid, hasAnyStepErrors, previousLabel, nextLabel, okLabel, onPrevious, onNext, onSubmit, }) => (jsxs("div", { style: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
width: '100%',
|
|
8
|
+
gap: '0.75rem',
|
|
9
|
+
}, children: [!isFirstStep && (jsx(Button, { variant: 'outline', onClick: onPrevious, disabled: isBusy, style: { width: 'auto' }, children: jsx("span", { children: previousLabel }) })), jsx("div", { style: { flex: 1 } }), !isLastStep && (jsx(Button, { onClick: onNext, disabled: isBusy || isSubmitting || isCurrentStepInvalid, style: { width: 'auto' }, children: jsx("span", { children: nextLabel }) })), isLastStep && showSubmit && (jsxs(Button, { onClick: () => void onSubmit?.(), disabled: isBusy ||
|
|
10
|
+
isSubmitting ||
|
|
11
|
+
isSubmitDisabled ||
|
|
12
|
+
hasAnyStepErrors, autoFocus: true, style: { width: 'auto' }, children: [isSubmitting && (jsx("span", { className: 'cratis-dialog__spinner', "aria-hidden": 'true' })), jsx("span", { children: okLabel })] }))] }));
|
|
13
|
+
|
|
14
|
+
export { CommandStepperNavigation };
|
|
15
|
+
//# sourceMappingURL=CommandStepperNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperNavigation.js","sources":["../../../CommandDialog/CommandStepperNavigation.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 { Button } from '../Common/Button';\n\ninterface CommandStepperNavigationProps {\n isFirstStep: boolean;\n isLastStep: boolean;\n showSubmit: boolean;\n isBusy: boolean;\n isSubmitting: boolean;\n isSubmitDisabled: boolean;\n isCurrentStepInvalid: boolean;\n hasAnyStepErrors: boolean;\n previousLabel: string;\n nextLabel: string;\n okLabel: string;\n onPrevious: () => void;\n onNext: () => void;\n onSubmit?: () => void | Promise<void>;\n}\n\n/** The built-in Previous / Next / Submit buttons of the stepper. */\nexport const CommandStepperNavigation = ({\n isFirstStep,\n isLastStep,\n showSubmit,\n isBusy,\n isSubmitting,\n isSubmitDisabled,\n isCurrentStepInvalid,\n hasAnyStepErrors,\n previousLabel,\n nextLabel,\n okLabel,\n onPrevious,\n onNext,\n onSubmit,\n}: CommandStepperNavigationProps) => (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n width: '100%',\n gap: '0.75rem',\n }}\n >\n {!isFirstStep && (\n <Button\n variant='outline'\n onClick={onPrevious}\n disabled={isBusy}\n style={{ width: 'auto' }}\n >\n <span>{previousLabel}</span>\n </Button>\n )}\n <div style={{ flex: 1 }} />\n {!isLastStep && (\n <Button\n onClick={onNext}\n disabled={isBusy || isSubmitting || isCurrentStepInvalid}\n style={{ width: 'auto' }}\n >\n <span>{nextLabel}</span>\n </Button>\n )}\n {isLastStep && showSubmit && (\n <Button\n onClick={() => void onSubmit?.()}\n disabled={\n isBusy ||\n isSubmitting ||\n isSubmitDisabled ||\n hasAnyStepErrors\n }\n autoFocus\n style={{ width: 'auto' }}\n >\n {isSubmitting && (\n <span\n className='cratis-dialog__spinner'\n aria-hidden='true'\n />\n )}\n <span>{okLabel}</span>\n </Button>\n )}\n </div>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;AAuBO,MAAM,wBAAwB,GAAG,CAAC,EACrC,WAAW,EACX,UAAU,EACV,UAAU,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,OAAO,EACP,UAAU,EACV,MAAM,EACN,QAAQ,GACoB,MAC5BA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAE;AACH,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,GAAG,EAAE,SAAS;KACjB,EAAA,QAAA,EAAA,CAEA,CAAC,WAAW,KACTC,IAAC,MAAM,EAAA,EACH,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAExBA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,aAAa,GAAQ,EAAA,CACvB,CACZ,EACDA,GAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAI,EAC1B,CAAC,UAAU,KACRA,GAAA,CAAC,MAAM,EAAA,EACH,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,IAAI,YAAY,IAAI,oBAAoB,EACxD,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAA,QAAA,EAExBA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,SAAS,EAAA,CAAQ,GACnB,CACZ,EACA,UAAU,IAAI,UAAU,KACrBD,IAAA,CAAC,MAAM,EAAA,EACH,OAAO,EAAE,MAAM,KAAK,QAAQ,IAAI,EAChC,QAAQ,EACJ,MAAM;gBACN,YAAY;gBACZ,gBAAgB;AAChB,gBAAA,gBAAgB,EAEpB,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAA,QAAA,EAAA,CAEvB,YAAY,KACTC,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAC,wBAAwB,EAAA,aAAA,EACtB,MAAM,EAAA,CACpB,CACL,EACDA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,OAAO,EAAA,CAAQ,CAAA,EAAA,CACjB,CACZ,CAAA,EAAA,CACC;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StepperCustomizationProps } from './CommandStepper.js';
|
|
3
|
+
import type { StepperPanelProps } from './StepperPanel.js';
|
|
4
|
+
type StepperPt = StepperCustomizationProps['pt'];
|
|
5
|
+
interface CommandStepperPanelsProps {
|
|
6
|
+
panels: React.ReactElement<StepperPanelProps>[];
|
|
7
|
+
currentStep: number;
|
|
8
|
+
visitedSteps: Set<number>;
|
|
9
|
+
stepErrors: boolean[];
|
|
10
|
+
stepperId: string;
|
|
11
|
+
isBusy: boolean;
|
|
12
|
+
hasAnyStepErrors: boolean;
|
|
13
|
+
disableFieldsWhileSubmitting: boolean;
|
|
14
|
+
isSubmitting: boolean;
|
|
15
|
+
pt: StepperPt;
|
|
16
|
+
}
|
|
17
|
+
/** The step panels of the stepper — only the current one is not hidden. */
|
|
18
|
+
export declare const CommandStepperPanels: ({ panels, currentStep, visitedSteps, stepErrors, stepperId, isBusy, hasAnyStepErrors, disableFieldsWhileSubmitting, isSubmitting, pt, }: CommandStepperPanelsProps) => React.JSX.Element;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=CommandStepperPanels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperPanels.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepperPanels.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAIxD,KAAK,SAAS,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;AAEjD,UAAU,yBAAyB;IAC/B,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,4BAA4B,EAAE,OAAO,CAAC;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC;CACjB;AAcD,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,4IAW9B,yBAAyB,sBA8B3B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { processChildren } from './commandStepperFields.js';
|
|
3
|
+
import { joinClassNames } from './joinClassNames.js';
|
|
4
|
+
|
|
5
|
+
const PanelBody = ({ children, locked, isSubmitting }) => locked ? (jsx("fieldset", { disabled: isSubmitting, inert: isSubmitting, style: { display: 'contents' }, children: processChildren(children) })) : jsx(Fragment, { children: processChildren(children) });
|
|
6
|
+
const CommandStepperPanels = ({ panels, currentStep, visitedSteps, stepErrors, stepperId, isBusy, hasAnyStepErrors, disableFieldsWhileSubmitting, isSubmitting, pt, }) => (jsx("div", { ...pt?.panels, className: joinClassNames('cratis-command-stepper__panels', pt?.panels?.className), "data-cratis-part": 'panels', "data-part": 'panels', "data-busy": isBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: panels.map((panel, index) => (jsx("section", { ...pt?.panel, hidden: index !== currentStep, className: joinClassNames('cratis-command-stepper__panel', pt?.panel?.className), "data-cratis-part": 'panel', "data-part": 'panel', "data-busy": isBusy || undefined, "data-invalid": stepErrors[index] || undefined, "data-selected": index === currentStep || undefined, "data-visited": visitedSteps.has(index) || undefined, "aria-label": String(panel.props.header ?? `Step ${index + 1}`), "aria-labelledby": pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined), children: jsx(PanelBody, { locked: disableFieldsWhileSubmitting, isSubmitting: isSubmitting, children: panel.props.children }) }, index))) }));
|
|
7
|
+
|
|
8
|
+
export { CommandStepperPanels };
|
|
9
|
+
//# sourceMappingURL=CommandStepperPanels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperPanels.js","sources":["../../../CommandDialog/CommandStepperPanels.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 React from 'react';\nimport type { StepperCustomizationProps } from './CommandStepper';\nimport type { StepperPanelProps } from './StepperPanel';\nimport { processChildren } from './commandStepperFields';\nimport { joinClassNames } from './joinClassNames';\n\ntype StepperPt = StepperCustomizationProps['pt'];\n\ninterface CommandStepperPanelsProps {\n panels: React.ReactElement<StepperPanelProps>[];\n currentStep: number;\n visitedSteps: Set<number>;\n stepErrors: boolean[];\n stepperId: string;\n isBusy: boolean;\n hasAnyStepErrors: boolean;\n disableFieldsWhileSubmitting: boolean;\n isSubmitting: boolean;\n pt: StepperPt;\n}\n\ninterface PanelBodyProps {\n children: React.ReactNode;\n locked: boolean;\n isSubmitting: boolean;\n}\n\nconst PanelBody = ({ children, locked, isSubmitting }: PanelBodyProps) => locked ? (\n <fieldset disabled={isSubmitting} inert={isSubmitting} style={{ display: 'contents' }}>\n {processChildren(children)}\n </fieldset>\n) : <>{processChildren(children)}</>;\n\n/** The step panels of the stepper — only the current one is not hidden. */\nexport const CommandStepperPanels = ({\n panels,\n currentStep,\n visitedSteps,\n stepErrors,\n stepperId,\n isBusy,\n hasAnyStepErrors,\n disableFieldsWhileSubmitting,\n isSubmitting,\n pt,\n}: CommandStepperPanelsProps) => (\n <div\n {...pt?.panels}\n className={joinClassNames('cratis-command-stepper__panels', pt?.panels?.className)}\n data-cratis-part='panels'\n data-part='panels'\n data-busy={isBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {panels.map((panel, index) => (\n <section\n key={index}\n {...pt?.panel}\n hidden={index !== currentStep}\n className={joinClassNames('cratis-command-stepper__panel', pt?.panel?.className)}\n data-cratis-part='panel'\n data-part='panel'\n data-busy={isBusy || undefined}\n data-invalid={stepErrors[index] || undefined}\n data-selected={index === currentStep || undefined}\n data-visited={visitedSteps.has(index) || undefined}\n aria-label={String(panel.props.header ?? `Step ${index + 1}`)}\n aria-labelledby={pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined)}\n >\n <PanelBody locked={disableFieldsWhileSubmitting} isSubmitting={isSubmitting}>\n {panel.props.children}\n </PanelBody>\n </section>\n ))}\n </div>\n);\n"],"names":["_jsx","_Fragment"],"mappings":";;;;AA8BA,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAkB,KAAK,MAAM,IAC5EA,kBAAU,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EAChF,eAAe,CAAC,QAAQ,CAAC,EAAA,CACnB,IACXA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,eAAe,CAAC,QAAQ,CAAC,EAAA,CAAI;MAGvB,oBAAoB,GAAG,CAAC,EACjC,MAAM,EACN,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,4BAA4B,EAC5B,YAAY,EACZ,EAAE,GACsB,MACxBD,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,cAAc,CAAC,gCAAgC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,sBACjE,QAAQ,EAAA,WAAA,EACf,QAAQ,EAAA,WAAA,EACP,MAAM,IAAI,SAAS,EAAA,cAAA,EAChB,gBAAgB,IAAI,SAAS,YAE1C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,MACrBA,oBAEQ,EAAE,EAAE,KAAK,EACb,MAAM,EAAE,KAAK,KAAK,WAAW,EAC7B,SAAS,EAAE,cAAc,CAAC,+BAA+B,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC/D,OAAO,eACd,OAAO,EAAA,WAAA,EACN,MAAM,IAAI,SAAS,kBAChB,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,EAAA,eAAA,EAC7B,KAAK,KAAK,WAAW,IAAI,SAAS,EAAA,cAAA,EACnC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,gBACtC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,QAAQ,KAAK,GAAG,CAAC,CAAA,CAAE,CAAC,qBAC5C,EAAE,EAAE,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,GAAG,CAAA,EAAG,SAAS,SAAS,KAAK,CAAA,CAAE,GAAG,SAAS,CAAC,EAAA,QAAA,EAEtHA,GAAA,CAAC,SAAS,EAAA,EAAC,MAAM,EAAE,4BAA4B,EAAE,YAAY,EAAE,YAAY,YACtE,KAAK,CAAC,KAAK,CAAC,QAAQ,GACb,EAAA,EAfP,KAAK,CAgBJ,CACb,CAAC,EAAA,CACA;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StepperCustomizationProps } from './CommandStepper.js';
|
|
3
|
+
export type StepperPt = StepperCustomizationProps['pt'];
|
|
4
|
+
export interface StepPartProps {
|
|
5
|
+
pt: StepperPt;
|
|
6
|
+
selected: boolean;
|
|
7
|
+
visited: boolean;
|
|
8
|
+
invalid: boolean;
|
|
9
|
+
isBusy: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The numbered marker of a step. */
|
|
12
|
+
export declare const StepNumber: ({ pt, selected, visited, invalid, isBusy, index }: StepPartProps & {
|
|
13
|
+
index: number;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
/** The title of a step. */
|
|
16
|
+
export declare const StepTitle: ({ pt, selected, visited, invalid, isBusy, header }: StepPartProps & {
|
|
17
|
+
header: React.ReactNode;
|
|
18
|
+
}) => React.JSX.Element;
|
|
19
|
+
/** The connector after a step; absent after the last one. */
|
|
20
|
+
export declare const StepSeparator: ({ pt, visited, invalid, isBusy, isLast }: StepPartProps & {
|
|
21
|
+
isLast: boolean;
|
|
22
|
+
}) => React.JSX.Element | null;
|
|
23
|
+
//# sourceMappingURL=CommandStepperStepParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperStepParts.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepperStepParts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAkB,CAAC;AAGlE,MAAM,MAAM,SAAS,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;AAExD,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,SAAS,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,qCAAqC;AACrC,eAAO,MAAM,UAAU,sDAAuD,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,sBAa9G,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,SAAS,uDAAwD,aAAa,GAAG;IAAE,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAaxH,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,aAAa,6CAA8C,aAAa,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,6BAW1G,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { joinClassNames } from './joinClassNames.js';
|
|
3
|
+
|
|
4
|
+
const StepNumber = ({ pt, selected, visited, invalid, isBusy, index }) => (jsx("span", { ...pt?.number, className: joinClassNames('cratis-command-stepper__number', pt?.number?.className), "data-cratis-part": 'number', "data-part": 'number', "data-busy": isBusy || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, children: index + 1 }));
|
|
5
|
+
const StepTitle = ({ pt, selected, visited, invalid, isBusy, header }) => (jsx("span", { ...pt?.title, className: joinClassNames('cratis-command-stepper__title', pt?.title?.className), "data-cratis-part": 'title', "data-part": 'title', "data-busy": isBusy || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, children: header }));
|
|
6
|
+
const StepSeparator = ({ pt, visited, invalid, isBusy, isLast }) => isLast ? null : (jsx("span", { ...pt?.separator, className: joinClassNames('cratis-command-stepper__separator', pt?.separator?.className), "data-cratis-part": 'separator', "data-part": 'separator', "data-busy": isBusy || undefined, "data-invalid": invalid || undefined, "data-visited": visited || undefined, "aria-hidden": 'true' }));
|
|
7
|
+
|
|
8
|
+
export { StepNumber, StepSeparator, StepTitle };
|
|
9
|
+
//# sourceMappingURL=CommandStepperStepParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandStepperStepParts.js","sources":["../../../CommandDialog/CommandStepperStepParts.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 React from 'react';\nimport type { StepperCustomizationProps } from './CommandStepper';\nimport { joinClassNames } from './joinClassNames';\n\nexport type StepperPt = StepperCustomizationProps['pt'];\n\nexport interface StepPartProps {\n pt: StepperPt;\n selected: boolean;\n visited: boolean;\n invalid: boolean;\n isBusy: boolean;\n}\n\n/** The numbered marker of a step. */\nexport const StepNumber = ({ pt, selected, visited, invalid, isBusy, index }: StepPartProps & { index: number }) => (\n <span\n {...pt?.number}\n className={joinClassNames('cratis-command-stepper__number', pt?.number?.className)}\n data-cratis-part='number'\n data-part='number'\n data-busy={isBusy || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n >\n {index + 1}\n </span>\n);\n\n/** The title of a step. */\nexport const StepTitle = ({ pt, selected, visited, invalid, isBusy, header }: StepPartProps & { header: React.ReactNode }) => (\n <span\n {...pt?.title}\n className={joinClassNames('cratis-command-stepper__title', pt?.title?.className)}\n data-cratis-part='title'\n data-part='title'\n data-busy={isBusy || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n >\n {header}\n </span>\n);\n\n/** The connector after a step; absent after the last one. */\nexport const StepSeparator = ({ pt, visited, invalid, isBusy, isLast }: StepPartProps & { isLast: boolean }) => isLast ? null : (\n <span\n {...pt?.separator}\n className={joinClassNames('cratis-command-stepper__separator', pt?.separator?.className)}\n data-cratis-part='separator'\n data-part='separator'\n data-busy={isBusy || undefined}\n data-invalid={invalid || undefined}\n data-visited={visited || undefined}\n aria-hidden='true'\n />\n);\n"],"names":["_jsx"],"mappings":";;;AAkBO,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAqC,MAC3GA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,EAAE,EAAE,MAAM,EACd,SAAS,EAAE,cAAc,CAAC,gCAAgC,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA,kBAAA,EACjE,QAAQ,EAAA,WAAA,EACf,QAAQ,EAAA,WAAA,EACP,MAAM,IAAI,SAAS,EAAA,cAAA,EAChB,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,QAAQ,IAAI,SAAS,kBACtB,OAAO,IAAI,SAAS,EAAA,QAAA,EAEjC,KAAK,GAAG,CAAC,EAAA,CACP;AAIJ,MAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAA+C,MACrHA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,EAAE,EAAE,KAAK,EACb,SAAS,EAAE,cAAc,CAAC,+BAA+B,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAA,kBAAA,EAC/D,OAAO,EAAA,WAAA,EACd,OAAO,EAAA,WAAA,EACN,MAAM,IAAI,SAAS,EAAA,cAAA,EAChB,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,QAAQ,IAAI,SAAS,EAAA,cAAA,EACtB,OAAO,IAAI,SAAS,EAAA,QAAA,EAEjC,MAAM,EAAA,CACJ;AAIJ,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAuC,KAAK,MAAM,GAAG,IAAI,IACzHA,GAAA,CAAA,MAAA,EAAA,EAAA,GACQ,EAAE,EAAE,SAAS,EACjB,SAAS,EAAE,cAAc,CAAC,mCAAmC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,EAAA,kBAAA,EACvE,WAAW,EAAA,WAAA,EAClB,WAAW,EAAA,WAAA,EACV,MAAM,IAAI,SAAS,EAAA,cAAA,EAChB,OAAO,IAAI,SAAS,EAAA,cAAA,EACpB,OAAO,IAAI,SAAS,EAAA,aAAA,EACtB,MAAM,EAAA,CACpB;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Recursively collects all CommandFormField property names from a React node tree. */
|
|
3
|
+
export declare const extractFieldNamesFromNode: (nodes: React.ReactNode) => string[];
|
|
4
|
+
/** Wraps every CommandFormField in the tree with the Arc field wrapper. */
|
|
5
|
+
export declare const processChildren: (nodes: React.ReactNode) => React.ReactNode;
|
|
6
|
+
//# sourceMappingURL=commandStepperFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandStepperFields.d.ts","sourceRoot":"","sources":["../../../CommandDialog/commandStepperFields.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAmB1B,uFAAuF;AACvF,eAAO,MAAM,yBAAyB,UAAW,KAAK,CAAC,SAAS,KAAG,MAAM,EAexE,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,eAAe,UAAW,KAAK,CAAC,SAAS,KAAG,KAAK,CAAC,SAuB9D,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
4
|
+
import { isCommandFormField } from '../CommandForm/commandFormMarkers.js';
|
|
5
|
+
|
|
6
|
+
const getPropertyName = (accessor) => {
|
|
7
|
+
if (typeof accessor !== 'function')
|
|
8
|
+
return '';
|
|
9
|
+
const fnStr = accessor.toString();
|
|
10
|
+
const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
11
|
+
return match ? match[1] : '';
|
|
12
|
+
};
|
|
13
|
+
const fieldNameOf = (child) => {
|
|
14
|
+
const component = child.type;
|
|
15
|
+
if (!isCommandFormField(component))
|
|
16
|
+
return '';
|
|
17
|
+
const fieldProps = child.props;
|
|
18
|
+
return getPropertyName(fieldProps.value);
|
|
19
|
+
};
|
|
20
|
+
const extractFieldNamesFromNode = (nodes) => {
|
|
21
|
+
const names = [];
|
|
22
|
+
React.Children.forEach(nodes, (child) => {
|
|
23
|
+
if (!React.isValidElement(child))
|
|
24
|
+
return;
|
|
25
|
+
const name = fieldNameOf(child);
|
|
26
|
+
if (name)
|
|
27
|
+
names.push(name);
|
|
28
|
+
const childProps = child.props;
|
|
29
|
+
if (childProps.children != null) {
|
|
30
|
+
names.push(...extractFieldNamesFromNode(childProps.children));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return names;
|
|
34
|
+
};
|
|
35
|
+
const processChildren = (nodes) => {
|
|
36
|
+
return React.Children.map(nodes, (child) => {
|
|
37
|
+
if (!React.isValidElement(child))
|
|
38
|
+
return child;
|
|
39
|
+
const component = child.type;
|
|
40
|
+
if (isCommandFormField(component)) {
|
|
41
|
+
return jsx(CommandFormFieldWrapper, { field: child });
|
|
42
|
+
}
|
|
43
|
+
const childProps = child.props;
|
|
44
|
+
if (childProps.children != null) {
|
|
45
|
+
return React.cloneElement(child, {
|
|
46
|
+
children: processChildren(childProps.children),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return child;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { extractFieldNamesFromNode, processChildren };
|
|
54
|
+
//# sourceMappingURL=commandStepperFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandStepperFields.js","sources":["../../../CommandDialog/commandStepperFields.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 React from 'react';\nimport { CommandFormFieldWrapper } from '@cratis/arc.react/commands';\nimport { isCommandFormField } from '../CommandForm/commandFormMarkers';\n\n/** Extracts the property name from an accessor function like `c => c.name`. */\nconst getPropertyName = (accessor: ((obj: unknown) => unknown) | unknown): string => {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n};\n\nconst fieldNameOf = (child: React.ReactElement): string => {\n const component = child.type as React.ComponentType<unknown>;\n if (!isCommandFormField(component)) return '';\n const fieldProps = child.props as { value?: (obj: unknown) => unknown };\n return getPropertyName(fieldProps.value);\n};\n\n/** Recursively collects all CommandFormField property names from a React node tree. */\nexport const extractFieldNamesFromNode = (nodes: React.ReactNode): string[] => {\n const names: string[] = [];\n React.Children.forEach(nodes, (child) => {\n if (!React.isValidElement(child)) return;\n const name = fieldNameOf(child);\n if (name) names.push(name);\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n names.push(\n ...extractFieldNamesFromNode(childProps.children as React.ReactNode),\n );\n }\n });\n return names;\n};\n\n/** Wraps every CommandFormField in the tree with the Arc field wrapper. */\nexport const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<typeof CommandFormFieldWrapper>[0]['field'];\n // SAFETY: displayName identifies the Arc command field shape before it reaches the wrapper.\n return <CommandFormFieldWrapper field={child as unknown as FieldElement} />;\n }\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n};\n"],"names":["_jsx"],"mappings":";;;;;AAQA,MAAM,eAAe,GAAG,CAAC,QAA+C,KAAY;IAChF,IAAI,OAAO,QAAQ,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AAC7C,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,KAAyB,KAAY;AACtD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,IAAA,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,EAAE;AAC7C,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAA8C;AACvE,IAAA,OAAO,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC;AAC5C,CAAC;AAGM,MAAM,yBAAyB,GAAG,CAAC,KAAsB,KAAc;IAC1E,MAAM,KAAK,GAAa,EAAE;IAC1B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,KAAI;AACpC,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE;AAClC,QAAA,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC;AAC/B,QAAA,IAAI,IAAI;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;AAE1B,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAgC;AACzD,QAAA,IAAI,UAAU,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC7B,KAAK,CAAC,IAAI,CACN,GAAG,yBAAyB,CAAC,UAAU,CAAC,QAA2B,CAAC,CACvE;QACL;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,KAAK;AAChB;AAGO,MAAM,eAAe,GAAG,CAAC,KAAsB,KAAqB;IACvE,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,KAAI;AACvC,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;AAAE,YAAA,OAAO,KAAK;AAE9C,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,QAAA,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE;AAG/B,YAAA,OAAOA,IAAC,uBAAuB,EAAA,EAAC,KAAK,EAAE,KAAgC,GAAI;QAC/E;AAEA,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAgC;AACzD,QAAA,IAAI,UAAU,CAAC,QAAQ,IAAI,IAAI,EAAE;AAC7B,YAAA,OAAO,KAAK,CAAC,YAAY,CACrB,KAAoD,EACpD;AACI,gBAAA,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,QAA2B,CAAC;AACpE,aAAA,CACJ;QACL;AAEA,QAAA,OAAO,KAAK;AAChB,IAAA,CAAC,CAAC;AACN;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinClassNames.d.ts","sourceRoot":"","sources":["../../../CommandDialog/joinClassNames.ts"],"names":[],"mappings":"AAGA,6FAA6F;AAC7F,eAAO,MAAM,cAAc,SAAU,MAAM,UAAU,MAAM,KAAG,MACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinClassNames.js","sources":["../../../CommandDialog/joinClassNames.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\n/** Joins a stable class name with an optional caller-supplied one, skipping empty values. */\nexport const joinClassNames = (base: string, extra?: string): string =>\n [base, extra].filter(Boolean).join(' ');\n"],"names":[],"mappings":"AAIO,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,KAAc,KACvD,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG;;"}
|
|
@@ -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 {
|
|
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,
|
|
1
|
+
{"version":3,"file":"ChipsField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ChipsField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAQ9B,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,SAAS,CAAC,EAAE,OAAO,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;AA+CD,wEAAwE;AACxE,eAAO,MAAM,UAAU,uNAErB,CAAC"}
|
|
@@ -1,55 +1,19 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
4
|
+
import { ChipsInput } from './ChipsInput.js';
|
|
5
|
+
import { ChipsItem } from './ChipsItem.js';
|
|
6
|
+
import { ChipsRoot } from './ChipsRoot.js';
|
|
7
|
+
import { useChipsDraft } from './useChipsDraft.js';
|
|
7
8
|
|
|
8
9
|
const ChipsControl = (props) => {
|
|
9
|
-
const
|
|
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
|
-
|
|
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) => {
|
|
33
|
-
props.onBlur?.();
|
|
34
|
-
if (props.addOnBlur && !event.currentTarget.contains(event.relatedTarget))
|
|
35
|
-
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] }));
|
|
16
|
+
return (jsxs(ChipsRoot, { parts: props.pt, className: props.className, invalid: props.invalid, addOnBlur: props.addOnBlur, onBlur: props.onBlur, onCommit: commit, 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
17
|
};
|
|
54
18
|
const ChipsField = asCommandFormField(ChipsControl, {
|
|
55
19
|
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 {
|
|
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 { ChipsInput } from './ChipsInput';\nimport { ChipsItem } from './ChipsItem';\nimport { ChipsRoot } from './ChipsRoot';\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 <ChipsRoot\n parts={props.pt}\n className={props.className}\n invalid={props.invalid}\n addOnBlur={props.addOnBlur}\n onBlur={props.onBlur}\n onCommit={commit}\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 </ChipsRoot>\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,CAAC,SAAS,EAAA,EACN,KAAK,EAAE,KAAK,CAAC,EAAE,EACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,MAAM,EAAA,QAAA,EAAA,CAEf,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACzBC,GAAA,CAAC,SAAS,EAAA,EAEN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,KAAK,EAAE,KAAK,CAAC,EAAE,EACf,QAAQ,EAAE,MACN,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,IANxE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,EAAE,CAQzB,CACL,CAAC,EACFA,GAAA,CAAC,UAAU,EAAA,EACP,EAAE,EAAE,aAAa,CAAC,SAAS,EAC3B,SAAS,EAAE,aAAa,CAAC,SAAS,EAClC,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,QAAQ,EACvB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,KAAK,CAAC,EAAE,GACjB,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CAClB;AAEpB,CAAC;AAGM,MAAM,UAAU,GAAG,kBAAkB,CAA2B,YAAY,EAAE;AACjF,IAAA,YAAY,EAAE,EAAE;AACnB,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"}
|