@pixpilot/shadcn-ui 0.60.1 → 0.62.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.
@@ -1,5 +1,5 @@
1
1
  import * as React$1 from "react";
2
- import * as react_jsx_runtime9 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
  import * as _radix_ui_react_dialog0 from "@radix-ui/react-dialog";
4
4
 
5
5
  //#region src/dialog/Dialog.d.ts
@@ -9,14 +9,14 @@ declare const DialogContent: React$1.ForwardRefExoticComponent<Omit<_radix_ui_re
9
9
  declare function DialogHeader({
10
10
  className,
11
11
  ...props
12
- }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime9.JSX.Element;
12
+ }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime8.JSX.Element;
13
13
  declare function DialogBody({
14
14
  className,
15
15
  ...props
16
- }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime9.JSX.Element;
16
+ }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime8.JSX.Element;
17
17
  declare function DialogFooter({
18
18
  className,
19
19
  ...props
20
- }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime9.JSX.Element;
20
+ }: React$1.HTMLAttributes<HTMLDivElement>): react_jsx_runtime8.JSX.Element;
21
21
  //#endregion
22
22
  export { DialogBody, DialogContent, DialogFooter, DialogHeader };
@@ -1,10 +1,10 @@
1
1
  import { FileUploadInlineProps } from "./types.cjs";
2
- import * as react_jsx_runtime12 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime11 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/file-upload-inline/FileUploadInline.d.ts
5
5
  /**
6
6
  * FileUploadInline - An inline file upload component using FileUpload primitives
7
7
  */
8
- declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime12.JSX.Element;
8
+ declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime11.JSX.Element;
9
9
  //#endregion
10
10
  export { FileUploadInline };
@@ -1,10 +1,10 @@
1
1
  import { FileUploadInlineProps } from "./types.js";
2
- import * as react_jsx_runtime8 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime11 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/file-upload-inline/FileUploadInline.d.ts
5
5
  /**
6
6
  * FileUploadInline - An inline file upload component using FileUpload primitives
7
7
  */
8
- declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime8.JSX.Element;
8
+ declare function FileUploadInline(props: FileUploadInlineProps): react_jsx_runtime11.JSX.Element;
9
9
  //#endregion
10
10
  export { FileUploadInline };
@@ -1,11 +1,11 @@
1
1
  import { FileUploadRootProps } from "./types.cjs";
2
- import * as react_jsx_runtime11 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime12 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/file-upload-root/FileUploadRoot.d.ts
5
5
  /**
6
6
  * FileUploadInline - An inline file upload component using FileUpload primitives
7
7
  */
8
- declare function FileUploadRoot(props: FileUploadRootProps): react_jsx_runtime11.JSX.Element;
8
+ declare function FileUploadRoot(props: FileUploadRootProps): react_jsx_runtime12.JSX.Element;
9
9
  declare namespace FileUploadRoot {
10
10
  var displayName: string;
11
11
  }
@@ -1,5 +1,5 @@
1
1
  import { CommandOptionListItem } from "../CommandOptionList.js";
2
- import * as react_jsx_runtime14 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime15 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/tags-input/TagsInput.d.ts
5
5
  interface TagsInputProps {
@@ -57,6 +57,6 @@ declare function TagsInput({
57
57
  addOnTab,
58
58
  onValidate,
59
59
  addButtonVisibility
60
- }: TagsInputProps): react_jsx_runtime14.JSX.Element;
60
+ }: TagsInputProps): react_jsx_runtime15.JSX.Element;
61
61
  //#endregion
62
62
  export { TagsInput, TagsInputProps };
@@ -1,5 +1,5 @@
1
1
  import { ChangeEventHandler, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, Ref } from "react";
2
- import * as react_jsx_runtime15 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime14 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/tags-input/TagsInputInline.d.ts
5
5
  interface TagsInputInlineItem {
@@ -75,6 +75,6 @@ declare function TagsInputInline({
75
75
  canAddCurrentValue,
76
76
  onAddCurrentInput,
77
77
  showClear
78
- }: TagsInputInlineProps): react_jsx_runtime15.JSX.Element;
78
+ }: TagsInputInlineProps): react_jsx_runtime14.JSX.Element;
79
79
  //#endregion
