@kosdev-code/kos-ddk-components 3.1.1 → 3.1.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.
@@ -3,4 +3,5 @@ export * from './footer';
3
3
  export * from './header';
4
4
  export * from './modal';
5
5
  export * from './modal-container';
6
+ export * from './utility-modal';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ddk-components/src/components/modal/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ddk-components/src/components/modal/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './use-utility-modal';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ddk-components/src/components/modal/utility-modal/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { HeaderProps } from '../header';
2
+ import { ModalProps } from '../modal';
3
+ /**
4
+ * How a utility's modal fills the screen: `maximized` (the default) is a modal
5
+ * over the shell, `fullscreen` covers the whole display with no frame.
6
+ */
7
+ export type UtilityModalLayout = "maximized" | "fullscreen";
8
+ export interface UseUtilityModalOptions {
9
+ /** The utility experience's `onComplete`: called once the modal has closed. */
10
+ onComplete?: () => void;
11
+ /** Runs when the modal starts to close, before `onComplete` (reset models here). */
12
+ onClose?: () => void;
13
+ layout?: UtilityModalLayout;
14
+ /** Steps back inside the utility: the header's back button in standard mode. */
15
+ onBack?: () => void;
16
+ /** Whether the utility can step back now; defaults to whether `onBack` is set. */
17
+ showBack?: boolean;
18
+ backButtonLabel?: string;
19
+ closeButtonLabel?: string;
20
+ }
21
+ export interface UtilityModal {
22
+ isCompact: boolean;
23
+ /** Closes the modal; `onComplete` runs when its exit transition ends. */
24
+ close: () => void;
25
+ /** Spread on `Modal`. */
26
+ modalProps: Omit<ModalProps, "children">;
27
+ /** Spread on `Header`, then set its `title` and `subtitle`. */
28
+ headerProps: Omit<HeaderProps, "title" | "subtitle">;
29
+ /** Compact mode has no header back button: render a Back button in the footer. */
30
+ showFooterBack: boolean;
31
+ }
32
+ /**
33
+ * The modal a utility experience renders in, for the component mode the DDK host
34
+ * runs in: the props for `Modal` and `Header`, and the closing mechanics.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * const { modalProps, headerProps, close } = useUtilityModal({ onComplete });
39
+ * return (
40
+ * <Modal {...modalProps}>
41
+ * <Header {...headerProps} title={t("title")} />
42
+ * <Content align="center">…</Content>
43
+ * <Footer>
44
+ * <Button mode="primary" onPointerDown={close}>{t("done")}</Button>
45
+ * </Footer>
46
+ * </Modal>
47
+ * );
48
+ * ```
49
+ */
50
+ export declare const useUtilityModal: ({ onComplete, onClose, layout, onBack, showBack, backButtonLabel, closeButtonLabel, }?: UseUtilityModalOptions) => UtilityModal;
51
+ //# sourceMappingURL=use-utility-modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-utility-modal.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ddk-components/src/components/modal/utility-modal/use-utility-modal.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,YAAY,CAAC;AAE5D,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,yBAAyB;IACzB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACzC,+DAA+D;IAC/D,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;IACrD,kFAAkF;IAClF,cAAc,EAAE,OAAO,CAAC;CACzB;AAaD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAAI,wFAQ7B,sBAA2B,KAAG,YAoDhC,CAAC"}
package/index.cjs CHANGED
@@ -4867,6 +4867,88 @@ const ModalContainer = styled.div`
4867
4867
  gap: var(--ddk-component-base-modal-container-gap);
4868
4868
  height: 100%;
4869
4869
  `;
