@pixpilot/shadcn-ui 2.1.0 → 3.0.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 (112) hide show
  1. package/dist/absolute-fill/AbsoluteFill.d.ts +2 -2
  2. package/dist/button/Button.d.cts +2 -2
  3. package/dist/button-extended/ButtonExtended.d.cts +2 -2
  4. package/dist/button-extended/ButtonExtended.d.ts +2 -2
  5. package/dist/card/Card.d.ts +3 -3
  6. package/dist/color-select/ColorSelect.d.ts +2 -2
  7. package/dist/confirmation-dialog/ConfirmationDialog.cjs +2 -2
  8. package/dist/confirmation-dialog/ConfirmationDialog.js +2 -2
  9. package/dist/confirmation-dialog/mcp.js +3 -3
  10. package/dist/content-card/ContentCard.d.cts +2 -2
  11. package/dist/date-picker/DatePicker.d.cts +2 -2
  12. package/dist/date-picker/DatePicker.d.ts +2 -2
  13. package/dist/dialog/Dialog.d.cts +5 -5
  14. package/dist/dialog/Dialog.d.ts +5 -5
  15. package/dist/dialog/mcp.js +1 -1
  16. package/dist/dialog-registry/dialog-registry.cjs +24 -0
  17. package/dist/dialog-registry/dialog-registry.d.cts +23 -0
  18. package/dist/dialog-registry/dialog-registry.d.ts +23 -0
  19. package/dist/dialog-registry/dialog-registry.js +23 -0
  20. package/dist/dialog-registry/index.d.cts +3 -0
  21. package/dist/dialog-registry/index.d.ts +3 -0
  22. package/dist/dialog-registry/mcp.js +51 -0
  23. package/dist/dialog-registry/register-dialog.cjs +20 -0
  24. package/dist/dialog-registry/register-dialog.d.cts +21 -0
  25. package/dist/dialog-registry/register-dialog.d.ts +21 -0
  26. package/dist/dialog-registry/register-dialog.js +20 -0
  27. package/dist/dialog-registry/show-dialog.cjs +17 -0
  28. package/dist/dialog-registry/show-dialog.d.cts +18 -0
  29. package/dist/dialog-registry/show-dialog.d.ts +18 -0
  30. package/dist/dialog-registry/show-dialog.js +17 -0
  31. package/dist/drawer/Drawer.cjs +57 -0
  32. package/dist/drawer/Drawer.d.cts +40 -0
  33. package/dist/drawer/Drawer.d.ts +40 -0
  34. package/dist/drawer/Drawer.js +49 -0
  35. package/dist/drawer/index.d.cts +3 -0
  36. package/dist/drawer/index.d.ts +3 -0
  37. package/dist/drawer/index.js +4 -0
  38. package/dist/drawer/mcp.js +55 -0
  39. package/dist/drawer-registry/drawer-registry.cjs +28 -0
  40. package/dist/drawer-registry/drawer-registry.d.cts +27 -0
  41. package/dist/drawer-registry/drawer-registry.d.ts +27 -0
  42. package/dist/drawer-registry/drawer-registry.js +27 -0
  43. package/dist/drawer-registry/index.d.cts +3 -0
  44. package/dist/drawer-registry/index.d.ts +3 -0
  45. package/dist/drawer-registry/mcp.js +51 -0
  46. package/dist/drawer-registry/register-drawer.cjs +20 -0
  47. package/dist/drawer-registry/register-drawer.d.cts +21 -0
  48. package/dist/drawer-registry/register-drawer.d.ts +21 -0
  49. package/dist/drawer-registry/register-drawer.js +20 -0
  50. package/dist/drawer-registry/show-drawer.cjs +17 -0
  51. package/dist/drawer-registry/show-drawer.d.cts +18 -0
  52. package/dist/drawer-registry/show-drawer.d.ts +18 -0
  53. package/dist/drawer-registry/show-drawer.js +17 -0
  54. package/dist/file-upload/FileUpload.d.cts +2 -2
  55. package/dist/file-upload/FileUpload.d.ts +2 -2
  56. package/dist/file-upload-inline/FileUploadInline.d.cts +2 -2
  57. package/dist/file-upload-inline/FileUploadInline.d.ts +2 -2
  58. package/dist/file-upload-root/FileUploadRoot.d.cts +2 -2
  59. package/dist/file-upload-root/FileUploadRoot.d.ts +2 -2
  60. package/dist/generated/mcp-registry.js +38 -32
  61. package/dist/index.cjs +32 -9
  62. package/dist/index.d.cts +14 -6
  63. package/dist/index.d.ts +14 -6
  64. package/dist/index.js +11 -5
  65. package/dist/input/Input.d.cts +2 -2
  66. package/dist/input/Input.d.ts +2 -2
  67. package/dist/overlay-provider/OverlayProvider.cjs +47 -0
  68. package/dist/overlay-provider/OverlayProvider.d.cts +18 -0
  69. package/dist/overlay-provider/OverlayProvider.d.ts +18 -0
  70. package/dist/overlay-provider/OverlayProvider.js +42 -0
  71. package/dist/overlay-provider/index.d.cts +2 -0
  72. package/dist/overlay-provider/index.d.ts +2 -0
  73. package/dist/overlay-provider/mcp.js +35 -0
  74. package/dist/overlay-provider/overlay-registry.cjs +104 -0
  75. package/dist/overlay-provider/overlay-registry.d.cts +91 -0
  76. package/dist/overlay-provider/overlay-registry.d.ts +91 -0
  77. package/dist/overlay-provider/overlay-registry.js +94 -0
  78. package/dist/overlay-provider/types.d.cts +20 -0
  79. package/dist/overlay-provider/types.d.ts +20 -0
  80. package/dist/rating/Rating.d.ts +3 -3
  81. package/dist/select/Select.d.ts +2 -2
  82. package/dist/tags-input/TagsInput.d.cts +2 -2
  83. package/dist/tags-input/TagsInput.d.ts +2 -2
  84. package/dist/tags-input/TagsInputInline.d.ts +2 -2
  85. package/dist/theme-toggle/ThemeModeDropdown.d.cts +2 -2
  86. package/dist/theme-toggle/ThemeModeDropdown.d.ts +2 -2
  87. package/dist/theme-toggle/ThemeModeSwitchInside.d.cts +2 -2
  88. package/dist/theme-toggle/ThemeModeSwitchInside.d.ts +2 -2
  89. package/dist/theme-toggle/ThemeModeSwitchOutside.d.cts +2 -2
  90. package/dist/theme-toggle/ThemeModeSwitchOutside.d.ts +2 -2
  91. package/dist/theme-toggle/ThemeModeToggleButton.d.cts +2 -2
  92. package/dist/theme-toggle/ThemeModeToggleButton.d.ts +2 -2
  93. package/package.json +5 -5
  94. package/dist/dialog-provider/DialogProvider.cjs +0 -40
  95. package/dist/dialog-provider/DialogProvider.d.cts +0 -28
  96. package/dist/dialog-provider/DialogProvider.d.ts +0 -28
  97. package/dist/dialog-provider/DialogProvider.js +0 -36
  98. package/dist/dialog-provider/dialog-registry.cjs +0 -100
  99. package/dist/dialog-provider/dialog-registry.d.cts +0 -150
  100. package/dist/dialog-provider/dialog-registry.d.ts +0 -150
  101. package/dist/dialog-provider/dialog-registry.js +0 -93
  102. package/dist/dialog-provider/index.d.cts +0 -4
  103. package/dist/dialog-provider/index.d.ts +0 -4
  104. package/dist/dialog-provider/mcp.js +0 -24
  105. package/dist/dialog-provider/register-dialog.cjs +0 -64
  106. package/dist/dialog-provider/register-dialog.d.cts +0 -98
  107. package/dist/dialog-provider/register-dialog.d.ts +0 -98
  108. package/dist/dialog-provider/register-dialog.js +0 -61
  109. package/dist/dialog-provider/show-dialog.cjs +0 -30
  110. package/dist/dialog-provider/show-dialog.d.cts +0 -24
  111. package/dist/dialog-provider/show-dialog.d.ts +0 -24
  112. package/dist/dialog-provider/show-dialog.js +0 -28
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/shadcn-ui",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "3.0.0",
5
5
  "description": "Custom UI components and utilities built with shadcn/ui.",
