@pega/cosmos-react-core 3.0.0-dev.12.0 → 3.0.0-dev.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppHeader.js +13 -3
  3. package/lib/components/AppShell/AppHeader.js.map +1 -1
  4. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  5. package/lib/components/AppShell/AppShell.js +8 -4
  6. package/lib/components/AppShell/AppShell.js.map +1 -1
  7. package/lib/components/AppShell/AppShell.styles.d.ts +1 -0
  8. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  9. package/lib/components/AppShell/AppShell.styles.js +62 -77
  10. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  11. package/lib/components/AppShell/AppShell.types.d.ts +3 -0
  12. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  13. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  14. package/lib/components/AppShell/AppShellContext.d.ts +3 -1
  15. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
  16. package/lib/components/AppShell/AppShellContext.js +3 -1
  17. package/lib/components/AppShell/AppShellContext.js.map +1 -1
  18. package/lib/components/Banner/Banner.d.ts.map +1 -1
  19. package/lib/components/Banner/Banner.js +6 -2
  20. package/lib/components/Banner/Banner.js.map +1 -1
  21. package/lib/components/Boolean/BooleanDisplay.d.ts.map +1 -1
  22. package/lib/components/Boolean/BooleanDisplay.js +4 -12
  23. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  24. package/lib/components/CompositeInput/CompositeInput.d.ts +5 -0
  25. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -0
  26. package/lib/components/CompositeInput/CompositeInput.js +59 -0
  27. package/lib/components/CompositeInput/CompositeInput.js.map +1 -0
  28. package/lib/components/CompositeInput/CompositeInput.styles.d.ts +5 -0
  29. package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -0
  30. package/lib/components/CompositeInput/CompositeInput.styles.js +54 -0
  31. package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -0
  32. package/lib/components/CompositeInput/CompositeInput.types.d.ts +50 -0
  33. package/lib/components/CompositeInput/CompositeInput.types.d.ts.map +1 -0
  34. package/lib/components/CompositeInput/CompositeInput.types.js +2 -0
  35. package/lib/components/CompositeInput/CompositeInput.types.js.map +1 -0
  36. package/lib/components/CompositeInput/index.d.ts +3 -0
  37. package/lib/components/CompositeInput/index.d.ts.map +1 -0
  38. package/lib/components/CompositeInput/index.js +2 -0
  39. package/lib/components/CompositeInput/index.js.map +1 -0
  40. package/lib/components/Configuration/Configuration.d.ts +14 -13
  41. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  42. package/lib/components/Configuration/Configuration.js +24 -14
  43. package/lib/components/Configuration/Configuration.js.map +1 -1
  44. package/lib/components/Currency/utils.js +2 -2
  45. package/lib/components/Currency/utils.js.map +1 -1
  46. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  47. package/lib/components/FieldGroup/FieldGroup.js +3 -2
  48. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  49. package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
  50. package/lib/components/FieldGroup/FieldGroupList.js +6 -2
  51. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  52. package/lib/components/Form/Form.d.ts +5 -16
  53. package/lib/components/Form/Form.d.ts.map +1 -1
  54. package/lib/components/Form/Form.js +14 -11
  55. package/lib/components/Form/Form.js.map +1 -1
  56. package/lib/components/FormField/FormField.d.ts.map +1 -1
  57. package/lib/components/FormField/FormField.js +6 -2
  58. package/lib/components/FormField/FormField.js.map +1 -1
  59. package/lib/components/Icon/Icon.d.ts.map +1 -1
  60. package/lib/components/Icon/Icon.js +1 -1
  61. package/lib/components/Icon/Icon.js.map +1 -1
  62. package/lib/components/Link/Link.d.ts.map +1 -1
  63. package/lib/components/Link/Link.js +1 -2
  64. package/lib/components/Link/Link.js.map +1 -1
  65. package/lib/components/List/CommaSeparatedList.d.ts.map +1 -1
  66. package/lib/components/List/CommaSeparatedList.js +6 -14
  67. package/lib/components/List/CommaSeparatedList.js.map +1 -1
  68. package/lib/components/Modal/Contexts.d.ts.map +1 -1
  69. package/lib/components/Modal/Contexts.js +2 -3
  70. package/lib/components/Modal/Contexts.js.map +1 -1
  71. package/lib/components/Modal/Modal.types.d.ts +2 -6
  72. package/lib/components/Modal/Modal.types.d.ts.map +1 -1
  73. package/lib/components/Modal/Modal.types.js +1 -2
  74. package/lib/components/Modal/Modal.types.js.map +1 -1
  75. package/lib/components/Modal/ModalManager.d.ts +8 -2
  76. package/lib/components/Modal/ModalManager.d.ts.map +1 -1
  77. package/lib/components/Modal/ModalManager.js +13 -10
  78. package/lib/components/Modal/ModalManager.js.map +1 -1
  79. package/lib/components/MultiStepForm/FormProgress.d.ts +10 -0
  80. package/lib/components/MultiStepForm/FormProgress.d.ts.map +1 -0
  81. package/lib/components/{MultiStep/MultiStep.js → MultiStepForm/FormProgress.js} +8 -22
  82. package/lib/components/MultiStepForm/FormProgress.js.map +1 -0
  83. package/lib/components/{MultiStep/MultiStep.styles.d.ts → MultiStepForm/FormProgress.styles.d.ts} +2 -4
  84. package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -0
  85. package/lib/components/{MultiStep/MultiStep.styles.js → MultiStepForm/FormProgress.styles.js} +2 -4
  86. package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -0
  87. package/lib/components/MultiStepForm/MultiStepForm.d.ts +9 -0
  88. package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -0
  89. package/lib/components/MultiStepForm/MultiStepForm.js +50 -0
  90. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -0
  91. package/lib/components/MultiStepForm/MultiStepForm.types.d.ts +49 -0
  92. package/lib/components/MultiStepForm/MultiStepForm.types.d.ts.map +1 -0
  93. package/lib/components/MultiStepForm/MultiStepForm.types.js +2 -0
  94. package/lib/components/MultiStepForm/MultiStepForm.types.js.map +1 -0
  95. package/lib/components/MultiStepForm/index.d.ts +2 -0
  96. package/lib/components/MultiStepForm/index.d.ts.map +1 -0
  97. package/lib/components/MultiStepForm/index.js +2 -0
  98. package/lib/components/MultiStepForm/index.js.map +1 -0
  99. package/lib/components/Number/NumberDisplay.d.ts +0 -5
  100. package/lib/components/Number/NumberDisplay.d.ts.map +1 -1
  101. package/lib/components/Number/NumberDisplay.js +8 -12
  102. package/lib/components/Number/NumberDisplay.js.map +1 -1
  103. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  104. package/lib/components/Number/NumberInput.js +8 -5
  105. package/lib/components/Number/NumberInput.js.map +1 -1
  106. package/lib/components/Number/utils.d.ts +1 -4
  107. package/lib/components/Number/utils.d.ts.map +1 -1
  108. package/lib/components/Number/utils.js +5 -3
  109. package/lib/components/Number/utils.js.map +1 -1
  110. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  111. package/lib/components/SearchInput/SearchInput.js +5 -1
  112. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  113. package/lib/components/Tabs/Tab.d.ts.map +1 -1
  114. package/lib/components/Tabs/Tab.js +0 -1
  115. package/lib/components/Tabs/Tab.js.map +1 -1
  116. package/lib/components/Toaster/Toaster.d.ts +7 -2
  117. package/lib/components/Toaster/Toaster.d.ts.map +1 -1
  118. package/lib/components/Toaster/Toaster.js +7 -7
  119. package/lib/components/Toaster/Toaster.js.map +1 -1
  120. package/lib/hooks/useI18n.d.ts +20 -9
  121. package/lib/hooks/useI18n.d.ts.map +1 -1
  122. package/lib/i18n/default.d.ts +20 -9
  123. package/lib/i18n/default.d.ts.map +1 -1
  124. package/lib/i18n/default.js +23 -9
  125. package/lib/i18n/default.js.map +1 -1
  126. package/lib/i18n/i18n.d.ts +40 -18
  127. package/lib/i18n/i18n.d.ts.map +1 -1
  128. package/lib/index.d.ts +3 -2
  129. package/lib/index.d.ts.map +1 -1
  130. package/lib/index.js +3 -2
  131. package/lib/index.js.map +1 -1
  132. package/lib/init.d.ts +8 -0
  133. package/lib/init.d.ts.map +1 -0
  134. package/lib/init.js +5 -0
  135. package/lib/init.js.map +1 -0
  136. package/lib/theme/ThemeMachine.d.ts +11 -3
  137. package/lib/theme/ThemeMachine.d.ts.map +1 -1
  138. package/lib/theme/ThemeMachine.js +28 -26
  139. package/lib/theme/ThemeMachine.js.map +1 -1
  140. package/package.json +5 -2
  141. package/lib/components/MultiStep/MultiStep.d.ts +0 -6
  142. package/lib/components/MultiStep/MultiStep.d.ts.map +0 -1
  143. package/lib/components/MultiStep/MultiStep.js.map +0 -1
  144. package/lib/components/MultiStep/MultiStep.styles.d.ts.map +0 -1
  145. package/lib/components/MultiStep/MultiStep.styles.js.map +0 -1
  146. package/lib/components/MultiStep/MultiStep.types.d.ts +0 -36
  147. package/lib/components/MultiStep/MultiStep.types.d.ts.map +0 -1
  148. package/lib/components/MultiStep/MultiStep.types.js +0 -2
  149. package/lib/components/MultiStep/MultiStep.types.js.map +0 -1
  150. package/lib/components/MultiStep/index.d.ts +0 -3
  151. package/lib/components/MultiStep/index.d.ts.map +0 -1
  152. package/lib/components/MultiStep/index.js +0 -2
  153. package/lib/components/MultiStep/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAGlB,MAAM,OAAO,CAAC;AAQf,OAAO,EAIL,iBAAiB,EAIlB,MAAM,eAAe,CAAC;AA2KvB,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAkItD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ModalManager.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/ModalManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAGjB,OAAO,EAER,MAAM,OAAO,CAAC;AAMf,OAAO,YAAY,CAAC;AAGpB,OAAO,EAIL,iBAAiB,EAEjB,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAGvB,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAiB,aAAa;QAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;KACzD;CACF;AA4KD,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAkItD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useReducer, useMemo, useEffect, useContext } from 'react';