4870
+ const BackText = () => {
4871
+ const { t } = kosUiSdk.useKosTranslation("common");
4872
+ return t("close");
4873
+ };
4874
+ const VolumeBackButton = ({
4875
+ children,
4876
+ fill,
4877
+ label,
4878
+ size = "medium",
4879
+ ...props
4880
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
4881
+ IconButton,
4882
+ {
4883
+ icon: fill ? kosDdkStyles.ChevronLeftIcon : kosDdkStyles.ChevronLeftIcon,
4884
+ size,
4885
+ ...props,
4886
+ children: label ?? /* @__PURE__ */ jsxRuntime.jsx(BackText, {})
4887
+ }
4888
+ );
4889
+ const backButton = (label) => function UtilityBackButton({ onPointerDown }) {
4890
+ return /* @__PURE__ */ jsxRuntime.jsx(
4891
+ VolumeBackButton,
4892
+ {
4893
+ onPointerDown,
4894
+ label,
4895
+ size: "small"
4896
+ }
4897
+ );
4898
+ };
4899
+ const useUtilityModal = ({
4900
+ onComplete,
4901
+ onClose,
4902
+ layout = "maximized",
4903
+ onBack,
4904
+ showBack = !!onBack,
4905
+ backButtonLabel = "Back",
4906
+ closeButtonLabel = "Close"
4907
+ } = {}) => {
4908
+ const { componentModeOverride } = useComponentConfigurationContext();
4909
+ const isCompact = componentModeOverride === "compact";
4910
+ const [closing, setClosing] = React.useState(false);
4911
+ const close = React.useCallback(() => {
4912
+ onClose?.();
4913
+ setClosing(true);
4914
+ }, [onClose]);
4915
+ const BackButton2 = React.useMemo(() => backButton(backButtonLabel), [
4916
+ backButtonLabel
4917
+ ]);
4918
+ const fullscreen = layout === "fullscreen";
4919
+ const modalProps = {
4920
+ show: !closing,
4921
+ mode: layout,
4922
+ contain: fullscreen ? false : !isCompact,
4923
+ // A utility closes from its own controls, never from a tap outside it.
4924
+ closeOnShroudClick: false,
4925
+ onClose: close,
4926
+ onClosed: onComplete
4927
+ };
4928
+ const headerProps = fullscreen ? {
4929
+ contain: true,
4930
+ raiseCloseButton: true,
4931
+ showCloseButton: true,
4932
+ closeButtonLabel,
4933
+ onClose: close
4934
+ } : {
4935
+ contain: isCompact,
4936
+ CloseButton: isCompact ? CompactCloseButton : void 0,
4937
+ showCloseButton: true,
4938
+ closeButtonLabel,
4939
+ onClose: close,
4940
+ OpenButton: BackButton2,
4941
+ showOpenButton: !isCompact && showBack,
4942
+ onOpen: onBack
4943
+ };
4944
+ return {
4945
+ isCompact,
4946
+ close,
4947
+ modalProps,
4948
+ headerProps,
4949
+ showFooterBack: isCompact && showBack
4950
+ };
4951
+ };
4870
4952
  const WorkflowModalBase = styled(Modal)`
4871
4953
  --ddk-component-modal-min-height: var(
4872
4954
  --ddk-component-workflow-modal-min-height
@@ -11122,25 +11204,6 @@ const viewStyles = react.css`
11122
11204
  padding: var(--ddk-component-view-padding);
11123
11205
  `;
11124
11206
  const View = ({ children, contain = true, style }) => contain ? /* @__PURE__ */ jsxRuntime.jsx(Container$8, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { css: [viewStyles, style], children }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { css: [viewStyles, style], children });
11125
- const BackText = () => {
11126
- const { t } = kosUiSdk.useKosTranslation("common");
11127
- return t("close");
11128
- };
11129
- const VolumeBackButton = ({
11130
- children,
11131
- fill,
11132
- label,
11133
- size = "medium",
11134
- ...props
11135
- }) => /* @__PURE__ */ jsxRuntime.jsx(
11136
- IconButton,
11137
- {
11138
- icon: fill ? kosDdkStyles.ChevronLeftIcon : kosDdkStyles.ChevronLeftIcon,
11139
- size,
11140
- ...props,
11141
- children: label ?? /* @__PURE__ */ jsxRuntime.jsx(BackText, {})
11142
- }
11143
- );
11144
11207
  exports.ActionCard = ActionCard;
11145
11208
  exports.ActionItem = ActionItem;
11146
11209
  exports.ActionItemButton = ActionItemButton;
@@ -11314,6 +11377,7 @@ exports.useComponentConfigurationContext = useComponentConfigurationContext;
11314
11377
  exports.useExperience = useExperience;
11315
11378
  exports.useKeyboardToggle = useKeyboardToggle;
11316
11379
  exports.useNavigate = useNavigate;
11380
+ exports.useUtilityModal = useUtilityModal;
11317
11381
  exports.useViewExperience = useViewExperience;
11318
11382
  exports.useViewExperienceListMap = useViewExperienceListMap;
11319
11383
  //# sourceMappingURL=index.cjs.map