@safestrong/ppa-component-library 1.0.0 → 1.1.1

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.
@@ -0,0 +1,98 @@
1
+ import React from 'react';
2
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
3
+
4
+ type Button = React.ButtonHTMLAttributes<HTMLButtonElement> & {
5
+ icon?: IconProp;
6
+ label: string;
7
+ btnType?: "primary" | "secondary" | "tertiary";
8
+ isLoading?: boolean;
9
+ };
10
+ declare function Button({ label, icon, isLoading, btnType, className, ...rest }: Readonly<Button>): React.JSX.Element;
11
+
12
+ declare function TextInput({ label, labelFor, icon, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
13
+ label?: string;
14
+ labelFor?: string;
15
+ icon?: IconProp;
16
+ }>): React.JSX.Element;
17
+
18
+ declare function Slider(attr: Readonly<React.InputHTMLAttributes<HTMLInputElement>>): React.JSX.Element;
19
+
20
+ type SingleSelect = React.InputHTMLAttributes<HTMLInputElement> & {
21
+ label?: string;
22
+ labelHtml?: string;
23
+ options: {
24
+ label: string;
25
+ value: string;
26
+ }[];
27
+ };
28
+ declare function SingleSelect(attr: Readonly<SingleSelect>): React.JSX.Element;
29
+
30
+ type Tooltip = {
31
+ children: React.ReactNode;
32
+ text: string;
33
+ position: "top" | "bottom" | "right" | "left";
34
+ };
35
+ declare function Tooltip({ children, text, position, }: Readonly<Tooltip>): React.JSX.Element;
36
+
37
+ type Option$1 = {
38
+ label: string;
39
+ value: string;
40
+ };
41
+ declare function NavTabClient({ items, state, }: Readonly<{
42
+ items: Option$1[];
43
+ state: {
44
+ active: string;
45
+ setActive: (val: string) => void;
46
+ };
47
+ }>): React.JSX.Element;
48
+
49
+ type Card = {
50
+ children: React.ReactNode;
51
+ className: string;
52
+ };
53
+ declare function Card({ children, className }: Readonly<Card>): React.JSX.Element;
54
+ declare namespace Card {
55
+ var Footer: ({ className, children, }: {
56
+ className?: string;
57
+ children?: React.ReactNode;
58
+ }) => React.JSX.Element;
59
+ }
60
+
61
+ type ToastType = "warning" | "success" | "info" | "danger";
62
+ type Toast = {
63
+ title: string;
64
+ className?: string;
65
+ description: string;
66
+ type: ToastType;
67
+ };
68
+ declare function Toast({ title, description, type, className, }: Readonly<Toast>): React.JSX.Element;
69
+ declare namespace Toast {
70
+ var Inline: ({ text, type }: {
71
+ text: string;
72
+ type: ToastType;
73
+ }) => React.JSX.Element;
74
+ }
75
+
76
+ type Expandable = {
77
+ children: React.ReactNode;
78
+ title: string;
79
+ className: string;
80
+ isOpen?: boolean;
81
+ };
82
+ declare function Expandable({ children, title, className, isOpen, }: Readonly<Expandable>): React.JSX.Element;
83
+
84
+ type Option = {
85
+ value: string;
86
+ label: string;
87
+ };
88
+ declare function MultiSelect({ list, state, }: Readonly<{
89
+ list: Option[];
90
+ state: {
91
+ value: Option[];
92
+ select: (newVal: Option[]) => void;
93
+ };
94
+ }>): React.JSX.Element;
95
+
96
+ declare function Dashboard(): React.JSX.Element;
97
+
98
+ export { Button, Card, Dashboard, Expandable, MultiSelect, NavTabClient, SingleSelect, Slider, TextInput, Toast, Tooltip };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,98 @@
1
1
  import React from 'react';
2
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
2
3
 
