@x-plat/design-system 0.1.3 → 0.1.5

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 (70) hide show
  1. package/dist/components/Accordion/index.cjs +908 -18
  2. package/dist/components/Accordion/index.js +908 -18
  3. package/dist/components/Avatar/index.css +1 -0
  4. package/dist/components/CheckBox/index.cjs +1 -1
  5. package/dist/components/CheckBox/index.css +13 -1
  6. package/dist/components/CheckBox/index.js +1 -1
  7. package/dist/components/DatePicker/index.cjs +75 -5
  8. package/dist/components/DatePicker/index.css +20 -2
  9. package/dist/components/DatePicker/index.d.cts +245 -4
  10. package/dist/components/DatePicker/index.d.ts +245 -4
  11. package/dist/components/DatePicker/index.js +75 -5
  12. package/dist/components/Drawer/index.cjs +111 -0
  13. package/dist/components/Drawer/index.css +70 -0
  14. package/dist/components/Drawer/index.d.cts +14 -0
  15. package/dist/components/Drawer/index.d.ts +14 -0
  16. package/dist/components/Drawer/index.js +74 -0
  17. package/dist/components/Dropdown/index.cjs +185 -0
  18. package/dist/components/Dropdown/index.css +54 -0
  19. package/dist/components/Dropdown/index.d.cts +17 -0
  20. package/dist/components/Dropdown/index.d.ts +17 -0
  21. package/dist/components/Dropdown/index.js +148 -0
  22. package/dist/components/EmptyState/index.cjs +60 -0
  23. package/dist/components/EmptyState/index.css +32 -0
  24. package/dist/components/EmptyState/index.d.cts +12 -0
  25. package/dist/components/EmptyState/index.d.ts +12 -0
  26. package/dist/components/EmptyState/index.js +33 -0
  27. package/dist/components/FileUpload/index.cjs +1039 -0
  28. package/dist/components/FileUpload/index.css +42 -0
  29. package/dist/components/FileUpload/index.d.cts +14 -0
  30. package/dist/components/FileUpload/index.d.ts +14 -0
  31. package/dist/components/FileUpload/index.js +1002 -0
  32. package/dist/components/Pagination/index.cjs +913 -7
  33. package/dist/components/Pagination/index.js +913 -7
  34. package/dist/components/Radio/index.css +1 -1
  35. package/dist/components/Select/index.cjs +17 -7
  36. package/dist/components/Select/index.d.cts +2 -0
  37. package/dist/components/Select/index.d.ts +2 -0
  38. package/dist/components/Select/index.js +17 -7
  39. package/dist/components/Steps/index.cjs +1105 -0
  40. package/dist/components/Steps/index.css +918 -0
  41. package/dist/components/Steps/index.d.cts +134 -0
  42. package/dist/components/Steps/index.d.ts +134 -0
  43. package/dist/components/Steps/index.js +1078 -0
  44. package/dist/components/Switch/index.cjs +2 -0
  45. package/dist/components/Switch/index.css +34 -8
  46. package/dist/components/Switch/index.d.cts +2 -0
  47. package/dist/components/Switch/index.d.ts +2 -0
  48. package/dist/components/Switch/index.js +2 -0
  49. package/dist/components/Tag/index.cjs +1090 -0
  50. package/dist/components/Tag/index.css +498 -0
  51. package/dist/components/Tag/index.d.cts +131 -0
  52. package/dist/components/Tag/index.d.ts +131 -0
  53. package/dist/components/Tag/index.js +1063 -0
  54. package/dist/components/Toast/index.cjs +150 -0
  55. package/dist/components/Toast/index.css +111 -0
  56. package/dist/components/Toast/index.d.cts +15 -0
  57. package/dist/components/Toast/index.d.ts +15 -0
  58. package/dist/components/Toast/index.js +112 -0
  59. package/dist/components/Tooltip/index.css +3 -0
  60. package/dist/components/index.cjs +1669 -1188
  61. package/dist/components/index.css +5803 -4011
  62. package/dist/components/index.d.cts +7 -0
  63. package/dist/components/index.d.ts +7 -0
  64. package/dist/components/index.js +1635 -1162
  65. package/dist/index.cjs +2689 -2244
  66. package/dist/index.css +5803 -4011
  67. package/dist/index.d.cts +7 -0
  68. package/dist/index.d.ts +7 -0
  69. package/dist/index.js +2758 -2321
  70. package/package.json +2 -2
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/Toast/index.ts
31
+ var Toast_exports = {};
32
+ __export(Toast_exports, {
33
+ ToastProvider: () => ToastProvider,
34
+ useToast: () => useToast
35
+ });
36
+ module.exports = __toCommonJS(Toast_exports);
37
+
38
+ // src/components/Toast/Toast.tsx
39
+ var import_react = __toESM(require("react"), 1);
40
+ var import_react_dom = require("react-dom");
41
+
42
+ // node_modules/clsx/dist/clsx.mjs
43
+ function r(e) {
44
+ var t, f, n = "";
45
+ if ("string" == typeof e || "number" == typeof e) n += e;
46
+ else if ("object" == typeof e) if (Array.isArray(e)) {
47
+ var o = e.length;
48
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
49
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
50
+ return n;
51
+ }
52
+ function clsx() {
53
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
54
+ return n;
55
+ }
56
+ var clsx_default = clsx;
57
+
58
+ // src/components/Toast/Toast.tsx
59
+ var import_jsx_runtime = require("react/jsx-runtime");
60
+ var ToastContext = import_react.default.createContext(null);
61
+ var useToast = () => {
62
+ const ctx = import_react.default.useContext(ToastContext);
63
+ if (!ctx) throw new Error("useToast must be used within ToastProvider");
64
+ return ctx;
65
+ };
66
+ var EXIT_DURATION = 300;
67
+ var ToastItemComponent = ({ item, isExiting, onClose }) => {
68
+ const ref = import_react.default.useRef(null);
69
+ const [height, setHeight] = import_react.default.useState(void 0);
70
+ import_react.default.useEffect(() => {
71
+ if (ref.current && !isExiting) {
72
+ setHeight(ref.current.offsetHeight);
73
+ }
74
+ }, [isExiting]);
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ "div",
77
+ {
78
+ className: clsx_default("lib-xplat-toast-wrapper", { exit: isExiting }),
79
+ style: {
80
+ maxHeight: isExiting ? 0 : height ?? "none",
81
+ marginBottom: isExiting ? 0 : void 0
82
+ },
83
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
84
+ "div",
85
+ {
86
+ ref,
87
+ className: clsx_default("lib-xplat-toast", item.type, { exit: isExiting }),
88
+ role: "alert",
89
+ children: [
90
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "message", children: item.message }),
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "close-btn", onClick: onClose, "aria-label": "\uB2EB\uAE30", children: "\xD7" })
92
+ ]
93
+ }
94
+ )
95
+ }
96
+ );
97
+ };
98
+ var ToastProvider = ({
99
+ children,
100
+ position = "top-right"
101
+ }) => {
102
+ const [toasts, setToasts] = import_react.default.useState([]);
103
+ const [removing, setRemoving] = import_react.default.useState(/* @__PURE__ */ new Set());
104
+ const [mounted, setMounted] = import_react.default.useState(false);
105
+ import_react.default.useEffect(() => {
106
+ setMounted(true);
107
+ }, []);
108
+ const remove = import_react.default.useCallback((id) => {
109
+ setRemoving((prev) => new Set(prev).add(id));
110
+ setTimeout(() => {
111
+ setToasts((prev) => prev.filter((t) => t.id !== id));
112
+ setRemoving((prev) => {
113
+ const next = new Set(prev);
114
+ next.delete(id);
115
+ return next;
116
+ });
117
+ }, EXIT_DURATION);
118
+ }, []);
119
+ const toast = import_react.default.useCallback(
120
+ (type, message, duration = 3e3) => {
121
+ const id = `${Date.now()}-${Math.random()}`;
122
+ setToasts((prev) => [...prev, { id, type, message }]);
123
+ if (duration > 0) {
124
+ setTimeout(() => remove(id), duration);
125
+ }
126
+ },
127
+ [remove]
128
+ );
129
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ToastContext.Provider, { value: { toast }, children: [
130
+ children,
131
+ mounted && (0, import_react_dom.createPortal)(
132
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: clsx_default("lib-xplat-toast-container", position), children: toasts.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
+ ToastItemComponent,
134
+ {
135
+ item: t,
136
+ isExiting: removing.has(t.id),
137
+ onClose: () => remove(t.id)
138
+ },
139
+ t.id
140
+ )) }),
141
+ document.body
142
+ )
143
+ ] });
144
+ };
145
+ ToastProvider.displayName = "ToastProvider";
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ ToastProvider,
149
+ useToast
150
+ });
@@ -0,0 +1,111 @@
1
+ /* src/components/Toast/toast.scss */
2
+ .lib-xplat-toast-container {
3
+ position: fixed;
4
+ z-index: 9999;
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 0;
8
+ pointer-events: none;
9
+ }
10
+ .lib-xplat-toast-container.top {
11
+ top: 16px;
12
+ left: 50%;
13
+ transform: translateX(-50%);
14
+ align-items: center;
15
+ }
16
+ .lib-xplat-toast-container.bottom {
17
+ bottom: 16px;
18
+ left: 50%;
19
+ transform: translateX(-50%);
20
+ align-items: center;
21
+ }
22
+ .lib-xplat-toast-container.top-left {
23
+ top: 16px;
24
+ left: 16px;
25
+ align-items: flex-start;
26
+ }
27
+ .lib-xplat-toast-container.top-right {
28
+ top: 16px;
29
+ right: 16px;
30
+ align-items: flex-end;
31
+ }
32
+ .lib-xplat-toast-container.bottom-left {
33
+ bottom: 16px;
34
+ left: 16px;
35
+ align-items: flex-start;
36
+ }
37
+ .lib-xplat-toast-container.bottom-right {
38
+ bottom: 16px;
39
+ right: 16px;
40
+ align-items: flex-end;
41
+ }
42
+ .lib-xplat-toast-wrapper {
43
+ overflow: hidden;
44
+ transition: max-height 0.3s ease, margin-bottom 0.3s ease;
45
+ margin-bottom: 8px;
46
+ }
47
+ .lib-xplat-toast-wrapper.exit {
48
+ margin-bottom: 0;
49
+ }
50
+ .lib-xplat-toast {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 8px;
54
+ padding: 0.75rem 1rem;
55
+ border-radius: 0.5rem;
56
+ font-size: 14px;
57
+ line-height: 1.5;
58
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
59
+ pointer-events: auto;
60
+ animation: lib-xplat-toast-enter 0.2s ease;
61
+ min-width: 240px;
62
+ max-width: 400px;
63
+ transition: opacity 0.3s ease, transform 0.3s ease;
64
+ }
65
+ .lib-xplat-toast.exit {
66
+ opacity: 0;
67
+ transform: translateX(30px);
68
+ }
69
+ .lib-xplat-toast .message {
70
+ flex: 1;
71
+ }
72
+ .lib-xplat-toast .close-btn {
73
+ background: none;
74
+ border: none;
75
+ cursor: pointer;
76
+ font-size: 18px;
77
+ line-height: 1;
78
+ padding: 0;
79
+ opacity: 0.6;
80
+ transition: opacity 0.2s;
81
+ color: inherit;
82
+ }
83
+ .lib-xplat-toast .close-btn:hover {
84
+ opacity: 1;
85
+ }
86
+ .lib-xplat-toast.info {
87
+ background-color: #1999F7;
88
+ color: #FFFFFF;
89
+ }
90
+ .lib-xplat-toast.success {
91
+ background-color: #00A34F;
92
+ color: #FFFFFF;
93
+ }
94
+ .lib-xplat-toast.warning {
95
+ background-color: #F0B100;
96
+ color: #FFFFFF;
97
+ }
98
+ .lib-xplat-toast.error {
99
+ background-color: #F80409;
100
+ color: #FFFFFF;
101
+ }
102
+ @keyframes lib-xplat-toast-enter {
103
+ from {
104
+ opacity: 0;
105
+ transform: translateY(-8px);
106
+ }
107
+ to {
108
+ opacity: 1;
109
+ transform: translateY(0);
110
+ }
111
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ type ToastType = "info" | "success" | "warning" | "error";
4
+ type ToastPosition = "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
5
+ interface ToastContextValue {
6
+ toast: (type: ToastType, message: React.ReactNode, duration?: number) => void;
7
+ }
8
+ declare const useToast: () => ToastContextValue;
9
+ interface ToastProviderProps {
10
+ children: React.ReactNode;
11
+ position?: ToastPosition;
12
+ }
13
+ declare const ToastProvider: React.FC<ToastProviderProps>;
14
+
15
+ export { ToastProvider, useToast };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ type ToastType = "info" | "success" | "warning" | "error";
4
+ type ToastPosition = "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
5
+ interface ToastContextValue {
6
+ toast: (type: ToastType, message: React.ReactNode, duration?: number) => void;
7
+ }
8
+ declare const useToast: () => ToastContextValue;
9
+ interface ToastProviderProps {
10
+ children: React.ReactNode;
11
+ position?: ToastPosition;
12
+ }
13
+ declare const ToastProvider: React.FC<ToastProviderProps>;
14
+
15
+ export { ToastProvider, useToast };
@@ -0,0 +1,112 @@
1
+ // src/components/Toast/Toast.tsx
2
+ import React from "react";
3
+ import { createPortal } from "react-dom";
4
+
5
+ // node_modules/clsx/dist/clsx.mjs
6
+ function r(e) {
7
+ var t, f, n = "";
8
+ if ("string" == typeof e || "number" == typeof e) n += e;
9
+ else if ("object" == typeof e) if (Array.isArray(e)) {
10
+ var o = e.length;
11
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
12
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
13
+ return n;
14
+ }
15
+ function clsx() {
16
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
17
+ return n;
18
+ }
19
+ var clsx_default = clsx;
20
+
21
+ // src/components/Toast/Toast.tsx
22
+ import { jsx, jsxs } from "react/jsx-runtime";
23
+ var ToastContext = React.createContext(null);
24
+ var useToast = () => {
25
+ const ctx = React.useContext(ToastContext);
26
+ if (!ctx) throw new Error("useToast must be used within ToastProvider");
27
+ return ctx;
28
+ };
29
+ var EXIT_DURATION = 300;
30
+ var ToastItemComponent = ({ item, isExiting, onClose }) => {
31
+ const ref = React.useRef(null);
32
+ const [height, setHeight] = React.useState(void 0);
33
+ React.useEffect(() => {
34
+ if (ref.current && !isExiting) {
35
+ setHeight(ref.current.offsetHeight);
36
+ }
37
+ }, [isExiting]);
38
+ return /* @__PURE__ */ jsx(
39
+ "div",
40
+ {
41
+ className: clsx_default("lib-xplat-toast-wrapper", { exit: isExiting }),
42
+ style: {
43
+ maxHeight: isExiting ? 0 : height ?? "none",
44
+ marginBottom: isExiting ? 0 : void 0
45
+ },
46
+ children: /* @__PURE__ */ jsxs(
47
+ "div",
48
+ {
49
+ ref,
50
+ className: clsx_default("lib-xplat-toast", item.type, { exit: isExiting }),
51
+ role: "alert",
52
+ children: [
53
+ /* @__PURE__ */ jsx("span", { className: "message", children: item.message }),
54
+ /* @__PURE__ */ jsx("button", { className: "close-btn", onClick: onClose, "aria-label": "\uB2EB\uAE30", children: "\xD7" })
55
+ ]
56
+ }
57
+ )
58
+ }
59
+ );
60
+ };
61
+ var ToastProvider = ({
62
+ children,
63
+ position = "top-right"
64
+ }) => {
65
+ const [toasts, setToasts] = React.useState([]);
66
+ const [removing, setRemoving] = React.useState(/* @__PURE__ */ new Set());
67
+ const [mounted, setMounted] = React.useState(false);
68
+ React.useEffect(() => {
69
+ setMounted(true);
70
+ }, []);
71
+ const remove = React.useCallback((id) => {
72
+ setRemoving((prev) => new Set(prev).add(id));
73
+ setTimeout(() => {
74
+ setToasts((prev) => prev.filter((t) => t.id !== id));
75
+ setRemoving((prev) => {
76
+ const next = new Set(prev);
77
+ next.delete(id);
78
+ return next;
79
+ });
80
+ }, EXIT_DURATION);
81
+ }, []);
82
+ const toast = React.useCallback(
83
+ (type, message, duration = 3e3) => {
84
+ const id = `${Date.now()}-${Math.random()}`;
85
+ setToasts((prev) => [...prev, { id, type, message }]);
86
+ if (duration > 0) {
87
+ setTimeout(() => remove(id), duration);
88
+ }
89
+ },
90
+ [remove]
91
+ );
92
+ return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast }, children: [
93
+ children,
94
+ mounted && createPortal(
95
+ /* @__PURE__ */ jsx("div", { className: clsx_default("lib-xplat-toast-container", position), children: toasts.map((t) => /* @__PURE__ */ jsx(
96
+ ToastItemComponent,
97
+ {
98
+ item: t,
99
+ isExiting: removing.has(t.id),
100
+ onClose: () => remove(t.id)
101
+ },
102
+ t.id
103
+ )) }),
104
+ document.body
105
+ )
106
+ ] });
107
+ };
108
+ ToastProvider.displayName = "ToastProvider";
109
+ export {
110
+ ToastProvider,
111
+ useToast
112
+ };
@@ -20,6 +20,9 @@
20
20
  bottom: 100%;
21
21
  transition: opacity 0.12s ease, transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
22
22
  }
23
+ .lib-xplat-tooltip > .tooltip-wrapper.primary {
24
+ color: #FFFFFF;
25
+ }
23
26
  .lib-xplat-tooltip > .tooltip-wrapper.primary.xplat-red-50 {
24
27
  background-color: #FFF0F0;
25
28
  }