3
+ import { useReducer, useMemo, useEffect, useContext, memo } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
- import { createUID } from '../../utils';
5
+ import { createUID, windowIsAvailable } from '../../utils';
6
6
  import { useConfiguration, useScrollToggle } from '../../hooks';
7
+ import '../../init';
7
8
  import DockedModals from './DockedModals';
8
- import { modalInitializedKey, managerInitializedKey } from './Modal.types';
9
9
  import { ModalContext, ModalManagerContext } from './Contexts';
10
10
  const reducer = (modals, payload) => {
11
11
  switch (payload.action) {
@@ -72,7 +72,7 @@ const reducer = (modals, payload) => {
72
72
  return modals;
73
73
  }
74
74
  };
75
- const WrappedModal = ({ Component, id, options: { alert, dismissible, dockable, minimizable, maximizable }, state, methods, props, top }) => (_jsx(ModalContext.Provider, { value: {
75
+ const WrappedModal = memo(({ Component, id, options: { alert, dismissible, dockable, minimizable, maximizable }, state, methods, props, top }) => (_jsx(ModalContext.Provider, { value: {
76
76
  id,
77
77
  alert,
78
78
  dismissible,
@@ -81,9 +81,9 @@ const WrappedModal = ({ Component, id, options: { alert, dismissible, dockable,
81
81
  dockable,
82
82
  state,
83
83
  top,
84
- [modalInitializedKey]: true,
84
+ initialized: true,
85
85
  ...methods
86
- }, children: _jsx(Component, { ...props }) }));
86
+ }, children: _jsx(Component, { ...props }) })));
87
87
  const RenderModals = ({ modals }) => {
88
88
  const { open, minimized, alerts } = modals.reduce((obj, modal) => {
89
89
  if (modal.options.alert)
@@ -97,7 +97,7 @@ const RenderModals = ({ modals }) => {
97
97
  }, { open: [], minimized: [], alerts: [] });
98
98
  return (_jsxs(_Fragment, { children: [open.map((modal, i) => (_createElement(WrappedModal, { ...modal, top: alerts.length === 0 && i === open.length - 1, key: modal.id }))), minimized.length > 0 && (_jsx(DockedModals, { children: minimized.map(modal => (_createElement(WrappedModal, { ...modal, top: false, key: modal.id }))) })), alerts.map((modal, i) => (_createElement(WrappedModal, { ...modal, top: i === open.length - 1, key: modal.id })))] }));
99
99
  };
100
- const ModalManager = ({ children, context = ModalManagerContext }) => {
100
+ const ModalManager = ({ children }) => {
101
101
  const [modals, dispatch] = useReducer(reducer, []);
102
102
  const { disableScroll, enableScroll } = useScrollToggle();
103
103
  const providerValue = useMemo(() => ({
@@ -167,7 +167,7 @@ const ModalManager = ({ children, context = ModalManagerContext }) => {
167
167
  return methods;
168
168
  },
169
169
  ModalContext,
170
- [managerInitializedKey]: true
170
+ initialized: true
171
171
  }), []);
172
172
  useEffect(() => {
173
173
  if (modals.some(modal => modal.state === 'open' && !modal.options.dockable)) {
@@ -178,18 +178,21 @@ const ModalManager = ({ children, context = ModalManagerContext }) => {
178
178
  }
179
179
  }, [modals]);
180
180
  const { portalTarget } = useConfiguration();
181
+ const context = windowIsAvailable
182
+ ? window.cosmos.modalManagerContext ?? ModalManagerContext
183
+ : ModalManagerContext;
181
184
  const priorCtx = useContext(context);
182
185
  const priorCtxValue = useMemo(() => context === ModalManagerContext
183
186
  ? priorCtx
184
187
  : {
185
188
  ...priorCtx,
186
189
  create: (Comp, props, opts) => {
187
- const WrappedComp = compProps => (_jsx(ModalManager, { context: context, children: _jsx(Comp, { ...compProps }) }));
190
+ const WrappedComp = compProps => (_jsx(ModalManager, { children: _jsx(Comp, { ...compProps }) }));
188
191
  return priorCtx.create(WrappedComp, props, opts);
189
192
  }
190
193
  }, [priorCtx, context]);
191
194
  // Don't create additional Modal portals.
192
- if (priorCtx[managerInitializedKey])
195
+ if (priorCtx.initialized)
193
196
  return (_jsx(ModalManagerContext.Provider, { value: priorCtxValue, children: children }));
194
197
  return (_jsxs(ModalManagerContext.Provider, { value: providerValue, children: [children, modals.length > 0 &&
195
198
  portalTarget &&
@@ -1 +1 @@
1
- {"version":3,"file":"ModalManager.js","sourceRoot":"","sources":["../../../src/components/Modal/ModalManager.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,SAAS,EACT,UAAU,EAIX,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAML,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAwB/D,MAAM,OAAO,GAAG,CACd,MAAqB,EACrB,OAA+B,EACX,EAAE;IACtB,QAAQ,OAAO,CAAC,MAAM,EAAE;QACtB,KAAK,QAAQ;YACX,OAAO;gBACL,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;oBACpB,IACE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK;wBAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;wBAC9B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK;wBACpB,KAAK,CAAC,KAAK,KAAK,MAAM;wBACtB,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;wBAC5B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAC9B;wBACA,KAAK,CAA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AAO,KAAK,mBAAmB;QAC7B,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC;YACE,GAAG,QAAQ;YACX,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBAC5B,MAAM,WAAW,GAAgB,SAAS,CAAC,EAAE,CAAC,CAC5C,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,YAC5B,KAAC,IAAI,OAAK,SAAS,GAAI,GACV,CAChB,CAAC;gBACF,OAAO,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;SACF,EACP,CAAC,QAAQ,EAAE,OAAO,CAAC,CACpB,CAAC;IAEF,yCAAyC;IACzC,IAAI,QAAQ,CAAC,qBAAqB,CAAC;QACjC,OAAO,CACL,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAAgC,CAC9F,CAAC;IAEJ,OAAO,CACL,MAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,aAC/C,QAAQ,EACR,MAAM,CAAC,MAAM,GAAG,CAAC;gBAChB,YAAY;gBACZ,YAAY,CAAC,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,EAAE,YAAY,CAAC,IACjC,CAChC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useReducer,\n useMemo,\n useEffect,\n useContext,\n FunctionComponent,\n ComponentType,\n Dispatch\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID } from '../../utils';\nimport { useConfiguration, useScrollToggle } from '../../hooks';\nimport { OmitStrict } from '../../types';\n\nimport DockedModals from './DockedModals';\nimport {\n ModalMethods,\n ModalOptions,\n ModalObject,\n ModalManagerProps,\n ModalState,\n modalInitializedKey,\n managerInitializedKey\n} from './Modal.types';\nimport { ModalContext, ModalManagerContext } from './Contexts';\n\ntype ModalAction =\n | 'create'\n | 'update'\n | 'minimize'\n | 'maximize'\n | 'dock'\n | 'activate'\n | 'dismiss'\n | 'unmount';\n\ntype ModalReducerPayload<P extends object> =\n | { action: 'create'; modal: ModalObject<P> }\n | {\n action: 'update';\n modal: Partial<OmitStrict<ModalObject<P>, 'props'>> &\n Pick<ModalObject, 'id'> & { props: Partial<ModalObject<P>['props']> };\n }\n | {\n action: Exclude<ModalAction, 'create' | 'update'>;\n modal: Pick<ModalObject, 'id'>;\n };\n\nconst reducer = <P extends object>(\n modals: ModalObject[],\n payload: ModalReducerPayload<P>\n): ModalObject<any>[] => {\n switch (payload.action) {\n case 'create':\n return [\n ...modals.map(modal => {\n if (\n (!payload.modal.options.alert &&\n payload.modal.state === 'open' &&\n !modal.options.alert &&\n modal.state === 'open' &&\n modal.options.minimizable) ||\n payload.modal.options.dockable\n ) {\n modal.state = 'minimized';\n }\n\n return modal;\n }),\n payload.modal\n ];\n\n case 'unmount':\n return modals.filter(modal => modal.id !== payload.modal.id);\n\n case 'dismiss':\n return modals.map(modal => {\n modal.state = modal.id === payload.modal.id ? 'closed' : modal.state;\n return modal;\n });\n\n case 'update':\n return modals.map(modal => {\n modal.props =\n modal.id === payload.modal.id ? { ...modal.props, ...payload.modal.props } : modal.props;\n return modal;\n });\n\n case 'activate':\n return modals.map(modal => {\n if (modal.id === payload.modal.id && !modal.options.dockable) {\n modal.state = 'open';\n } else if (modal.id === payload.modal.id && modal.options.dockable) {\n modal.state = 'docked';\n } else if (!modal.options.alert && modal.state === 'open' && modal.options.minimizable) {\n modal.state = 'minimized';\n }\n\n return modal;\n });\n\n case 'minimize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.minimizable ? 'minimized' : modal.state;\n return modal;\n });\n\n case 'maximize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.maximizable ? 'maximized' : modal.state;\n return modal;\n });\n\n case 'dock':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.dockable ? 'docked' : 'minimized';\n return modal;\n });\n\n default:\n return modals;\n }\n};\n\nconst WrappedModal = ({\n Component,\n id,\n options: { alert, dismissible, dockable, minimizable, maximizable },\n state,\n methods,\n props,\n top\n}: ModalObject & { top: boolean }) => (\n <ModalContext.Provider\n value={{\n id,\n alert,\n dismissible,\n minimizable,\n maximizable,\n dockable,\n state,\n top,\n [modalInitializedKey]: true,\n ...methods\n }}\n >\n <Component {...props} />\n </ModalContext.Provider>\n);\n\nconst RenderModals = ({ modals }: { modals: ModalObject[] }) => {\n const { open, minimized, alerts } = modals.reduce<{\n open: ModalObject[];\n minimized: ModalObject[];\n alerts: ModalObject[];\n }>(\n (obj, modal) => {\n if (modal.options.alert) obj.alerts.push(modal);\n else if (modal.state === 'minimized' || modal.state === 'docked') {\n obj.minimized.push(modal);\n } else obj.open.push(modal);\n\n return obj;\n },\n { open: [], minimized: [], alerts: [] }\n );\n\n return (\n <>\n {open.map((modal, i) => (\n <WrappedModal\n {...modal}\n top={alerts.length === 0 && i === open.length - 1}\n key={modal.id}\n />\n ))}\n {minimized.length > 0 && (\n <DockedModals>\n {minimized.map(modal => (\n <WrappedModal {...modal} top={false} key={modal.id} />\n ))}\n </DockedModals>\n )}\n {alerts.map((modal, i) => (\n <WrappedModal {...modal} top={i === open.length - 1} key={modal.id} />\n ))}\n </>\n );\n};\n\nconst ModalManager: FunctionComponent<ModalManagerProps> = ({\n children,\n context = ModalManagerContext\n}) => {\n const [modals, dispatch] = useReducer(reducer, []);\n const { disableScroll, enableScroll } = useScrollToggle();\n\n const providerValue = useMemo(\n () => ({\n create: <P extends object>(\n Component: ComponentType<P>,\n props?: P,\n options?: ModalOptions\n ) => {\n const id = options?.id || createUID();\n\n const methods: ModalMethods<P> = {\n dismiss: () => {\n dispatch({ action: 'dismiss', modal: { id } });\n options?.onDismiss?.(id);\n },\n update: updateProps => {\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'update',\n modal: { id, props: updateProps }\n });\n },\n minimize: () => {\n dispatch({ action: 'minimize', modal: { id } });\n options?.onMinimize?.(id);\n },\n maximize: () => {\n dispatch({ action: 'maximize', modal: { id } });\n options?.onMaximize?.(id);\n },\n dock: () => {\n dispatch({ action: 'dock', modal: { id } });\n options?.onDock?.(id);\n },\n activate: () => {\n dispatch({ action: 'activate', modal: { id } });\n options?.onActivate?.(id);\n },\n unmount: () => {\n dispatch({ action: 'unmount', modal: { id } });\n }\n };\n\n let defaultState: ModalState;\n if (options?.defaultMinimized) {\n defaultState = 'minimized';\n } else if (options?.dockable) {\n defaultState = 'docked';\n } else {\n defaultState = 'open';\n }\n\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'create',\n modal: {\n id,\n methods,\n Component,\n props,\n state: defaultState,\n options: {\n alert: false,\n minimizable: false,\n maximizable: false,\n dockable: false,\n defaultMinimized: false,\n unmountWhenMinimized: true,\n ...options,\n dismissible: !!(options?.alert ? false : options?.dismissible ?? true)\n }\n }\n });\n\n return methods;\n },\n ModalContext,\n [managerInitializedKey]: true\n }),\n []\n );\n\n useEffect(() => {\n if (modals.some(modal => modal.state === 'open' && !modal.options.dockable)) {\n disableScroll();\n } else {\n enableScroll();\n }\n }, [modals]);\n\n const { portalTarget } = useConfiguration();\n\n const priorCtx = useContext(context);\n\n const priorCtxValue = useMemo(\n () =>\n context === ModalManagerContext\n ? priorCtx\n : {\n ...priorCtx,\n create: (Comp, props, opts) => {\n const WrappedComp: typeof Comp = compProps => (\n <ModalManager context={context}>\n <Comp {...compProps} />\n </ModalManager>\n );\n return priorCtx.create(WrappedComp, props, opts);\n }\n },\n [priorCtx, context]\n );\n\n // Don't create additional Modal portals.\n if (priorCtx[managerInitializedKey])\n return (\n <ModalManagerContext.Provider value={priorCtxValue}>{children}</ModalManagerContext.Provider>\n );\n\n return (\n <ModalManagerContext.Provider value={providerValue}>\n {children}\n {modals.length > 0 &&\n portalTarget &&\n createPortal(<RenderModals modals={modals} />, portalTarget)}\n </ModalManagerContext.Provider>\n );\n};\n\nexport default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C5B,MAAM,WAAW,GAAgB,SAAS,CAAC,EAAE,CAAC,CAC5C,KAAC,YAAY,cACX,KAAC,IAAI,OAAK,SAAS,GAAI,GACV,CAChB,CAAC;gBACF,OAAO,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;SACF,EACP,CAAC,QAAQ,EAAE,OAAO,CAAC,CACpB,CAAC;IAEF,yCAAyC;IACzC,IAAI,QAAQ,CAAC,WAAW;QACtB,OAAO,CACL,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YAAG,QAAQ,GAAgC,CAC9F,CAAC;IAEJ,OAAO,CACL,MAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,aAC/C,QAAQ,EACR,MAAM,CAAC,MAAM,GAAG,CAAC;gBAChB,YAAY;gBACZ,YAAY,CAAC,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,EAAE,YAAY,CAAC,IACjC,CAChC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n useReducer,\n useMemo,\n useEffect,\n useContext,\n FunctionComponent,\n ComponentType,\n Dispatch,\n Context,\n memo\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { createUID, windowIsAvailable } from '../../utils';\nimport { useConfiguration, useScrollToggle } from '../../hooks';\nimport { OmitStrict } from '../../types';\nimport '../../init';\n\nimport DockedModals from './DockedModals';\nimport {\n ModalMethods,\n ModalOptions,\n ModalObject,\n ModalManagerProps,\n ModalState,\n ModalManagerContextValue\n} from './Modal.types';\nimport { ModalContext, ModalManagerContext } from './Contexts';\n\ndeclare module '../../init' {\n export interface CosmosGlobals {\n modalManagerContext?: Context<ModalManagerContextValue>;\n }\n}\n\ntype ModalAction =\n | 'create'\n | 'update'\n | 'minimize'\n | 'maximize'\n | 'dock'\n | 'activate'\n | 'dismiss'\n | 'unmount';\n\ntype ModalReducerPayload<P extends object> =\n | { action: 'create'; modal: ModalObject<P> }\n | {\n action: 'update';\n modal: Partial<OmitStrict<ModalObject<P>, 'props'>> &\n Pick<ModalObject, 'id'> & { props: Partial<ModalObject<P>['props']> };\n }\n | {\n action: Exclude<ModalAction, 'create' | 'update'>;\n modal: Pick<ModalObject, 'id'>;\n };\n\nconst reducer = <P extends object>(\n modals: ModalObject[],\n payload: ModalReducerPayload<P>\n): ModalObject<any>[] => {\n switch (payload.action) {\n case 'create':\n return [\n ...modals.map(modal => {\n if (\n (!payload.modal.options.alert &&\n payload.modal.state === 'open' &&\n !modal.options.alert &&\n modal.state === 'open' &&\n modal.options.minimizable) ||\n payload.modal.options.dockable\n ) {\n modal.state = 'minimized';\n }\n\n return modal;\n }),\n payload.modal\n ];\n\n case 'unmount':\n return modals.filter(modal => modal.id !== payload.modal.id);\n\n case 'dismiss':\n return modals.map(modal => {\n modal.state = modal.id === payload.modal.id ? 'closed' : modal.state;\n return modal;\n });\n\n case 'update':\n return modals.map(modal => {\n modal.props =\n modal.id === payload.modal.id ? { ...modal.props, ...payload.modal.props } : modal.props;\n return modal;\n });\n\n case 'activate':\n return modals.map(modal => {\n if (modal.id === payload.modal.id && !modal.options.dockable) {\n modal.state = 'open';\n } else if (modal.id === payload.modal.id && modal.options.dockable) {\n modal.state = 'docked';\n } else if (!modal.options.alert && modal.state === 'open' && modal.options.minimizable) {\n modal.state = 'minimized';\n }\n\n return modal;\n });\n\n case 'minimize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.minimizable ? 'minimized' : modal.state;\n return modal;\n });\n\n case 'maximize':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.maximizable ? 'maximized' : modal.state;\n return modal;\n });\n\n case 'dock':\n return modals.map(modal => {\n modal.state =\n modal.id === payload.modal.id && modal.options.dockable ? 'docked' : 'minimized';\n return modal;\n });\n\n default:\n return modals;\n }\n};\n\nconst WrappedModal = memo(\n ({\n Component,\n id,\n options: { alert, dismissible, dockable, minimizable, maximizable },\n state,\n methods,\n props,\n top\n }: ModalObject & { top: boolean }) => (\n <ModalContext.Provider\n value={{\n id,\n alert,\n dismissible,\n minimizable,\n maximizable,\n dockable,\n state,\n top,\n initialized: true,\n ...methods\n }}\n >\n <Component {...props} />\n </ModalContext.Provider>\n )\n);\n\nconst RenderModals = ({ modals }: { modals: ModalObject[] }) => {\n const { open, minimized, alerts } = modals.reduce<{\n open: ModalObject[];\n minimized: ModalObject[];\n alerts: ModalObject[];\n }>(\n (obj, modal) => {\n if (modal.options.alert) obj.alerts.push(modal);\n else if (modal.state === 'minimized' || modal.state === 'docked') {\n obj.minimized.push(modal);\n } else obj.open.push(modal);\n\n return obj;\n },\n { open: [], minimized: [], alerts: [] }\n );\n\n return (\n <>\n {open.map((modal, i) => (\n <WrappedModal\n {...modal}\n top={alerts.length === 0 && i === open.length - 1}\n key={modal.id}\n />\n ))}\n {minimized.length > 0 && (\n <DockedModals>\n {minimized.map(modal => (\n <WrappedModal {...modal} top={false} key={modal.id} />\n ))}\n </DockedModals>\n )}\n {alerts.map((modal, i) => (\n <WrappedModal {...modal} top={i === open.length - 1} key={modal.id} />\n ))}\n </>\n );\n};\n\nconst ModalManager: FunctionComponent<ModalManagerProps> = ({ children }) => {\n const [modals, dispatch] = useReducer(reducer, []);\n const { disableScroll, enableScroll } = useScrollToggle();\n\n const providerValue = useMemo(\n () => ({\n create: <P extends object>(\n Component: ComponentType<P>,\n props?: P,\n options?: ModalOptions\n ) => {\n const id = options?.id || createUID();\n\n const methods: ModalMethods<P> = {\n dismiss: () => {\n dispatch({ action: 'dismiss', modal: { id } });\n options?.onDismiss?.(id);\n },\n update: updateProps => {\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'update',\n modal: { id, props: updateProps }\n });\n },\n minimize: () => {\n dispatch({ action: 'minimize', modal: { id } });\n options?.onMinimize?.(id);\n },\n maximize: () => {\n dispatch({ action: 'maximize', modal: { id } });\n options?.onMaximize?.(id);\n },\n dock: () => {\n dispatch({ action: 'dock', modal: { id } });\n options?.onDock?.(id);\n },\n activate: () => {\n dispatch({ action: 'activate', modal: { id } });\n options?.onActivate?.(id);\n },\n unmount: () => {\n dispatch({ action: 'unmount', modal: { id } });\n }\n };\n\n let defaultState: ModalState;\n if (options?.defaultMinimized) {\n defaultState = 'minimized';\n } else if (options?.dockable) {\n defaultState = 'docked';\n } else {\n defaultState = 'open';\n }\n\n (dispatch as Dispatch<ModalReducerPayload<P>>)({\n action: 'create',\n modal: {\n id,\n methods,\n Component,\n props,\n state: defaultState,\n options: {\n alert: false,\n minimizable: false,\n maximizable: false,\n dockable: false,\n defaultMinimized: false,\n unmountWhenMinimized: true,\n ...options,\n dismissible: !!(options?.alert ? false : options?.dismissible ?? true)\n }\n }\n });\n\n return methods;\n },\n ModalContext,\n initialized: true\n }),\n []\n );\n\n useEffect(() => {\n if (modals.some(modal => modal.state === 'open' && !modal.options.dockable)) {\n disableScroll();\n } else {\n enableScroll();\n }\n }, [modals]);\n\n const { portalTarget } = useConfiguration();\n\n const context = windowIsAvailable\n ? window.cosmos.modalManagerContext ?? ModalManagerContext\n : ModalManagerContext;\n const priorCtx = useContext(context);\n\n const priorCtxValue = useMemo(\n () =>\n context === ModalManagerContext\n ? priorCtx\n : {\n ...priorCtx,\n create: (Comp, props, opts) => {\n const WrappedComp: typeof Comp = compProps => (\n <ModalManager>\n <Comp {...compProps} />\n </ModalManager>\n );\n return priorCtx.create(WrappedComp, props, opts);\n }\n },\n [priorCtx, context]\n );\n\n // Don't create additional Modal portals.\n if (priorCtx.initialized)\n return (\n <ModalManagerContext.Provider value={priorCtxValue}>{children}</ModalManagerContext.Provider>\n );\n\n return (\n <ModalManagerContext.Provider value={providerValue}>\n {children}\n {modals.length > 0 &&\n portalTarget &&\n createPortal(<RenderModals modals={modals} />, portalTarget)}\n </ModalManagerContext.Provider>\n );\n};\n\nexport default ModalManager;\n"]}
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '../../types';
3
+ import type MultiStepFormProps from './MultiStepForm.types';
4
+ interface FormProgressProps {
5
+ steps: MultiStepFormProps['steps'];
6
+ currentStepId: MultiStepFormProps['currentStepId'];
7
+ }
8
+ declare const FormProgress: FunctionComponent<FormProgressProps & ForwardProps>;
9
+ export default FormProgress;
10
+ //# sourceMappingURL=FormProgress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormProgress.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa3C,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAE5D,UAAU,iBAAiB;IACzB,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CA0FrE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,15 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { remToPx, stripUnit } from 'polished';
3
- import { forwardRef, useRef, useEffect } from 'react';
3
+ import { useRef, useEffect } from 'react';
4
4
  import { useElement, useTheme } from '../../hooks';
5
- import { getFocusables, tryCatch } from '../../utils';
5
+ import { tryCatch } from '../../utils';
6
6
  import Flex from '../Flex';
7
- import Form from '../Form';
8
7
  import Text from '../Text';
9
8
  import Tooltip from '../Tooltip';
10
- import StyledMultiStep, { CurrentStepPopover, StepMarker, StyledBar, StyledFill, StyledFormProgress } from './MultiStep.styles';
11
- const FormProgress = ({ steps, currentId, ...restProps }) => {
12
- const curIdx = steps.findIndex(step => step.id === currentId);
9
+ import { CurrentStepPopover, StepMarker, StyledBar, StyledFill, StyledFormProgress } from './FormProgress.styles';
10
+ const FormProgress = ({ steps, currentStepId, ...restProps }) => {
11
+ const curIdx = steps.findIndex(step => step.id === currentStepId);
13
12
  const curStep = steps[curIdx];
14
13
  const fillScale = curIdx / (steps.length - 1);
15
14
  const [currentStepEl, setCurrentStepEl] = useElement();
@@ -36,21 +35,8 @@ const FormProgress = ({ steps, currentId, ...restProps }) => {
36
35
  ], children: _jsx(Text, { variant: 'h4', children: curStep.name }) }), _jsx(Flex, { container: { justify: 'between', alignItems: 'center' }, item: { grow: 1 }, children: steps.map((step, index) => {
37
36
  return (_jsx(StepMarker, { ref: (el) => {
38
37
  stepRefs.current[index] = el;
39
- }, "aria-label": step.name, "aria-describedby": step.id, current: index === curIdx, depth: step.depth, prior: index < curIdx, onClick: step.onClick, children: index !== curIdx && (_jsx(Tooltip, { id: step.id, target: stepRefs.current[index], showDelay: 'none', hideDelay: 'short', portal: false, children: step.name })) }, step.id));
38
+ }, "aria-label": step.name, "aria-describedby": step.id, current: index === curIdx, depth: step.depth, prior: index < curIdx, onClick: step.onMarkerClick, children: index !== curIdx && (_jsx(Tooltip, { id: step.id, target: stepRefs.current[index], showDelay: 'none', hideDelay: 'short', portal: false, children: step.name })) }, step.id));
40
39
  }) }), _jsx(StyledBar, { children: _jsx(StyledFill, { style: { '--fillScale': fillScale } }) })] }));
41
40
  };
42
- const MultiStep = forwardRef(({ currentId, steps, ...restProps }, ref) => {
43
- const multiStepContentRef = useRef(null);
44
- const currentStep = steps.find(step => step.id === currentId);
45
- useEffect(() => {
46
- const focusableElements = getFocusables(multiStepContentRef);
47
- if (focusableElements.length)
48
- focusableElements[0].focus();
49
- }, [currentId]);
50
- return (_jsxs(Flex, { as: StyledMultiStep, ref: ref, container: {
51
- direction: 'column',
52
- gap: 3
53
- }, ...restProps, children: [_jsx(FormProgress, { steps: steps, currentId: currentId }), _jsx(Form, { ref: multiStepContentRef, actions: currentStep.actions, banners: currentStep.banners, children: currentStep.content })] }));
54
- });
55
- export default MultiStep;
56
- //# sourceMappingURL=MultiStep.js.map
41
+ export default FormProgress;
42
+ //# sourceMappingURL=FormProgress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormProgress.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAoC,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,UAAU,EACV,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAQ/B,MAAM,YAAY,GAAwD,CAAC,EACzE,KAAK,EACL,aAAa,EACb,GAAG,SAAS,EACb,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,aAAa,CAAC,CAAC;IAClE,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE9C,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,UAAU,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,CAAgB,EAAE,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IAEzB,IAAI,gBAAgB,GAAoC,KAAK,CAAC;IAC9D,IAAI,MAAM,KAAK,CAAC;QAAE,gBAAgB,GA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,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;wBAC/B,CAAC,gBACW,IAAI,CAAC,IAAI,sBACH,IAAI,CAAC,EAAE,EACzB,OAAO,EAAE,KAAK,KAAK,MAAM,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,OAAO,EAAE,IAAI,CAAC,aAAa,YAE1B,KAAK,KAAK,MAAM,IAAI,CACnB,KAAC,OAAO,IACN,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAC/B,SAAS,EAAC,MAAM,EAChB,SAAS,EAAC,OAAO,EACjB,MAAM,EAAE,KAAK,YAEZ,IAAI,CAAC,IAAI,GACF,CACX,IArBI,IAAI,CAAC,EAAE,CAsBD,CACd,CAAC;gBACJ,CAAC,CAAC,GACG,EAEP,KAAC,SAAS,cACR,KAAC,UAAU,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAmB,GAAI,GAC1D,IACO,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { remToPx, stripUnit } from 'polished';\nimport { FunctionComponent, CSSProperties, useRef, useEffect } from 'react';\n\nimport { useElement, useTheme } from '../../hooks';\nimport { ForwardProps } from '../../types';\nimport { tryCatch } from '../../utils';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\n\nimport {\n CurrentStepPopover,\n StepMarker,\n StyledBar,\n StyledFill,\n StyledFormProgress\n} from './FormProgress.styles';\nimport type MultiStepFormProps from './MultiStepForm.types';\n\ninterface FormProgressProps {\n steps: MultiStepFormProps['steps'];\n currentStepId: MultiStepFormProps['currentStepId'];\n}\n\nconst FormProgress: FunctionComponent<FormProgressProps & ForwardProps> = ({\n steps,\n currentStepId,\n ...restProps\n}) => {\n const curIdx = steps.findIndex(step => step.id === currentStepId);\n const curStep = steps[curIdx];\n const fillScale = curIdx / (steps.length - 1);\n\n const [currentStepEl, setCurrentStepEl] = useElement();\n const stepRefs = useRef<HTMLElement[]>([]);\n const theme = useTheme();\n\n let popoverPlacement: 'top' | 'top-start' | 'top-end' = 'top';\n if (curIdx === 0) popoverPlacement = 'top-start';\n else if (curIdx === steps.length - 1) popoverPlacement = 'top-end';\n\n useEffect(() => {\n setCurrentStepEl(stepRefs.current[curIdx]);\n }, [stepRefs.current, curIdx]);\n\n return (\n <StyledFormProgress\n {...restProps}\n container={{ alignItems: 'center' }}\n role='progressbar'\n aria-valuenow={curIdx}\n aria-valuemin={0}\n aria-valuetext={curStep.name}\n aria-valuemax={steps.length}\n >\n <CurrentStepPopover\n show\n target={currentStepEl}\n placement={popoverPlacement}\n strategy='absolute'\n hideOnTargetHidden\n modifiers={[\n {\n name: 'offset',\n options: {\n offset: [\n 0,\n tryCatch(\n () => stripUnit(remToPx(theme.base.spacing)),\n () => 8\n )\n ]\n }\n }\n ]}\n >\n <Text variant='h4'>{curStep.name}</Text>\n </CurrentStepPopover>\n <Flex container={{ justify: 'between', alignItems: 'center' }} item={{ grow: 1 }}>\n {steps.map((step, index) => {\n return (\n <StepMarker\n key={step.id}\n ref={(el: HTMLElement) => {\n stepRefs.current[index] = el;\n }}\n aria-label={step.name}\n aria-describedby={step.id}\n current={index === curIdx}\n depth={step.depth}\n prior={index < curIdx}\n onClick={step.onMarkerClick}\n >\n {index !== curIdx && (\n <Tooltip\n id={step.id}\n target={stepRefs.current[index]}\n showDelay='none'\n hideDelay='short'\n portal={false}\n >\n {step.name}\n </Tooltip>\n )}\n </StepMarker>\n );\n })}\n </Flex>\n\n <StyledBar>\n <StyledFill style={{ '--fillScale': fillScale } as CSSProperties} />\n </StyledBar>\n </StyledFormProgress>\n );\n};\n\nexport default FormProgress;\n"]}
@@ -1,4 +1,4 @@
1
- import { Step } from './MultiStep.types';
1
+ import { type Step } from './MultiStepForm.types';
2
2
  export declare const CurrentStepPopover: import("styled-components").StyledComponent<(<Modifiers extends string = string>(props: import("../Popover").PopoverProps<Modifiers> & import("../..").ForwardProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null), import("styled-components").DefaultTheme, {}, never>;
3
3
  export declare const StyledBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
4
  export declare const StyledFill: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -8,6 +8,4 @@ export declare const StepMarker: import("styled-components").StyledComponent<imp
8
8
  depth: Step['depth'];
9
9
  prior: boolean;
10
10
  }, never>;
11
- declare const StyledMultiStep: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
- export default StyledMultiStep;
13
- //# sourceMappingURL=MultiStep.styles.d.ts.map
11
+ //# sourceMappingURL=FormProgress.styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormProgress.styles.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAElD,eAAO,MAAM,kBAAkB,8TAa9B,CAAC;AAEF,eAAO,MAAM,SAAS,yGAapB,CAAC;AAIH,eAAO,MAAM,UAAU,yGAsBrB,CAAC;AAIH,eAAO,MAAM,kBAAkB,iMAe7B,CAAC;AAIH,eAAO,MAAM,UAAU;aACZ,OAAO;WACT,IAAI,CAAC,OAAO,CAAC;WACb,OAAO;SA6Ed,CAAC"}
@@ -50,7 +50,7 @@ export const StyledFormProgress = styled(Flex)(({ theme }) => {
50
50
  const fontSizes = calculateFontSize(fontSize, fontScale);
51
51
  return css `
52
52
  position: relative;
53
- padding-block-start: calc(${spacing} * 2 + ${fontSizes[h4fontSize]} * 1.35);
53
+ padding-block-start: calc(${spacing} + ${fontSizes[h4fontSize]} * 1.35);
54
54
  `;
55
55
  });
56
56
  StyledFormProgress.defaultProps = defaultThemeProp;
@@ -116,6 +116,4 @@ export const StepMarker = styled(BareButton)(({ current, depth, prior, theme })
116
116
  `;
117
117
  });
118
118
  StepMarker.defaultProps = defaultThemeProp;
119
- const StyledMultiStep = styled.div ``;
120
- export default StyledMultiStep;
121
- //# sourceMappingURL=MultiStep.styles.js.map
119
+ //# sourceMappingURL=FormProgress.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormProgress.styles.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/FormProgress.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAY,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;;;;;;;QAQzC,UAAU;;;;;CAKjB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAChD,MAAM,EACJ,IAAI,EAAE,EACJ,OAAO,EAAE,EAAE,aAAa,EAAE,WAAW,EAAE,EACxC,EACF,GAAG,KAAK,CAAC;IAEV,OAAO,GAAG,CAAA;;;;kBAIM,WAAW;GAC1B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAA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U;gBAClD,KAAK,KAAK,CAAC;QACjB,CAAC,CAAC,SAAS,eAAe,MAAM,mBAAmB,UAAU;QAC7D,CAAC,CAAC,SAAS,eAAe,MAAM,cAAc,UAAU;UACxD,IAAI,CAAC,eAAe,CAAC;;;;;;;;;;;;;;oBAcX,WAAW;;GAE5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { size } from 'polished';\n\nimport Flex from '../Flex';\nimport { defaultThemeProp } from '../../theme';\nimport BareButton from '../Button/BareButton';\nimport Popover from '../Popover';\nimport { StyledText } from '../Text';\nimport { calculateFontSize, FontSize } from '../../styles';\nimport { useDirection } from '../../hooks';\n\nimport { type Step } from './MultiStepForm.types';\n\nexport const CurrentStepPopover = styled(Popover)`\n max-width: 100%;\n background-color: transparent;\n\n ::after {\n filter: none;\n }\n\n & > ${StyledText} {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n`;\n\nexport const StyledBar = styled.div(({ theme }) => {\n const {\n base: {\n palette: { 'border-line': borderColor }\n }\n } = theme;\n\n return css`\n position: absolute;\n width: 100%;\n height: 0.0625rem;\n background: ${borderColor};\n `;\n});\n\nStyledBar.defaultProps = defaultThemeProp;\n\nexport const StyledFill = styled.div(({ theme }) => {\n const {\n base: {\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive }\n }\n } = theme;\n\n const { ltr } = useDirection();\n\n return css`\n position: absolute;\n width: 100%;\n height: 100%;\n background: ${interactive};\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n transform: scaleX(var(--fillScale));\n transform-origin: ${ltr ? 0 : '100%'} 0;\n `;\n});\n\nStyledFill.defaultProps = defaultThemeProp;\n\nexport const StyledFormProgress = styled(Flex)(({ theme }) => {\n const {\n base: { spacing, 'font-size': fontSize, 'font-scale': fontScale },\n components: {\n text: {\n h4: { 'font-size': h4fontSize }\n }\n }\n } = theme;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n position: relative;\n padding-block-start: calc(${spacing} + ${fontSizes[h4fontSize as FontSize]} * 1.35);\n `;\n});\n\nStyledFormProgress.defaultProps = defaultThemeProp;\n\nexport const StepMarker = styled(BareButton)<{\n current: boolean;\n depth: Step['depth'];\n prior: boolean;\n}>(({ current, depth, prior, theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n animation: {\n speed: animationSpeed,\n timing: { ease: animationTiming }\n },\n palette: { interactive, 'primary-background': primaryBackground },\n shadow: { focus: focusShadow },\n 'hit-area': { 'mouse-min': buttonSize, 'finger-min': touchButtonSize }\n },\n components: {\n 'form-control': { 'border-color': borderColor }\n }\n } = theme;\n const { m: stepMarkerSize } = calculateFontSize(fontSize, fontScale);\n const smallStepMarkerSize = `calc(${stepMarkerSize} / 1.5)`;\n\n return css`\n display: block;\n position: relative;\n z-index: 1;\n ${size(depth === 1 ? smallStepMarkerSize : stepMarkerSize)}\n border-radius: 100%;\n background: ${primaryBackground};\n border: 0.0625rem solid ${borderColor};\n transition: all calc(2 * ${animationSpeed}) ${animationTiming};\n\n ${current &&\n css`\n background: ${interactive};\n border-color: ${interactive};\n `}\n\n ${prior &&\n css`\n border-color: ${interactive};\n `}\n\n ::after {\n content: '';\n position: absolute;\n top: ${depth === 1\n ? `calc((${buttonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};\n left: ${depth === 1\n ? `calc((${buttonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${buttonSize} - ${stepMarkerSize}) / -2) `};\n ${size(buttonSize)}\n\n @media (pointer: coarse) {\n top: ${depth === 1\n ? `calc((${touchButtonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};\n left: ${depth === 1\n ? `calc((${touchButtonSize} - ${smallStepMarkerSize}) / -2) `\n : `calc((${touchButtonSize} - ${stepMarkerSize}) / -2) `};\n ${size(touchButtonSize)}\n }\n }\n\n &:first-child::after {\n left: 0;\n }\n\n &:last-child::after {\n left: unset;\n right: 0;\n }\n\n :focus {\n box-shadow: ${focusShadow};\n }\n `;\n});\n\nStepMarker.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,9 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ForwardProps } from '../../types';
3
+ import MultiStepFormProps from './MultiStepForm.types';
4
+ export declare const StyledForm: import("styled-components").StyledComponent<"form", import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const StyledFormContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StyledRequiredFieldLegend: import("styled-components").StyledComponent<FunctionComponent<import("../Text").TextProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const MultiStepForm: FunctionComponent<MultiStepFormProps & ForwardProps>;
8
+ export default MultiStepForm;
9
+ //# sourceMappingURL=MultiStepForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiStepForm.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAI1F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,kBAA4B,MAAM,uBAAuB,CAAC;AAGjE,eAAO,MAAM,UAAU,0GAAgB,CAAC;AACxC,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,yBAAyB,iKAqBpC,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAoE9E,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useEffect } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { useUID, useI18n, usePrevious } from '../../hooks';
5
+ import { getFocusables } from '../../utils';
6
+ import { calculateFontSize } from '../../styles';
7
+ import Flex from '../Flex';
8
+ import Text from '../Text';
9
+ import HTML from '../HTML';
10
+ import VisuallyHiddenText from '../VisuallyHiddenText';
11
+ import FormProgress from './FormProgress';
12
+ export const StyledForm = styled.form ``;
13
+ export const StyledFormContent = styled.div ``;
14
+ export const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {
15
+ const { base: { 'font-size': fontSize, 'font-scale': fontScale, palette: { urgent } } } = theme;
16
+ const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);
17
+ return css `
18
+ font-size: ${infoFontSize};
19
+ font-style: italic;
20
+
21
+ &::before {
22
+ display: 'inline';
23
+ content: '\\00a0*';
24
+ vertical-align: top;
25
+ color: ${urgent};
26
+ }
27
+ `;
28
+ });
29
+ export const MultiStepForm = forwardRef(({ currentStepId, steps, heading, ...restProps }, ref) => {
30
+ const multiStepContentRef = useRef(null);
31
+ const previousId = usePrevious(currentStepId);
32
+ const currentStep = steps.find((step) => step.id === currentStepId);
33
+ const headingId = useUID();
34
+ const descriptionId = useUID();
35
+ const t = useI18n();
36
+ useEffect(() => {
37
+ if (previousId === undefined)
38
+ return;
39
+ if (previousId !== currentStepId) {
40
+ const focusableElements = getFocusables(multiStepContentRef);
41
+ if (focusableElements.length)
42
+ focusableElements[0].focus();
43
+ }
44
+ }, [currentStepId, previousId]);
45
+ return (_jsxs(Flex, { ref: ref, as: StyledForm, container: { direction: 'column', gap: 3 }, ...restProps, "aria-labelledby": heading ? headingId : undefined, "aria-describedby": currentStep.description ? descriptionId : undefined, children: [(heading || steps.length > 1) && (_jsxs(Flex, { container: { direction: 'column', gap: 1.5 }, children: [heading && (_jsx(Text, { id: headingId, variant: 'h3', children: heading })), steps.length > 1 && (_jsxs(_Fragment, { children: [_jsx(FormProgress, { steps: steps, currentStepId: currentStepId }), _jsx(VisuallyHiddenText, { "aria-live": 'polite', children: previousId !== undefined && previousId !== currentStepId
46
+ ? t('step_changed_to_name', [currentStep.name])
47
+ : '' })] }))] })), currentStep.banners, currentStep.description && (_jsx(HTML, { id: descriptionId, as: 'p', content: currentStep.description })), _jsx(StyledFormContent, { ref: multiStepContentRef, children: currentStep.content }), currentStep.actions && (_jsx(Flex, { container: { justify: 'between', alignItems: 'center' }, children: currentStep.actions }))] }));
48
+ });
49
+ export default MultiStepForm;
50
+ //# sourceMappingURL=MultiStepForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiStepForm.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsC,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAGvD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAClE,MAAM,EACJ,IAAI,EAAE,EACJ,WAAW,EAAE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,aAAa,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useUID, useI18n, usePrevious } from '../../hooks';\nimport { ForwardProps } from '../../types';\nimport { getFocusables } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Flex from '../Flex';\nimport Text from '../Text';\nimport HTML from '../HTML';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport MultiStepFormProps, { Step } from './MultiStepForm.types';\nimport FormProgress from './FormProgress';\n\nexport const StyledForm = styled.form``;\nexport const StyledFormContent = styled.div``;\n\nexport const StyledRequiredFieldLegend = styled(Text)(({ theme }) => {\n const {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n palette: { urgent }\n }\n } = theme;\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n font-size: ${infoFontSize};\n font-style: italic;\n\n &::before {\n display: 'inline';\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n `;\n});\n\nexport const MultiStepForm: FunctionComponent<MultiStepFormProps & ForwardProps> = forwardRef(\n (\n { currentStepId, steps, heading, ...restProps }: PropsWithoutRef<MultiStepFormProps>,\n ref: MultiStepFormProps['ref']\n ) => {\n const multiStepContentRef = useRef(null);\n const previousId = usePrevious(currentStepId);\n const currentStep = steps.find((step: Step) => step.id === currentStepId)!;\n const headingId = useUID();\n const descriptionId = useUID();\n const t = useI18n();\n\n useEffect(() => {\n if (previousId === undefined) return;\n\n if (previousId !== currentStepId) {\n const focusableElements = getFocusables(multiStepContentRef);\n\n if (focusableElements.length) focusableElements[0].focus();\n }\n }, [currentStepId, previousId]);\n\n return (\n <Flex\n ref={ref}\n as={StyledForm}\n container={{ direction: 'column', gap: 3 }}\n {...restProps}\n aria-labelledby={heading ? headingId : undefined}\n aria-describedby={currentStep.description ? descriptionId : undefined}\n >\n {(heading || steps.length > 1) && (\n <Flex container={{ direction: 'column', gap: 1.5 }}>\n {heading && (\n <Text id={headingId} variant='h3'>\n {heading}\n </Text>\n )}\n {steps.length > 1 && (\n <>\n <FormProgress steps={steps} currentStepId={currentStepId} />\n\n <VisuallyHiddenText aria-live='polite'>\n {previousId !== undefined && previousId !== currentStepId\n ? t('step_changed_to_name', [currentStep.name])\n : ''}\n </VisuallyHiddenText>\n </>\n )}\n </Flex>\n )}\n\n {currentStep.banners}\n\n {currentStep.description && (\n <HTML id={descriptionId} as='p' content={currentStep.description} />\n )}\n\n <StyledFormContent ref={multiStepContentRef}>{currentStep.content}</StyledFormContent>\n\n {currentStep.actions && (\n <Flex container={{ justify: 'between', alignItems: 'center' }}>\n {currentStep.actions}\n </Flex>\n )}\n </Flex>\n );\n }\n);\n\nexport default MultiStepForm;\n"]}
@@ -0,0 +1,49 @@
1
+ import { ReactNode, Ref, MouseEventHandler } from 'react';
2
+ import { BaseProps } from '../../types';
3
+ export interface BaseFormProps extends BaseProps {
4
+ /** Primary content area. */
5
+ content: ReactNode;
6
+ /** Region for Form Actions. */
7
+ actions?: ReactNode;
8
+ /** Region for Banners above the Form. */
9
+ banners?: ReactNode;
10
+ /** A description of the form to be displayed above the controls. */
11
+ description?: string;
12
+ /** The heading of the form. */
13
+ heading?: string;
14
+ /** Ref forwarded to the form element. */
15
+ ref?: Ref<HTMLFormElement>;
16
+ }
17
+ export interface Step {
18
+ /** The id that is referenced by the Multi Step currentStepId prop. */
19
+ id: string;
20
+ /** The displayed name of the step. */
21
+ name: string;
22
+ /** A set of Action Buttons to render for the step. */
23
+ actions?: BaseFormProps['actions'];
24
+ /** Banners to render for the step */
25
+ banners?: BaseFormProps['banners'];
26
+ /** Content to render for the step. */
27
+ content?: BaseFormProps['content'];
28
+ /**
29
+ * Determines the size of the step indicator. Depth 0 is larger than depth 1.
30
+ * @default 0
31
+ */
32
+ depth?: 0 | 1;
33
+ /** A description of the form to be displayed above the controls. */
34
+ description?: BaseFormProps['description'];
35
+ /** Callback function that is called when a step marker is clicked. */
36
+ onMarkerClick?: MouseEventHandler;
37
+ }
38
+ interface MultiStepFormProps {
39
+ /** Sets the current step. */
40
+ currentStepId: string;
41
+ /** Flat array of objects describing each step. */
42
+ steps: Step[];
43
+ /** The heading of the form. */
44
+ heading?: BaseFormProps['heading'];
45
+ /** Ref forwarded to the form element. */
46
+ ref?: BaseFormProps['ref'];
47
+ }
48
+ export default MultiStepFormProps;
49
+ //# sourceMappingURL=MultiStepForm.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiStepForm.types.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,4BAA4B;IAC5B,OAAO,EAAE,SAAS,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,yCAAyC;IACzC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,GAAG,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,IAAI;IACnB,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,qCAAqC;IACrC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,sCAAsC;IACtC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,oEAAoE;IACpE,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAC3C,sEAAsE;IACtE,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,UAAU,kBAAkB;IAC1B,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,+BAA+B;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,yCAAyC;IACzC,GAAG,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC5B;AAED,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MultiStepForm.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiStepForm.types.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/MultiStepForm.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactNode, Ref, MouseEventHandler } from 'react';\n\nimport { BaseProps } from '../../types';\n\nexport interface BaseFormProps extends BaseProps {\n /** Primary content area. */\n content: ReactNode;\n /** Region for Form Actions. */\n actions?: ReactNode;\n /** Region for Banners above the Form. */\n banners?: ReactNode;\n /** A description of the form to be displayed above the controls. */\n description?: string;\n /** The heading of the form. */\n heading?: string;\n /** Ref forwarded to the form element. */\n ref?: Ref<HTMLFormElement>;\n}\n\nexport interface Step {\n /** The id that is referenced by the Multi Step currentStepId prop. */\n id: string;\n /** The displayed name of the step. */\n name: string;\n /** A set of Action Buttons to render for the step. */\n actions?: BaseFormProps['actions'];\n /** Banners to render for the step */\n banners?: BaseFormProps['banners'];\n /** Content to render for the step. */\n content?: BaseFormProps['content'];\n /**\n * Determines the size of the step indicator. Depth 0 is larger than depth 1.\n * @default 0\n */\n depth?: 0 | 1;\n /** A description of the form to be displayed above the controls. */\n description?: BaseFormProps['description'];\n /** Callback function that is called when a step marker is clicked. */\n onMarkerClick?: MouseEventHandler;\n}\n\ninterface MultiStepFormProps {\n /** Sets the current step. */\n currentStepId: string;\n /** Flat array of objects describing each step. */\n steps: Step[];\n /** The heading of the form. */\n heading?: BaseFormProps['heading'];\n /** Ref forwarded to the form element. */\n ref?: BaseFormProps['ref'];\n}\n\nexport default MultiStepFormProps;\n"]}
@@ -0,0 +1,2 @@
1
+ export { default } from './MultiStepForm';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MultiStepForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from './MultiStepForm';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MultiStepForm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { default } from './MultiStepForm';\n"]}
@@ -5,11 +5,6 @@ export interface NumberDisplayProps extends BaseProps, NoChildrenProp {
5
5
  value?: number | bigint;
6
6
  /** Unit to be included in the text, for example '%' */
7
7
  unit?: string;
8
- /**
9
- * Determines the placement of the unit.
10
- * @default "after"
11
- */
12
- unitPlacement?: 'before' | 'after';
13
8
  formattingOptions?: {
14
9
  /**
15
10
  * Value display notation.
@@ -1 +1 @@
1
- {"version":3,"file":"NumberDisplay.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAK3E,MAAM,WAAW,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IACnE,mBAAmB;IACnB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a,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CA+BvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,19 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from 'react';
3
3
  import { useConfiguration } from '../../hooks';
4
- import { getFraction, formatNumber } from './utils';
5
- const NumberDisplay = forwardRef(({ value, unit = '', unitPlacement = 'after', formattingOptions: { fractionDigits = getFraction(String(value)).substring(1).length, notation, groupSeparators = true } = {}, ...restProps }, ref) => {
4
+ import { getFraction, getFormattedValue } from './utils';
5
+ const NumberDisplay = forwardRef(({ value, unit = '', formattingOptions: { fractionDigits = getFraction(String(value)).substring(1).length, notation, groupSeparators = true } = {}, ...restProps }, ref) => {
6
6
  const { locale } = useConfiguration();
7
- const options = {
8
- minimumFractionDigits: fractionDigits,
9
- maximumFractionDigits: fractionDigits,
10
- useGrouping: groupSeparators,
11
- notation
12
- };
13
- return (_jsx("span", { ref: ref, ...restProps, children: value || value === 0 ? (`${unit && unitPlacement === 'before' ? `${unit}\u00a0` : ''}${formatNumber(value, {
14
- locale,
15
- options
16
- })}${unit && unitPlacement === 'after' ? `\u00a0${unit}` : ''}`) : (_jsx("span", { "aria-hidden": 'true', children: "\u2013\u2013" })) }));
7
+ return (_jsx("span", { ref: ref, ...restProps, children: value || value === 0 ? (getFormattedValue(value.toString(), locale, unit, {
8
+ notation,
9
+ useGrouping: groupSeparators,
10
+ maximumFractionDigits: fractionDigits,
11
+ minimumFractionDigits: fractionDigits
12
+ })) : (_jsx("span", { "aria-hidden": 'true', children: "\u2013\u2013" })) }));
17
13
  });
18
14
  export default NumberDisplay;
19
15
  //# sourceMappingURL=NumberDisplay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NumberDisplay.js","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkCpD,MAAM,aAAa,GAAyD,UAAU,CACpF,CACE,EACE,KAAK,EACL,IAAI,GAAG,EAAE,EACT,aAAa,GAAG,OAAO,EACvB,iBAAiB,EAAE,EACjB,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAC/D,QAAQ,EACR,eAAe,GAAG,IAAI,EACvB,GAAG,EAAE,EACN,GAAG,SAAS,EACwB,EACtC,GAA8B,EAC9B,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,MAAM,OAAO,GAAG;QACd,qBAAqB,EAAE,cAAc;QACrC,qBAAqB,EAAE,cAAc;QACrC,WAAW,EAAE,eAAe;QAC5B,QAAQ;KACmB,CAAC;IAE9B,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACtB,GAAG,IAAI,IAAI,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,KAAK,EAAE;YACjF,MAAM;YACN,OAAO;SACR,CAAC,GAAG,IAAI,IAAI,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAChE,CAAC,CAAC,CAAC,CACF,8BAAkB,MAAM,6BAAsB,CAC/C,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { useConfiguration } from '../../hooks';\n\nimport { getFraction, formatNumber } from './utils';\n\nexport interface NumberDisplayProps extends BaseProps, NoChildrenProp {\n /** Number value */\n value?: number | bigint;\n /** Unit to be included in the text, for example '%' */\n unit?: string;\n /**\n * Determines the placement of the unit.\n * @default \"after\"\n */\n unitPlacement?: 'before' | 'after';\n formattingOptions?: {\n /**\n * Value display notation.\n * @default 'standard'\n */\n notation?: 'standard' | 'compact';\n /**\n * Determines the fixed number of fraction digits. The value is rounded to the given precision.\n * Maximum is 20, default is value precision.\n * @default variable\n */\n fractionDigits?: number;\n /**\n * Determines whether group separators should be shown.\n * @default true\n */\n groupSeparators?: boolean;\n };\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLSpanElement>;\n}\n\nconst NumberDisplay: FunctionComponent<NumberDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value,\n unit = '',\n unitPlacement = 'after',\n formattingOptions: {\n fractionDigits = getFraction(String(value)).substring(1).length,\n notation,\n groupSeparators = true\n } = {},\n ...restProps\n }: PropsWithoutRef<NumberDisplayProps>,\n ref: NumberDisplayProps['ref']\n ) => {\n const { locale } = useConfiguration();\n\n const options = {\n minimumFractionDigits: fractionDigits,\n maximumFractionDigits: fractionDigits,\n useGrouping: groupSeparators,\n notation\n } as Intl.NumberFormatOptions;\n\n return (\n <span ref={ref} {...restProps}>\n {value || value === 0 ? (\n `${unit && unitPlacement === 'before' ? `${unit}\\u00a0` : ''}${formatNumber(value, {\n locale,\n options\n })}${unit && unitPlacement === 'after' ? `\\u00a0${unit}` : ''}`\n ) : (\n <span aria-hidden='true'>&ndash;&ndash;</span>\n )}\n </span>\n );\n }\n);\n\nexport default NumberDisplay;\n"]}
1
+ {"version":3,"file":"NumberDisplay.js","sourceRoot":"","sources":["../../../src/components/Number/NumberDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA8BzD,MAAM,aAAa,GAAyD,UAAU,CACpF,CACE,EACE,KAAK,EACL,IAAI,GAAG,EAAE,EACT,iBAAiB,EAAE,EACjB,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,EAC/D,QAAQ,EACR,eAAe,GAAG,IAAI,EACvB,GAAG,EAAE,EACN,GAAG,SAAS,EACwB,EACtC,GAA8B,EAC9B,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,OAAO,CACL,eAAM,GAAG,EAAE,GAAG,KAAM,SAAS,YAC1B,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CACtB,iBAAiB,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YAChD,QAAQ;YACR,WAAW,EAAE,eAAe;YAC5B,qBAAqB,EAAE,cAAc;YACrC,qBAAqB,EAAE,cAAc;SACtC,CAAC,CACH,CAAC,CAAC,CAAC,CACF,8BAAkB,MAAM,6BAAsB,CAC/C,GACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { useConfiguration } from '../../hooks';\n\nimport { getFraction, getFormattedValue } from './utils';\n\nexport interface NumberDisplayProps extends BaseProps, NoChildrenProp {\n /** Number value */\n value?: number | bigint;\n /** Unit to be included in the text, for example '%' */\n unit?: string;\n\n formattingOptions?: {\n /**\n * Value display notation.\n * @default 'standard'\n */\n notation?: 'standard' | 'compact';\n /**\n * Determines the fixed number of fraction digits. The value is rounded to the given precision.\n * Maximum is 20, default is value precision.\n * @default variable\n */\n fractionDigits?: number;\n /**\n * Determines whether group separators should be shown.\n * @default true\n */\n groupSeparators?: boolean;\n };\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLSpanElement>;\n}\n\nconst NumberDisplay: FunctionComponent<NumberDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value,\n unit = '',\n formattingOptions: {\n fractionDigits = getFraction(String(value)).substring(1).length,\n notation,\n groupSeparators = true\n } = {},\n ...restProps\n }: PropsWithoutRef<NumberDisplayProps>,\n ref: NumberDisplayProps['ref']\n ) => {\n const { locale } = useConfiguration();\n\n return (\n <span ref={ref} {...restProps}>\n {value || value === 0 ? (\n getFormattedValue(value.toString(), locale, unit, {\n notation,\n useGrouping: groupSeparators,\n maximumFractionDigits: fractionDigits,\n minimumFractionDigits: fractionDigits\n })\n ) : (\n <span aria-hidden='true'>&ndash;&ndash;</span>\n )}\n </span>\n );\n }\n);\n\nexport default NumberDisplay;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,OAAO,gBAA+C,MAAM,qBAAqB,CAAC;AAWlF,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAuLnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/Number/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAQf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAW3C,OAAO,gBAA+C,MAAM,qBAAqB,CAAC;AAWlF,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CA0LnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -18,18 +18,21 @@ const NumberInput = forwardRef((props, ref) => {
18
18
  const { locale } = useConfiguration();
19
19
  const inputRef = useConsolidatedRef(ref);
20
20
  const containerRef = useRef(null);
21
- const numberOfDecimals = showDecimal ? numberOfDecimalsProp : 0;
21
+ const maximumFractionDigits = showDecimal ? numberOfDecimalsProp : 0;
22
22
  const decimalSign = useMemo(() => getDecimalSign(locale), [locale]);
23
23
  const formatValue = useCallback(number => {
24
- return getFormattedValue(number, locale, unit, { showGroupSeparators, numberOfDecimals });
25
- }, [locale, unit, showGroupSeparators, numberOfDecimals]);
24
+ return getFormattedValue(number, locale, unit, {
25
+ useGrouping: showGroupSeparators,
26
+ maximumFractionDigits
27
+ });
28
+ }, [locale, unit, showGroupSeparators, maximumFractionDigits]);
26
29
  const onInputChange = useCallback((e) => {
27
30
  const inputValue = e.target.value;
28
- const cleanedInputValue = getCleanedValue(inputValue, decimalSign, numberOfDecimals);
31
+ const cleanedInputValue = getCleanedValue(inputValue, decimalSign, maximumFractionDigits);
29
32
  if (cleanedInputValue === value)
30
33
  return;
31
34
  onChange(cleanedInputValue);
32
- }, [onChange, decimalSign, value, numberOfDecimals]);
35
+ }, [onChange, decimalSign, value, maximumFractionDigits]);
33
36
  const onKeyDown = (e) => {
34
37
  if (readOnly)
35
38
  return;