80
80
  export { TagsInputInline, TagsInputInlineItem, TagsInputInlineProps };
@@ -10,9 +10,7 @@ sonner = require_rolldown_runtime.__toESM(sonner);
10
10
  //#region src/toast/toast.tsx
11
11
  const DEFAULT_ALERT_DURATION = 1e4;
12
12
  const toastInstances = /* @__PURE__ */ new Map();
13
- const toast = function(props) {
14
- const { duration,...rest } = props;
15
- const baseId = `toast_${(0, __pixpilot_hash.simpleHash)(`${props.title ?? ""}::${props.description ?? ""}`)}`;
13
+ function getToastId(baseId) {
16
14
  const instance = toastInstances.get(baseId);
17
15
  if (instance) {
18
16
  sonner.toast.dismiss(instance.currentId);
@@ -22,41 +20,70 @@ const toast = function(props) {
22
20
  currentId: `${baseId}_0`,
23
21
  counter: 0
24
22
  });
25
- const toastId = toastInstances.get(baseId).currentId;
26
- const cleanUp = (id) => {
23
+ return toastInstances.get(baseId).currentId;
24
+ }
25
+ function getToastHandlers(baseId) {
26
+ const cleanUp = (tId) => {
27
27
  const latestInstance = toastInstances.get(baseId);
28
- if (latestInstance && latestInstance.currentId === id) toastInstances.delete(baseId);
28
+ if (latestInstance && latestInstance.currentId === tId) toastInstances.delete(baseId);
29
29
  };
30
- sonner.toast.custom((t) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AlertToast.AlertToast, {
31
- ...rest,
32
- onClose: () => sonner.toast.dismiss(t)
33
- }), {
34
- duration: duration ?? DEFAULT_ALERT_DURATION,
35
- id: toastId,
30
+ return {
36
31
  onDismiss: (t) => {
37
32
  cleanUp(t.id);
38
33
  },
39
- onAutoClose(t) {
34
+ onAutoClose: (t) => {
40
35
  cleanUp(t.id);
41
36
  }
37
+ };
38
+ }
39
+ const toast = function(props) {
40
+ const { duration, id, dismissible = true, position,...rest } = props;
41
+ const baseId = id ?? `toast_${(0, __pixpilot_hash.simpleHash)(`${props.title ?? ""}::${props.description ?? ""}`)}`;
42
+ const toastId = getToastId(baseId);
43
+ const handlers = getToastHandlers(baseId);
44
+ sonner.toast.custom((t) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AlertToast.AlertToast, {
45
+ ...rest,
46
+ onClose: dismissible ? () => sonner.toast.dismiss(t) : void 0
47
+ }), {
48
+ duration: duration ?? DEFAULT_ALERT_DURATION,
49
+ id: toastId,
50
+ position,
51
+ ...handlers
42
52
  });
43
53
  };
44
- function createToast(variant, message, duration) {
54
+ function createToast(variant, message, options) {
55
+ const { duration, id } = options || {};
45
56
  if (typeof message === "string") toast({
46
57
  variant,
47
58
  description: message,
48
- duration
59
+ duration,
60
+ id
49
61
  });
50
62
  else toast({
51
63
  variant,
52
64
  ...message,
53
- duration
65
+ duration,
66
+ id
54
67
  });
55
68
  }
56
- toast.error = (message, duration) => createToast("error", message, duration);
57
- toast.success = (message, duration) => createToast("success", message, duration);
58
- toast.warning = (message, duration) => createToast("warning", message, duration);
59
- toast.info = (message, duration) => createToast("info", message, duration);
69
+ toast.error = (message, options) => createToast("error", message, options);
70
+ toast.success = (message, options) => createToast("success", message, options);
71
+ toast.warning = (message, options) => createToast("warning", message, options);
72
+ toast.info = (message, options) => createToast("info", message, options);
73
+ toast.custom = (component, options) => {
74
+ const { duration,...rest } = options || {};
75
+ sonner.toast.custom(() => component, {
76
+ duration: duration ?? DEFAULT_ALERT_DURATION,
77
+ ...rest
78
+ });
79
+ };
80
+ toast.remove = (id) => {
81
+ sonner.toast.dismiss(id);
82
+ };
83
+ toast.removeAll = () => {
84
+ sonner.toast.dismiss();
85
+ toastInstances.clear();
86
+ };
60
87
 
61
88
  //#endregion
62
89
  exports.DEFAULT_ALERT_DURATION = DEFAULT_ALERT_DURATION;
@@ -1,11 +1,14 @@
1
1
  import { AlertBaseProps } from "../Alert.cjs";
2
2
  import { AlertToastProps } from "./types.cjs";
3
3
  import "../index.cjs";
4
+ import { ToastT } from "sonner";
4
5
 
5
6
  //#region src/toast/toast.d.ts
6
7
  declare const DEFAULT_ALERT_DURATION = 10000;
7
- interface ToastProps extends AlertBaseProps {
8
- duration?: number;
8
+ interface ToastOwnProps extends Pick<ToastT, 'dismissible' | 'duration' | 'position'> {
9
+ id?: string;
10
+ }
11
+ interface ToastProps extends AlertBaseProps, ToastOwnProps {
9
12
  description?: string;
10
13
  }
11
14
  type ToastMessage = string | ({
@@ -14,10 +17,13 @@ type ToastMessage = string | ({
14
17
  } & AlertToastProps);
15
18
  interface ToastFunction {
16
19
  (props: ToastProps): void;
17
- error: (message: ToastMessage, duration?: number) => void;
18
- success: (message: ToastMessage, duration?: number) => void;
19
- warning: (message: ToastMessage, duration?: number) => void;
20
- info: (message: ToastMessage, duration?: number) => void;
20
+ error: (message: ToastMessage, options?: ToastOwnProps) => void;
21
+ success: (message: ToastMessage, options?: ToastOwnProps) => void;
22
+ warning: (message: ToastMessage, options?: ToastOwnProps) => void;
23
+ info: (message: ToastMessage, options?: ToastOwnProps) => void;
24
+ custom: (component: React.ReactElement, options?: ToastOwnProps) => void;
25
+ remove: (id: string) => void;
26
+ removeAll: () => void;
21
27
  }
22
28
  declare const toast: ToastFunction;
23
29
  //#endregion
@@ -1,11 +1,14 @@
1
1
  import { AlertBaseProps } from "../Alert.js";
2
2
  import { AlertToastProps } from "./types.js";
3
3
  import "../index.js";
4
+ import { ToastT } from "sonner";
4
5
 
5
6
  //#region src/toast/toast.d.ts
6
7
  declare const DEFAULT_ALERT_DURATION = 10000;
7
- interface ToastProps extends AlertBaseProps {
8
- duration?: number;
8
+ interface ToastOwnProps extends Pick<ToastT, 'dismissible' | 'duration' | 'position'> {
9
+ id?: string;
10
+ }
11
+ interface ToastProps extends AlertBaseProps, ToastOwnProps {
9
12
  description?: string;
10
13
  }
11
14
  type ToastMessage = string | ({
@@ -14,11 +17,14 @@ type ToastMessage = string | ({
14
17
  } & AlertToastProps);
15
18
  interface ToastFunction {
16
19
  (props: ToastProps): void;
17
- error: (message: ToastMessage, duration?: number) => void;
18
- success: (message: ToastMessage, duration?: number) => void;
19
- warning: (message: ToastMessage, duration?: number) => void;
20
- info: (message: ToastMessage, duration?: number) => void;
20
+ error: (message: ToastMessage, options?: ToastOwnProps) => void;
21
+ success: (message: ToastMessage, options?: ToastOwnProps) => void;
22
+ warning: (message: ToastMessage, options?: ToastOwnProps) => void;
23
+ info: (message: ToastMessage, options?: ToastOwnProps) => void;
24
+ custom: (component: React.ReactElement, options?: ToastOwnProps) => void;
25
+ remove: (id: string) => void;
26
+ removeAll: () => void;
21
27
  }
22
- declare const toast: ToastFunction;
28
+ declare const toast$1: ToastFunction;
23
29
  //#endregion
24
- export { DEFAULT_ALERT_DURATION, ToastFunction, ToastMessage, toast };
30
+ export { DEFAULT_ALERT_DURATION, ToastFunction, ToastMessage, toast$1 as toast };
@@ -6,9 +6,7 @@ import { toast } from "sonner";
6
6
  //#region src/toast/toast.tsx
7
7
  const DEFAULT_ALERT_DURATION = 1e4;
8
8
  const toastInstances = /* @__PURE__ */ new Map();
9
- const toast$1 = function(props) {
10
- const { duration,...rest } = props;
11
- const baseId = `toast_${simpleHash(`${props.title ?? ""}::${props.description ?? ""}`)}`;
9
+ function getToastId(baseId) {
12
10
  const instance = toastInstances.get(baseId);
13
11
  if (instance) {
14
12
  toast.dismiss(instance.currentId);
@@ -18,41 +16,70 @@ const toast$1 = function(props) {
18
16
  currentId: `${baseId}_0`,
19
17
  counter: 0
20
18
  });
21
- const toastId = toastInstances.get(baseId).currentId;
22
- const cleanUp = (id) => {
19
+ return toastInstances.get(baseId).currentId;
20
+ }
21
+ function getToastHandlers(baseId) {
22
+ const cleanUp = (tId) => {
23
23
  const latestInstance = toastInstances.get(baseId);
24
- if (latestInstance && latestInstance.currentId === id) toastInstances.delete(baseId);
24
+ if (latestInstance && latestInstance.currentId === tId) toastInstances.delete(baseId);
25
25
  };
26
- toast.custom((t) => /* @__PURE__ */ jsx(AlertToast, {
27
- ...rest,
28
- onClose: () => toast.dismiss(t)
29
- }), {
30
- duration: duration ?? DEFAULT_ALERT_DURATION,
31
- id: toastId,
26
+ return {
32
27
  onDismiss: (t) => {
33
28
  cleanUp(t.id);
34
29
  },
35
- onAutoClose(t) {
30
+ onAutoClose: (t) => {
36
31
  cleanUp(t.id);
37
32
  }
33
+ };
34
+ }
35
+ const toast$1 = function(props) {
36
+ const { duration, id, dismissible = true, position,...rest } = props;
37
+ const baseId = id ?? `toast_${simpleHash(`${props.title ?? ""}::${props.description ?? ""}`)}`;
38
+ const toastId = getToastId(baseId);
39
+ const handlers = getToastHandlers(baseId);
40
+ toast.custom((t) => /* @__PURE__ */ jsx(AlertToast, {
41
+ ...rest,
42
+ onClose: dismissible ? () => toast.dismiss(t) : void 0
43
+ }), {
44
+ duration: duration ?? DEFAULT_ALERT_DURATION,
45
+ id: toastId,
46
+ position,
47
+ ...handlers
38
48
  });
39
49
  };
40
- function createToast(variant, message, duration) {
50
+ function createToast(variant, message, options) {
51
+ const { duration, id } = options || {};
41
52
  if (typeof message === "string") toast$1({
42
53
  variant,
43
54
  description: message,
44
- duration
55
+ duration,
56
+ id
45
57
  });
46
58
  else toast$1({
47
59
  variant,
48
60
  ...message,
49
- duration
61
+ duration,
62
+ id
50
63
  });
51
64
  }
52
- toast$1.error = (message, duration) => createToast("error", message, duration);
53
- toast$1.success = (message, duration) => createToast("success", message, duration);
54
- toast$1.warning = (message, duration) => createToast("warning", message, duration);
55
- toast$1.info = (message, duration) => createToast("info", message, duration);
65
+ toast$1.error = (message, options) => createToast("error", message, options);
66
+ toast$1.success = (message, options) => createToast("success", message, options);
67
+ toast$1.warning = (message, options) => createToast("warning", message, options);
68
+ toast$1.info = (message, options) => createToast("info", message, options);
69
+ toast$1.custom = (component, options) => {
70
+ const { duration,...rest } = options || {};
71
+ toast.custom(() => component, {
72
+ duration: duration ?? DEFAULT_ALERT_DURATION,
73
+ ...rest
74
+ });
75
+ };
76
+ toast$1.remove = (id) => {
77
+ toast.dismiss(id);
78
+ };
79
+ toast$1.removeAll = () => {
80
+ toast.dismiss();
81
+ toastInstances.clear();
82
+ };
56
83
 
57
84
  //#endregion
58
85
  export { DEFAULT_ALERT_DURATION, toast$1 as toast };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/shadcn-ui",
3
3
  "type": "module",
4
- "version": "0.60.1",
4
+ "version": "0.62.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",