6
6
  "author": "m.doaie <m.doaie@hotmail.com>",
7
7
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  "react-responsive": "^10.0.1",
56
56
  "sonner": "2.0.7",
57
57
  "zod": "^4.3.6",
58
- "@pixpilot/shadcn": "1.4.1"
58
+ "@pixpilot/shadcn": "2.0.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@storybook/react": "^8.6.18",
@@ -71,12 +71,12 @@
71
71
  "tsdown": "^0.15.12",
72
72
  "tsx": "^4.21.0",
73
73
  "typescript": "^5.9.3",
74
- "@internal/eslint-config": "0.3.0",
75
- "@internal/prettier-config": "0.0.1",
76
- "@internal/mcp": "0.0.0",
77
74
  "@internal/hooks": "0.0.0",
75
+ "@internal/mcp": "0.0.0",
76
+ "@internal/prettier-config": "0.0.1",
78
77
  "@internal/tsconfig": "0.1.0",
79
78
  "@internal/tsdown-config": "0.1.0",
79
+ "@internal/eslint-config": "0.3.0",
80
80
  "@internal/vitest-config": "0.1.0"
81
81
  },
82
82
  "prettier": "@internal/prettier-config",
@@ -1,40 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- let react = require("react");
3
- react = require_rolldown_runtime.__toESM(react);
4
- let react_jsx_runtime = require("react/jsx-runtime");
5
- react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
6
- let __ebay_nice_modal_react = require("@ebay/nice-modal-react");
7
- __ebay_nice_modal_react = require_rolldown_runtime.__toESM(__ebay_nice_modal_react);
8
-
9
- //#region src/dialog-provider/DialogProvider.tsx
10
- const DialogProviderMountedContext = (0, react.createContext)(false);
11
- /**
12
- * Guards against nested DialogProviders, which would break NiceModal.
13
- *
14
- * NiceModal.Provider creates its own isolated modal state store via React context.
15
- * If a second NiceModal.Provider mounts anywhere below the first, it shadows the
16
- * outer one — meaning modals registered/shown inside the inner provider are
17
- * invisible to the outer one, and vice versa.
18
- *
19
- * This becomes especially bad with navigation: when you navigate away and back,
20
- * the inner provider unmounts and remounts, creating a brand-new store. Any
21
- * in-flight `showConfirmDialog` calls still hold a reference to the old store's
22
- * dispatch, so their promises never resolve and the modal tree is left in a
23
- * broken state. This has been detected when navigating in a Next.js app,
24
- * but it could happen in any React app that conditionally mounts/unmounts providers.
25
- *
26
- * The fix: track whether a DialogProvider is already mounted above us in the tree.
27
- * If one is, skip rendering NiceModal.Provider entirely and just pass children
28
- * through — making the inner DialogProvider a safe no-op.
29
- */
30
- const DialogProvider = (props) => {
31
- if ((0, react.use)(DialogProviderMountedContext)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: props.children });
32
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DialogProviderMountedContext.Provider, {
33
- value: true,
34
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ebay_nice_modal_react.default.Provider, { children: props.children })
35
- });
36
- };
37
- DialogProvider.displayName = "DialogProvider";
38
-
39
- //#endregion
40
- exports.DialogProvider = DialogProvider;
@@ -1,28 +0,0 @@
1
- import React from "react";
2
-
3
- //#region src/dialog-provider/DialogProvider.d.ts
4
- interface DialogProviderProps {
5
- children: React.ReactNode;
6
- }
7
- /**
8
- * Guards against nested DialogProviders, which would break NiceModal.
9
- *
10
- * NiceModal.Provider creates its own isolated modal state store via React context.
11
- * If a second NiceModal.Provider mounts anywhere below the first, it shadows the
12
- * outer one — meaning modals registered/shown inside the inner provider are
13
- * invisible to the outer one, and vice versa.
14
- *
15
- * This becomes especially bad with navigation: when you navigate away and back,
16
- * the inner provider unmounts and remounts, creating a brand-new store. Any
17
- * in-flight `showConfirmDialog` calls still hold a reference to the old store's
18
- * dispatch, so their promises never resolve and the modal tree is left in a
19
- * broken state. This has been detected when navigating in a Next.js app,
20
- * but it could happen in any React app that conditionally mounts/unmounts providers.
21
- *
22
- * The fix: track whether a DialogProvider is already mounted above us in the tree.
23
- * If one is, skip rendering NiceModal.Provider entirely and just pass children
24
- * through — making the inner DialogProvider a safe no-op.
25
- */
26
- declare const DialogProvider: React.FC<DialogProviderProps>;
27
- //#endregion
28
- export { DialogProvider, DialogProviderProps };
@@ -1,28 +0,0 @@
1
- import React from "react";
2
-
3
- //#region src/dialog-provider/DialogProvider.d.ts
4
- interface DialogProviderProps {
5
- children: React.ReactNode;
6
- }
7
- /**
8
- * Guards against nested DialogProviders, which would break NiceModal.
9
- *
10
- * NiceModal.Provider creates its own isolated modal state store via React context.
11
- * If a second NiceModal.Provider mounts anywhere below the first, it shadows the
12
- * outer one — meaning modals registered/shown inside the inner provider are
13
- * invisible to the outer one, and vice versa.
14
- *
15
- * This becomes especially bad with navigation: when you navigate away and back,
16
- * the inner provider unmounts and remounts, creating a brand-new store. Any
17
- * in-flight `showConfirmDialog` calls still hold a reference to the old store's
18
- * dispatch, so their promises never resolve and the modal tree is left in a
19
- * broken state. This has been detected when navigating in a Next.js app,
20
- * but it could happen in any React app that conditionally mounts/unmounts providers.
21
- *
22
- * The fix: track whether a DialogProvider is already mounted above us in the tree.
23
- * If one is, skip rendering NiceModal.Provider entirely and just pass children
24
- * through — making the inner DialogProvider a safe no-op.
25
- */
26
- declare const DialogProvider: React.FC<DialogProviderProps>;
27
- //#endregion
28
- export { DialogProvider, DialogProviderProps };
@@ -1,36 +0,0 @@
1
- import React, { createContext, use } from "react";
2
- import { Fragment, jsx } from "react/jsx-runtime";
3
- import NiceModal from "@ebay/nice-modal-react";
4
-
5
- //#region src/dialog-provider/DialogProvider.tsx
6
- const DialogProviderMountedContext = createContext(false);
7
- /**
8
- * Guards against nested DialogProviders, which would break NiceModal.
9
- *
10
- * NiceModal.Provider creates its own isolated modal state store via React context.
11
- * If a second NiceModal.Provider mounts anywhere below the first, it shadows the
12
- * outer one — meaning modals registered/shown inside the inner provider are
13
- * invisible to the outer one, and vice versa.
14
- *
15
- * This becomes especially bad with navigation: when you navigate away and back,
16
- * the inner provider unmounts and remounts, creating a brand-new store. Any
17
- * in-flight `showConfirmDialog` calls still hold a reference to the old store's
18
- * dispatch, so their promises never resolve and the modal tree is left in a
19
- * broken state. This has been detected when navigating in a Next.js app,
20
- * but it could happen in any React app that conditionally mounts/unmounts providers.
21
- *
22
- * The fix: track whether a DialogProvider is already mounted above us in the tree.
23
- * If one is, skip rendering NiceModal.Provider entirely and just pass children
24
- * through — making the inner DialogProvider a safe no-op.
25
- */
26
- const DialogProvider = (props) => {
27
- if (use(DialogProviderMountedContext)) return /* @__PURE__ */ jsx(Fragment, { children: props.children });
28
- return /* @__PURE__ */ jsx(DialogProviderMountedContext.Provider, {
29
- value: true,
30
- children: /* @__PURE__ */ jsx(NiceModal.Provider, { children: props.children })
31
- });
32
- };
33
- DialogProvider.displayName = "DialogProvider";
34
-
35
- //#endregion
36
- export { DialogProvider };
@@ -1,100 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_register_dialog = require('./register-dialog.cjs');
3
- const require_show_dialog = require('./show-dialog.cjs');
4
- let __ebay_nice_modal_react = require("@ebay/nice-modal-react");
5
- __ebay_nice_modal_react = require_rolldown_runtime.__toESM(__ebay_nice_modal_react);
6
-
7
- //#region src/dialog-provider/dialog-registry.ts
8
- const useDialog = __ebay_nice_modal_react.useModal;
9
- function createDialog(component) {
10
- const CreatedDialog = __ebay_nice_modal_react.default.create(component);
11
- return Object.assign(CreatedDialog, {
12
- show: async (props) => __ebay_nice_modal_react.default.show(CreatedDialog, props),
13
- hide: async () => __ebay_nice_modal_react.default.hide(CreatedDialog),
14
- remove: () => {
15
- __ebay_nice_modal_react.default.remove(CreatedDialog);
16
- }
17
- });
18
- }
19
- /**
20
- * Hides a registered dialog by id.
21
- *
22
- * Use this when the caller only knows the dialog id. If you already have the
23
- * controller returned by `dialog.register(...)`, prefer `controller.hide()`.
24
- *
25
- * @param id - Dialog id that was previously registered.
26
- * @returns A promise from NiceModal that resolves after the hide action is
27
- * dispatched.
28
- *
29
- * Usage:
30
- * ```ts
31
- * await hideDialog('project-dialog');
32
- * ```
33
- */
34
- async function hideDialog(id) {
35
- return __ebay_nice_modal_react.default.hide(id);
36
- }
37
- /**
38
- * Removes a registered dialog instance from the NiceModal render tree by id.
39
- *
40
- * This does not unregister the dialog component; it only removes the mounted
41
- * instance from the modal tree.
42
- *
43
- * @param id - Dialog id that was previously registered.
44
- * Usage:
45
- * ```ts
46
- * removeDialog('project-dialog');
47
- * ```
48
- */
49
- function removeDialog(id) {
50
- __ebay_nice_modal_react.default.remove(id);
51
- }
52
- /**
53
- * Unregisters a dialog component by id.
54
- *
55
- * Use this when a registered dialog should no longer be available through
56
- * `showDialog(...)` or `dialog.show(...)`.
57
- *
58
- * @param id - Dialog id that was previously registered.
59
- * Usage:
60
- * ```ts
61
- * unregisterDialog('project-dialog');
62
- * ```
63
- */
64
- function unregisterDialog(id) {
65
- (0, __ebay_nice_modal_react.unregister)(id);
66
- }
67
- /**
68
- * Convenience registry facade for dialog operations.
69
- *
70
- * Use this when you prefer a single import with discoverable methods instead of
71
- * importing `registerDialog`, `showDialog`, `hideDialog`, `removeDialog`, and
72
- * `unregisterDialog` separately.
73
- *
74
- * @returns An object of dialog helper functions.
75
- *
76
- * Usage:
77
- * ```ts
78
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
79
- * await projectDialog.show({ projectId: 'project-1' });
80
- * await dialog.show('project-dialog', { projectId: 'project-2' });
81
- * dialog.unregister('project-dialog');
82
- * ```
83
- */
84
- const dialog = {
85
- create: createDialog,
86
- hide: hideDialog,
87
- register: require_register_dialog.registerDialog,
88
- remove: removeDialog,
89
- show: require_show_dialog.showDialog,
90
- unregister: unregisterDialog,
91
- useDialog
92
- };
93
-
94
- //#endregion
95
- exports.createDialog = createDialog;
96
- exports.dialog = dialog;
97
- exports.hideDialog = hideDialog;
98
- exports.removeDialog = removeDialog;
99
- exports.unregisterDialog = unregisterDialog;
100
- exports.useDialog = useDialog;
@@ -1,150 +0,0 @@
1
- import { registerDialog } from "./register-dialog.cjs";
2
- import { showDialog } from "./show-dialog.cjs";
3
- import { ComponentType, FC } from "react";
4
- import { NiceModalHocProps, useModal } from "@ebay/nice-modal-react";
5
-
6
- //#region src/dialog-provider/dialog-registry.d.ts
7
- declare const useDialog: typeof useModal;
8
- interface CreatedDialog<TProps extends object> extends FC<TProps & NiceModalHocProps> {
9
- show: <TResult = unknown>(props?: TProps) => Promise<TResult>;
10
- hide: <TResult = unknown>() => Promise<TResult>;
11
- remove: () => void;
12
- }
13
- declare function createDialog<TProps extends object>(component: ComponentType<TProps>): CreatedDialog<TProps>;
14
- /**
15
- * Hides a registered dialog by id.
16
- *
17
- * Use this when the caller only knows the dialog id. If you already have the
18
- * controller returned by `dialog.register(...)`, prefer `controller.hide()`.
19
- *
20
- * @param id - Dialog id that was previously registered.
21
- * @returns A promise from NiceModal that resolves after the hide action is
22
- * dispatched.
23
- *
24
- * Usage:
25
- * ```ts
26
- * await hideDialog('project-dialog');
27
- * ```
28
- */
29
- declare function hideDialog<TResult = unknown>(id: string): Promise<TResult>;
30
- /**
31
- * Removes a registered dialog instance from the NiceModal render tree by id.
32
- *
33
- * This does not unregister the dialog component; it only removes the mounted
34
- * instance from the modal tree.
35
- *
36
- * @param id - Dialog id that was previously registered.
37
- * Usage:
38
- * ```ts
39
- * removeDialog('project-dialog');
40
- * ```
41
- */
42
- declare function removeDialog(id: string): void;
43
- /**
44
- * Unregisters a dialog component by id.
45
- *
46
- * Use this when a registered dialog should no longer be available through
47
- * `showDialog(...)` or `dialog.show(...)`.
48
- *
49
- * @param id - Dialog id that was previously registered.
50
- * Usage:
51
- * ```ts
52
- * unregisterDialog('project-dialog');
53
- * ```
54
- */
55
- declare function unregisterDialog(id: string): void;
56
- interface DialogRegistry {
57
- /**
58
- * Registers a dialog component and returns a typed controller.
59
- *
60
- * @returns A controller with `id`, `show`, `hide`, and `remove`.
61
- *
62
- * Usage:
63
- * ```ts
64
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
65
- * ```
66
- */
67
- register: typeof registerDialog;
68
- /**
69
- * Creates a custom NiceModal dialog component with controller helpers.
70
- *
71
- * Use this for dialogs that need to control `useDialog()` directly. For simple
72
- * shadcn dialogs, prefer `dialog.register(...)`.
73
- *
74
- * Usage:
75
- * ```ts
76
- * const CustomDialog = dialog.create((props) => {
77
- * const modal = dialog.useDialog();
78
- * return <Dialog open={modal.visible} onOpenChange={(open) => !open && modal.hide()} />;
79
- * });
80
- *
81
- * await CustomDialog.show({ projectId: 'project-1' });
82
- * ```
83
- */
84
- create: typeof createDialog;
85
- /**
86
- * Shows a registered dialog by id with generic props.
87
- *
88
- * @returns A promise resolved by the dialog component.
89
- *
90
- * Usage:
91
- * ```ts
92
- * await dialog.show('project-dialog', { projectId: 'project-1' });
93
- * ```
94
- */
95
- show: typeof showDialog;
96
- /**
97
- * Hides a registered dialog by id.
98
- *
99
- * @returns A promise from NiceModal after the hide action is dispatched.
100
- *
101
- * Usage:
102
- * ```ts
103
- * await dialog.hide('project-dialog');
104
- * ```
105
- */
106
- hide: typeof hideDialog;
107
- /**
108
- * Removes a registered dialog instance from the render tree by id.
109
- *
110
- * @returns Nothing.
111
- *
112
- * Usage:
113
- * ```ts
114
- * dialog.remove('project-dialog');
115
- * ```
116
- */
117
- remove: typeof removeDialog;
118
- /**
119
- * Unregisters a dialog component by id.
120
- *
121
- * @returns Nothing.
122
- *
123
- * Usage:
124
- * ```ts
125
- * dialog.unregister('project-dialog');
126
- * ```
127
- */
128
- unregister: typeof unregisterDialog;
129
- useDialog: typeof useDialog;
130
- }
131
- /**
132
- * Convenience registry facade for dialog operations.
133
- *
134
- * Use this when you prefer a single import with discoverable methods instead of
135
- * importing `registerDialog`, `showDialog`, `hideDialog`, `removeDialog`, and
136
- * `unregisterDialog` separately.
137
- *
138
- * @returns An object of dialog helper functions.
139
- *
140
- * Usage:
141
- * ```ts
142
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
143
- * await projectDialog.show({ projectId: 'project-1' });
144
- * await dialog.show('project-dialog', { projectId: 'project-2' });
145
- * dialog.unregister('project-dialog');
146
- * ```
147
- */
148
- declare const dialog: DialogRegistry;
149
- //#endregion
150
- export { CreatedDialog, DialogRegistry, createDialog, dialog, hideDialog, removeDialog, unregisterDialog, useDialog };
@@ -1,150 +0,0 @@
1
- import { registerDialog } from "./register-dialog.js";
2
- import { showDialog } from "./show-dialog.js";
3
- import { ComponentType, FC } from "react";
4
- import { NiceModalHocProps, useModal } from "@ebay/nice-modal-react";
5
-
6
- //#region src/dialog-provider/dialog-registry.d.ts
7
- declare const useDialog: typeof useModal;
8
- interface CreatedDialog<TProps extends object> extends FC<TProps & NiceModalHocProps> {
9
- show: <TResult = unknown>(props?: TProps) => Promise<TResult>;
10
- hide: <TResult = unknown>() => Promise<TResult>;
11
- remove: () => void;
12
- }
13
- declare function createDialog<TProps extends object>(component: ComponentType<TProps>): CreatedDialog<TProps>;
14
- /**
15
- * Hides a registered dialog by id.
16
- *
17
- * Use this when the caller only knows the dialog id. If you already have the
18
- * controller returned by `dialog.register(...)`, prefer `controller.hide()`.
19
- *
20
- * @param id - Dialog id that was previously registered.
21
- * @returns A promise from NiceModal that resolves after the hide action is
22
- * dispatched.
23
- *
24
- * Usage:
25
- * ```ts
26
- * await hideDialog('project-dialog');
27
- * ```
28
- */
29
- declare function hideDialog<TResult = unknown>(id: string): Promise<TResult>;
30
- /**
31
- * Removes a registered dialog instance from the NiceModal render tree by id.
32
- *
33
- * This does not unregister the dialog component; it only removes the mounted
34
- * instance from the modal tree.
35
- *
36
- * @param id - Dialog id that was previously registered.
37
- * Usage:
38
- * ```ts
39
- * removeDialog('project-dialog');
40
- * ```
41
- */
42
- declare function removeDialog(id: string): void;
43
- /**
44
- * Unregisters a dialog component by id.
45
- *
46
- * Use this when a registered dialog should no longer be available through
47
- * `showDialog(...)` or `dialog.show(...)`.
48
- *
49
- * @param id - Dialog id that was previously registered.
50
- * Usage:
51
- * ```ts
52
- * unregisterDialog('project-dialog');
53
- * ```
54
- */
55
- declare function unregisterDialog(id: string): void;
56
- interface DialogRegistry {
57
- /**
58
- * Registers a dialog component and returns a typed controller.
59
- *
60
- * @returns A controller with `id`, `show`, `hide`, and `remove`.
61
- *
62
- * Usage:
63
- * ```ts
64
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
65
- * ```
66
- */
67
- register: typeof registerDialog;
68
- /**
69
- * Creates a custom NiceModal dialog component with controller helpers.
70
- *
71
- * Use this for dialogs that need to control `useDialog()` directly. For simple
72
- * shadcn dialogs, prefer `dialog.register(...)`.
73
- *
74
- * Usage:
75
- * ```ts
76
- * const CustomDialog = dialog.create((props) => {
77
- * const modal = dialog.useDialog();
78
- * return <Dialog open={modal.visible} onOpenChange={(open) => !open && modal.hide()} />;
79
- * });
80
- *
81
- * await CustomDialog.show({ projectId: 'project-1' });
82
- * ```
83
- */
84
- create: typeof createDialog;
85
- /**
86
- * Shows a registered dialog by id with generic props.
87
- *
88
- * @returns A promise resolved by the dialog component.
89
- *
90
- * Usage:
91
- * ```ts
92
- * await dialog.show('project-dialog', { projectId: 'project-1' });
93
- * ```
94
- */
95
- show: typeof showDialog;
96
- /**
97
- * Hides a registered dialog by id.
98
- *
99
- * @returns A promise from NiceModal after the hide action is dispatched.
100
- *
101
- * Usage:
102
- * ```ts
103
- * await dialog.hide('project-dialog');
104
- * ```
105
- */
106
- hide: typeof hideDialog;
107
- /**
108
- * Removes a registered dialog instance from the render tree by id.
109
- *
110
- * @returns Nothing.
111
- *
112
- * Usage:
113
- * ```ts
114
- * dialog.remove('project-dialog');
115
- * ```
116
- */
117
- remove: typeof removeDialog;
118
- /**
119
- * Unregisters a dialog component by id.
120
- *
121
- * @returns Nothing.
122
- *
123
- * Usage:
124
- * ```ts
125
- * dialog.unregister('project-dialog');
126
- * ```
127
- */
128
- unregister: typeof unregisterDialog;
129
- useDialog: typeof useDialog;
130
- }
131
- /**
132
- * Convenience registry facade for dialog operations.
133
- *
134
- * Use this when you prefer a single import with discoverable methods instead of
135
- * importing `registerDialog`, `showDialog`, `hideDialog`, `removeDialog`, and
136
- * `unregisterDialog` separately.
137
- *
138
- * @returns An object of dialog helper functions.
139
- *
140
- * Usage:
141
- * ```ts
142
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
143
- * await projectDialog.show({ projectId: 'project-1' });
144
- * await dialog.show('project-dialog', { projectId: 'project-2' });
145
- * dialog.unregister('project-dialog');
146
- * ```
147
- */
148
- declare const dialog: DialogRegistry;
149
- //#endregion
150
- export { CreatedDialog, DialogRegistry, createDialog, dialog, hideDialog, removeDialog, unregisterDialog, useDialog };
@@ -1,93 +0,0 @@
1
- import { registerDialog } from "./register-dialog.js";
2
- import { showDialog } from "./show-dialog.js";
3
- import NiceModal, { unregister, useModal } from "@ebay/nice-modal-react";
4
-
5
- //#region src/dialog-provider/dialog-registry.ts
6
- const useDialog = useModal;
7
- function createDialog(component) {
8
- const CreatedDialog = NiceModal.create(component);
9
- return Object.assign(CreatedDialog, {
10
- show: async (props) => NiceModal.show(CreatedDialog, props),
11
- hide: async () => NiceModal.hide(CreatedDialog),
12
- remove: () => {
13
- NiceModal.remove(CreatedDialog);
14
- }
15
- });
16
- }
17
- /**
18
- * Hides a registered dialog by id.
19
- *
20
- * Use this when the caller only knows the dialog id. If you already have the
21
- * controller returned by `dialog.register(...)`, prefer `controller.hide()`.
22
- *
23
- * @param id - Dialog id that was previously registered.
24
- * @returns A promise from NiceModal that resolves after the hide action is
25
- * dispatched.
26
- *
27
- * Usage:
28
- * ```ts
29
- * await hideDialog('project-dialog');
30
- * ```
31
- */
32
- async function hideDialog(id) {
33
- return NiceModal.hide(id);
34
- }
35
- /**
36
- * Removes a registered dialog instance from the NiceModal render tree by id.
37
- *
38
- * This does not unregister the dialog component; it only removes the mounted
39
- * instance from the modal tree.
40
- *
41
- * @param id - Dialog id that was previously registered.
42
- * Usage:
43
- * ```ts
44
- * removeDialog('project-dialog');
45
- * ```
46
- */
47
- function removeDialog(id) {
48
- NiceModal.remove(id);
49
- }
50
- /**
51
- * Unregisters a dialog component by id.
52
- *
53
- * Use this when a registered dialog should no longer be available through
54
- * `showDialog(...)` or `dialog.show(...)`.
55
- *
56
- * @param id - Dialog id that was previously registered.
57
- * Usage:
58
- * ```ts
59
- * unregisterDialog('project-dialog');
60
- * ```
61
- */
62
- function unregisterDialog(id) {
63
- unregister(id);
64
- }
65
- /**
66
- * Convenience registry facade for dialog operations.
67
- *
68
- * Use this when you prefer a single import with discoverable methods instead of
69
- * importing `registerDialog`, `showDialog`, `hideDialog`, `removeDialog`, and
70
- * `unregisterDialog` separately.
71
- *
72
- * @returns An object of dialog helper functions.
73
- *
74
- * Usage:
75
- * ```ts
76
- * const projectDialog = dialog.register('project-dialog', ProjectDialog);
77
- * await projectDialog.show({ projectId: 'project-1' });
78
- * await dialog.show('project-dialog', { projectId: 'project-2' });
79
- * dialog.unregister('project-dialog');
80
- * ```
81
- */
82
- const dialog = {
83
- create: createDialog,
84
- hide: hideDialog,
85
- register: registerDialog,
86
- remove: removeDialog,
87
- show: showDialog,
88
- unregister: unregisterDialog,
89
- useDialog
90
- };
91
-
92
- //#endregion
93
- export { createDialog, dialog, hideDialog, removeDialog, unregisterDialog, useDialog };
@@ -1,4 +0,0 @@
1
- import { RegisteredDialog, RegisteredDialogInjectedProps, RegisteredDialogShowProps, registerDialog } from "./register-dialog.cjs";
2
- import { ShowDialogProps, showDialog } from "./show-dialog.cjs";
3
- import { CreatedDialog, DialogRegistry, createDialog, dialog, hideDialog, removeDialog, unregisterDialog, useDialog } from "./dialog-registry.cjs";
4
- import { DialogProvider, DialogProviderProps } from "./DialogProvider.cjs";
@@ -1,4 +0,0 @@
1
- import { RegisteredDialog, RegisteredDialogInjectedProps, RegisteredDialogShowProps, registerDialog } from "./register-dialog.js";
2
- import { ShowDialogProps, showDialog } from "./show-dialog.js";
3
- import { CreatedDialog, DialogRegistry, createDialog, dialog, hideDialog, removeDialog, unregisterDialog, useDialog } from "./dialog-registry.js";
4
- import { DialogProvider, DialogProviderProps } from "./DialogProvider.js";