3
- declare function IconButton({ label }: Readonly<IconButtonProps>): React.JSX.Element;
4
- type IconButtonProps = {
4
+ type Button = React.ButtonHTMLAttributes<HTMLButtonElement> & {
5
+ icon?: IconProp;
5
6
  label: string;
7
+ btnType?: "primary" | "secondary" | "tertiary";
8
+ isLoading?: boolean;
6
9
  };
10
+ declare function Button({ label, icon, isLoading, btnType, className, ...rest }: Readonly<Button>): React.JSX.Element;
7
11
 
8
- export { IconButton };
12
+ declare function TextInput({ label, labelFor, icon, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
13
+ label?: string;
14
+ labelFor?: string;
15
+ icon?: IconProp;
16
+ }>): React.JSX.Element;
17
+
18
+ declare function Slider(attr: Readonly<React.InputHTMLAttributes<HTMLInputElement>>): React.JSX.Element;
19
+
20
+ type SingleSelect = React.InputHTMLAttributes<HTMLInputElement> & {
21
+ label?: string;
22
+ labelHtml?: string;
23
+ options: {
24
+ label: string;
25
+ value: string;
26
+ }[];
27
+ };
28
+ declare function SingleSelect(attr: Readonly<SingleSelect>): React.JSX.Element;
29
+
30
+ type Tooltip = {
31
+ children: React.ReactNode;
32
+ text: string;
33
+ position: "top" | "bottom" | "right" | "left";
34
+ };
35
+ declare function Tooltip({ children, text, position, }: Readonly<Tooltip>): React.JSX.Element;
36
+
37
+ type Option$1 = {
38
+ label: string;
39
+ value: string;
40
+ };
41
+ declare function NavTabClient({ items, state, }: Readonly<{
42
+ items: Option$1[];
43
+ state: {
44
+ active: string;
45
+ setActive: (val: string) => void;
46
+ };
47
+ }>): React.JSX.Element;
48
+
49
+ type Card = {
50
+ children: React.ReactNode;
51
+ className: string;
52
+ };
53
+ declare function Card({ children, className }: Readonly<Card>): React.JSX.Element;
54
+ declare namespace Card {
55
+ var Footer: ({ className, children, }: {
56
+ className?: string;
57
+ children?: React.ReactNode;
58
+ }) => React.JSX.Element;
59
+ }
60
+
61
+ type ToastType = "warning" | "success" | "info" | "danger";
62
+ type Toast = {
63
+ title: string;
64
+ className?: string;
65
+ description: string;
66
+ type: ToastType;
67
+ };
68
+ declare function Toast({ title, description, type, className, }: Readonly<Toast>): React.JSX.Element;
69
+ declare namespace Toast {
70
+ var Inline: ({ text, type }: {
71
+ text: string;
72
+ type: ToastType;
73
+ }) => React.JSX.Element;
74
+ }
75
+
76
+ type Expandable = {
77
+ children: React.ReactNode;
78
+ title: string;
79
+ className: string;
80
+ isOpen?: boolean;
81
+ };
82
+ declare function Expandable({ children, title, className, isOpen, }: Readonly<Expandable>): React.JSX.Element;
83
+
84
+ type Option = {
85
+ value: string;
86
+ label: string;
87
+ };
88
+ declare function MultiSelect({ list, state, }: Readonly<{
89
+ list: Option[];
90
+ state: {
91
+ value: Option[];
92
+ select: (newVal: Option[]) => void;
93
+ };
94
+ }>): React.JSX.Element;
95
+
96
+ declare function Dashboard(): React.JSX.Element;
97
+
98
+ export { Button, Card, Dashboard, Expandable, MultiSelect, NavTabClient, SingleSelect, Slider, TextInput, Toast, Tooltip };
package/dist/index.js CHANGED
@@ -1,2 +1,423 @@
1
- "use strict";var t=require("react");exports.IconButton=function({label:e}){return t.createElement("button",null,e)};
2
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/index.ts
60
+ var index_exports = {};
61
+ __export(index_exports, {
62
+ Button: () => Button,
63
+ Card: () => Card,
64
+ Dashboard: () => Dashboard,
65
+ Expandable: () => Expandable,
66
+ MultiSelect: () => MultiSelect,
67
+ NavTabClient: () => NavTabClient,
68
+ SingleSelect: () => SingleSelect,
69
+ Slider: () => Slider,
70
+ TextInput: () => TextInput,
71
+ Toast: () => Toast,
72
+ Tooltip: () => Tooltip
73
+ });
74
+ module.exports = __toCommonJS(index_exports);
75
+
76
+ // src/components/Button.tsx
77
+ var import_react = __toESM(require("react"));
78
+ var import_free_solid_svg_icons = require("@fortawesome/free-solid-svg-icons");
79
+ var import_react_fontawesome = require("@fortawesome/react-fontawesome");
80
+ function Button(_a) {
81
+ var _b = _a, {
82
+ label,
83
+ icon,
84
+ isLoading,
85
+ btnType,
86
+ className
87
+ } = _b, rest = __objRest(_b, [
88
+ "label",
89
+ "icon",
90
+ "isLoading",
91
+ "btnType",
92
+ "className"
93
+ ]);
94
+ const buttonIcon = isLoading ? import_free_solid_svg_icons.faRefresh : icon;
95
+ return /* @__PURE__ */ import_react.default.createElement(
96
+ "button",
97
+ __spreadProps(__spreadValues({}, rest), {
98
+ className: `${!icon && "py-[0.67rem]"} ${className} ${btnType == "secondary" && "btn__secondary"} btn__primary`
99
+ }),
100
+ buttonIcon && icon && /* @__PURE__ */ import_react.default.createElement(
101
+ import_react_fontawesome.FontAwesomeIcon,
102
+ {
103
+ icon: buttonIcon,
104
+ className: `text-[1.1rem] ${isLoading && "animate-spin"}`
105
+ }
106
+ ),
107
+ isLoading ? "Memproses ..." : label
108
+ );
109
+ }
110
+
111
+ // src/components/TextInput.tsx
112
+ var import_react2 = __toESM(require("react"));
113
+ var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
114
+ var input__icon = "px-[0.7rem] text-[1.1rem] text-[var(--color-icon-input)]";
115
+ function TextInput(_a) {
116
+ var _b = _a, {
117
+ label,
118
+ labelFor,
119
+ icon
120
+ } = _b, attr = __objRest(_b, [
121
+ "label",
122
+ "labelFor",
123
+ "icon"
124
+ ]);
125
+ return /* @__PURE__ */ import_react2.default.createElement("div", { className: "group ..." }, label && /* @__PURE__ */ import_react2.default.createElement("label", { htmlFor: labelFor, className: "text-input__label" }, label), /* @__PURE__ */ import_react2.default.createElement("div", { className: "text-input__wrapper" }, icon && /* @__PURE__ */ import_react2.default.createElement(import_react_fontawesome2.FontAwesomeIcon, { icon, className: input__icon }), /* @__PURE__ */ import_react2.default.createElement(
126
+ "input",
127
+ __spreadProps(__spreadValues({}, attr), {
128
+ className: `text-input ${attr.className} ${icon && "!pl-0"}`
129
+ })
130
+ )));
131
+ }
132
+
133
+ // src/components/Slider.tsx
134
+ var import_react3 = __toESM(require("react"));
135
+ var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
136
+ var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
137
+ function Slider(attr) {
138
+ return /* @__PURE__ */ import_react3.default.createElement("div", { className: "slider__wrapper group" }, /* @__PURE__ */ import_react3.default.createElement(
139
+ "input",
140
+ __spreadProps(__spreadValues({}, attr), {
141
+ id: "slider",
142
+ type: "checkbox",
143
+ className: "peer ... w-[2rem] opacity-[0] cursor-pointer"
144
+ })
145
+ ), /* @__PURE__ */ import_react3.default.createElement("label", { htmlFor: "slider", className: "slider" }, /* @__PURE__ */ import_react3.default.createElement(import_react_fontawesome3.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faCheck, className: "text-[0.7rem]" })));
146
+ }
147
+
148
+ // src/components/SingleSelect.tsx
149
+ var import_react4 = __toESM(require("react"));
150
+ var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
151
+ var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
152
+ function SingleSelect(attr) {
153
+ var _a;
154
+ const [selected, setSelected] = (0, import_react4.useState)({ label: "", value: "" });
155
+ const [keyword, setKeyword] = (0, import_react4.useState)("");
156
+ const inputKeyword = (0, import_react4.useDeferredValue)(keyword);
157
+ function getFiltered() {
158
+ return attr.options.filter(
159
+ ({ label, value }) => label.toLowerCase().includes(inputKeyword.toLowerCase()) || value.toLowerCase().includes(inputKeyword.toLowerCase())
160
+ );
161
+ }
162
+ function selectItem({ label, value }) {
163
+ setSelected({ label, value });
164
+ setKeyword("");
165
+ }
166
+ return /* @__PURE__ */ import_react4.default.createElement("div", null, attr.label && /* @__PURE__ */ import_react4.default.createElement("label", { className: "text-input__label", htmlFor: attr.labelHtml }, attr.label), /* @__PURE__ */ import_react4.default.createElement("div", { className: "text-input__wrapper relative" }, /* @__PURE__ */ import_react4.default.createElement(
167
+ "input",
168
+ __spreadProps(__spreadValues(__spreadValues({}, attr), attr.onChange ? { onChange: attr.onChange } : {}), {
169
+ value: (_a = attr.value) != null ? _a : selected.value,
170
+ type: "hidden"
171
+ })
172
+ ), /* @__PURE__ */ import_react4.default.createElement(
173
+ "input",
174
+ __spreadValues({
175
+ value: keyword,
176
+ type: "search",
177
+ onChange: (e) => setKeyword(e.target.value),
178
+ className: "text-input peer ...",
179
+ placeholder: selected.value ? selected.label : "Cari opsi ..."
180
+ }, attr)
181
+ ), /* @__PURE__ */ import_react4.default.createElement("div", { className: "select-item__wrapper" }, getFiltered().length == 0 && keyword != "" && /* @__PURE__ */ import_react4.default.createElement("button", { className: "select-item text-[var(--color-danger)]" }, "Tidak ada Item"), getFiltered().map(({ label, value }) => /* @__PURE__ */ import_react4.default.createElement(
182
+ "button",
183
+ {
184
+ onClick: () => selectItem({ label, value }),
185
+ key: value,
186
+ className: "select-item"
187
+ },
188
+ label,
189
+ selected.value == value && /* @__PURE__ */ import_react4.default.createElement(
190
+ import_react_fontawesome4.FontAwesomeIcon,
191
+ {
192
+ icon: import_free_solid_svg_icons3.faCheck,
193
+ className: "text-[var(--color-primary)]"
194
+ }
195
+ )
196
+ ))), /* @__PURE__ */ import_react4.default.createElement(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faChevronDown, className: input__icon2 })));
197
+ }
198
+ var input__icon2 = "pr-[0.7rem] text-[var(--color-icon-input)]";
199
+
200
+ // src/components/Tooltip.tsx
201
+ var import_react5 = __toESM(require("react"));
202
+ function Tooltip({
203
+ children,
204
+ text,
205
+ position
206
+ }) {
207
+ function getAccent() {
208
+ const mapping = {
209
+ top,
210
+ bottom,
211
+ left,
212
+ right
213
+ };
214
+ return mapping[position];
215
+ }
216
+ return /* @__PURE__ */ import_react5.default.createElement("div", { className: "relative" }, /* @__PURE__ */ import_react5.default.createElement("div", { className: "peer" }, children), /* @__PURE__ */ import_react5.default.createElement("span", { className: `tooltip-text ${getAccent()}` }, text));
217
+ }
218
+ var top = "bottom-full translate-y-[-0.3rem] right-0 after:bottom-0 after:translate-y-[0.25rem] ";
219
+ var bottom = "right-0 top-full translate-y-[0.3rem] after:top-[-0.4rem] after:translate-y-[0.2rem] ";
220
+ var right = "left-full w-[max-content] translate-x-[0.6rem] after:left-[-0.2rem] top-[-0.2rem] after:top-[0.6rem]";
221
+ var left = "right-full w-[max-content] translate-x-[-0.6rem] top-[-0.2rem] after:right-[-0.2rem] after:top-[0.6rem]";
222
+
223
+ // src/components/NavTabClient.tsx
224
+ var import_react6 = __toESM(require("react"));
225
+ function NavTabClient({
226
+ items,
227
+ state
228
+ }) {
229
+ return /* @__PURE__ */ import_react6.default.createElement("nav", { className: "navtab__wrapper" }, items.map(({ label, value }) => /* @__PURE__ */ import_react6.default.createElement(
230
+ "button",
231
+ {
232
+ key: value,
233
+ className: `navtab__item ${state.active == value && "navtab__item__active"}`,
234
+ onClick: () => state.setActive(value)
235
+ },
236
+ label
237
+ )));
238
+ }
239
+
240
+ // src/components/Card.tsx
241
+ var import_react7 = __toESM(require("react"));
242
+ function Card({ children, className }) {
243
+ return /* @__PURE__ */ import_react7.default.createElement("div", { className: `card ${className}` }, children);
244
+ }
245
+ var Footer = ({
246
+ className,
247
+ children
248
+ }) => {
249
+ return /* @__PURE__ */ import_react7.default.createElement("div", { className: `${className} border-t border-t-[var(--color-border)]` }, children);
250
+ };
251
+ Card.Footer = Footer;
252
+
253
+ // src/components/Toast.tsx
254
+ var import_react8 = __toESM(require("react"));
255
+ var import_react_fontawesome5 = require("@fortawesome/react-fontawesome");
256
+ var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
257
+ function Toast({
258
+ title,
259
+ description,
260
+ type,
261
+ className
262
+ }) {
263
+ return /* @__PURE__ */ import_react8.default.createElement("div", { className: `${className} toast__wrapper group` }, /* @__PURE__ */ import_react8.default.createElement("div", { className: "toast__body" }, /* @__PURE__ */ import_react8.default.createElement(
264
+ import_react_fontawesome5.FontAwesomeIcon,
265
+ {
266
+ icon: getIcon(type),
267
+ className: "text-[1.2rem]",
268
+ style: { color: getColor(type) }
269
+ }
270
+ ), /* @__PURE__ */ import_react8.default.createElement("div", null, /* @__PURE__ */ import_react8.default.createElement("p", { className: "toast__title" }, title), /* @__PURE__ */ import_react8.default.createElement("p", { className: "toast__description" }, description)), /* @__PURE__ */ import_react8.default.createElement(
271
+ import_react_fontawesome5.FontAwesomeIcon,
272
+ {
273
+ icon: getIcon(type),
274
+ className: "toast-bg__icon",
275
+ style: { color: getColor(type) }
276
+ }
277
+ )), /* @__PURE__ */ import_react8.default.createElement("p", { className: "toast__bar", style: { background: getColor(type) } }));
278
+ }
279
+ var Inline = ({ text, type }) => {
280
+ return /* @__PURE__ */ import_react8.default.createElement(
281
+ "div",
282
+ {
283
+ className: "toast__inline",
284
+ style: { background: `var(--color-${type}-soft)`, opacity: 0.9 }
285
+ },
286
+ /* @__PURE__ */ import_react8.default.createElement(
287
+ import_react_fontawesome5.FontAwesomeIcon,
288
+ {
289
+ icon: getIcon(type),
290
+ className: "text-[1.1rem]",
291
+ style: { color: getColor(type) }
292
+ }
293
+ ),
294
+ /* @__PURE__ */ import_react8.default.createElement("p", null, text)
295
+ );
296
+ };
297
+ Toast.Inline = Inline;
298
+ function getColor(type) {
299
+ return `var(--color-${type})`;
300
+ }
301
+ function getIcon(type) {
302
+ const mapping = {
303
+ warning: import_free_solid_svg_icons4.faQuestionCircle,
304
+ info: import_free_solid_svg_icons4.faInfoCircle,
305
+ danger: import_free_solid_svg_icons4.faXmarkCircle,
306
+ success: import_free_solid_svg_icons4.faCheckCircle
307
+ };
308
+ return mapping[type];
309
+ }
310
+
311
+ // src/components/Expandable.tsx
312
+ var import_react9 = __toESM(require("react"));
313
+ var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
314
+ var import_react_fontawesome6 = require("@fortawesome/react-fontawesome");
315
+ function Expandable({
316
+ children,
317
+ title,
318
+ className,
319
+ isOpen
320
+ }) {
321
+ const name = title.replace(" ", "");
322
+ return /* @__PURE__ */ import_react9.default.createElement("div", { className: `expandable ${className}` }, /* @__PURE__ */ import_react9.default.createElement(
323
+ "input",
324
+ {
325
+ id: name,
326
+ type: "checkbox",
327
+ defaultChecked: isOpen,
328
+ className: "opacity-[0] peer absolute top-0 ex-title"
329
+ }
330
+ ), /* @__PURE__ */ import_react9.default.createElement(import_react_fontawesome6.FontAwesomeIcon, { icon: import_free_solid_svg_icons5.faCaretRight, className: "expandable__icon" }), /* @__PURE__ */ import_react9.default.createElement("label", { htmlFor: name, className: "expandable__title" }, title), /* @__PURE__ */ import_react9.default.createElement("div", { className: "expandable__body" }, /* @__PURE__ */ import_react9.default.createElement("div", { className: "p-[0.75rem] px-[1rem]" }, children)));
331
+ }
332
+
333
+ // src/components/MultiSelect.tsx
334
+ var import_react10 = __toESM(require("react"));
335
+ var import_react_fontawesome7 = require("@fortawesome/react-fontawesome");
336
+ var import_free_solid_svg_icons6 = require("@fortawesome/free-solid-svg-icons");
337
+ function MultiSelect({
338
+ list: list2,
339
+ state
340
+ }) {
341
+ const [keyword, setKeyword] = (0, import_react10.useState)("");
342
+ const inputKeyword = (0, import_react10.useDeferredValue)(keyword);
343
+ function getFiltered() {
344
+ return list2.filter(
345
+ ({ label, value }) => label.toLowerCase().includes(inputKeyword.toLowerCase()) || value.toLowerCase().includes(inputKeyword.toLowerCase())
346
+ );
347
+ }
348
+ function selectItem({ label, value }) {
349
+ state.select((prev) => {
350
+ const isItemExist2 = prev.find((item) => item.value == value);
351
+ if (isItemExist2) {
352
+ return prev.filter((item) => item.value != value);
353
+ }
354
+ return [...prev, { label, value }];
355
+ });
356
+ }
357
+ function isItemExist(value) {
358
+ return state.value.find((item) => item.value == value);
359
+ }
360
+ const selectUnSelectAll = (0, import_react10.useCallback)(() => {
361
+ const isAllSelected = state.value.length == list2.length;
362
+ state.select(isAllSelected ? [] : list2);
363
+ }, [state.value]);
364
+ return /* @__PURE__ */ import_react10.default.createElement("div", { className: "text-input__wrapper relative" }, /* @__PURE__ */ import_react10.default.createElement(
365
+ "input",
366
+ {
367
+ value: keyword,
368
+ type: "search",
369
+ placeholder: `${state.value.length} Dipilih`,
370
+ className: "text-input peer ...",
371
+ onChange: (e) => setKeyword(e.target.value)
372
+ }
373
+ ), /* @__PURE__ */ import_react10.default.createElement("div", { className: "select-item__wrapper select-multiple__wrapper" }, getFiltered().length == 0 && keyword != "" && /* @__PURE__ */ import_react10.default.createElement("button", { className: "select-item text-[var(--color-danger)]" }, "Tidak ada Item"), getFiltered().map(({ label, value }) => /* @__PURE__ */ import_react10.default.createElement(
374
+ "button",
375
+ {
376
+ onClick: () => selectItem({ label, value }),
377
+ key: value,
378
+ className: "select-item"
379
+ },
380
+ label,
381
+ isItemExist(value) && /* @__PURE__ */ import_react10.default.createElement(
382
+ import_react_fontawesome7.FontAwesomeIcon,
383
+ {
384
+ icon: import_free_solid_svg_icons6.faCheck,
385
+ className: "text-[var(--color-primary)]"
386
+ }
387
+ )
388
+ ))), /* @__PURE__ */ import_react10.default.createElement("button", { className: "cursor-pointer", onClick: selectUnSelectAll }, /* @__PURE__ */ import_react10.default.createElement(import_react_fontawesome7.FontAwesomeIcon, { icon: import_free_solid_svg_icons6.faListCheck, className: input__icon3 })));
389
+ }
390
+ var input__icon3 = "pr-[0.7rem] text-[var(--color-icon-input)]";
391
+
392
+ // src/components/Dashboard.tsx
393
+ var import_react11 = __toESM(require("react"));
394
+ var list = [
395
+ { label: "Option 1", value: "option1" },
396
+ { label: "Option 2", value: "option2" },
397
+ { label: "Option 3", value: "option3" }
398
+ ];
399
+ function Dashboard() {
400
+ const [selectedItem, setSelectedItem] = (0, import_react11.useState)([]);
401
+ return /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement(
402
+ MultiSelect,
403
+ {
404
+ list,
405
+ state: { value: selectedItem, select: setSelectedItem }
406
+ }
407
+ ));
408
+ }
409
+ // Annotate the CommonJS export names for ESM import in node:
410
+ 0 && (module.exports = {
411
+ Button,
412
+ Card,
413
+ Dashboard,
414
+ Expandable,
415
+ MultiSelect,
416
+ NavTabClient,
417
+ SingleSelect,
418
+ Slider,
419
+ TextInput,
420
+ Toast,
421
+ Tooltip
422
+ });
423
+ //# sourceMappingURL=index.js.map