@safestrong/ppa-component-library 1.7.3 → 1.8.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.
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +214 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -75
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +31 -19
- package/package.json +13 -6
package/dist/index.d.mts
CHANGED
|
@@ -19,11 +19,13 @@ declare namespace Button {
|
|
|
19
19
|
}) => React.JSX.Element;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
declare function TextInput({ label, labelFor, icon, outerclass, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
22
|
+
declare function TextInput({ label, labelFor, icon, outerclass, isdarkmode, inputclass, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
23
23
|
label?: string;
|
|
24
24
|
labelFor?: string;
|
|
25
25
|
icon?: IconProp;
|
|
26
26
|
outerclass?: string;
|
|
27
|
+
isdarkmode?: boolean;
|
|
28
|
+
inputclass?: string;
|
|
27
29
|
}>): React.JSX.Element;
|
|
28
30
|
|
|
29
31
|
declare function Slider(attr: Readonly<React.InputHTMLAttributes<HTMLInputElement>>): React.JSX.Element;
|
|
@@ -34,6 +36,7 @@ type SingleSelect = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
34
36
|
placeholder?: string;
|
|
35
37
|
stateaction?: (param: any) => void;
|
|
36
38
|
outerclass?: string;
|
|
39
|
+
isdarkmode?: boolean;
|
|
37
40
|
options?: {
|
|
38
41
|
label: string;
|
|
39
42
|
value: string;
|
|
@@ -113,6 +116,7 @@ type MultiSelect = {
|
|
|
113
116
|
label?: string;
|
|
114
117
|
labelHtml?: string;
|
|
115
118
|
outerclass?: string;
|
|
119
|
+
isdarkmode?: boolean;
|
|
116
120
|
options?: Option[];
|
|
117
121
|
stringOptions?: string[];
|
|
118
122
|
state: {
|
package/dist/index.d.ts
CHANGED
|
@@ -19,11 +19,13 @@ declare namespace Button {
|
|
|
19
19
|
}) => React.JSX.Element;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
declare function TextInput({ label, labelFor, icon, outerclass, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
22
|
+
declare function TextInput({ label, labelFor, icon, outerclass, isdarkmode, inputclass, ...attr }: Readonly<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
23
23
|
label?: string;
|
|
24
24
|
labelFor?: string;
|
|
25
25
|
icon?: IconProp;
|
|
26
26
|
outerclass?: string;
|
|
27
|
+
isdarkmode?: boolean;
|
|
28
|
+
inputclass?: string;
|
|
27
29
|
}>): React.JSX.Element;
|
|
28
30
|
|
|
29
31
|
declare function Slider(attr: Readonly<React.InputHTMLAttributes<HTMLInputElement>>): React.JSX.Element;
|
|
@@ -34,6 +36,7 @@ type SingleSelect = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
|
34
36
|
placeholder?: string;
|
|
35
37
|
stateaction?: (param: any) => void;
|
|
36
38
|
outerclass?: string;
|
|
39
|
+
isdarkmode?: boolean;
|
|
37
40
|
options?: {
|
|
38
41
|
label: string;
|
|
39
42
|
value: string;
|
|
@@ -113,6 +116,7 @@ type MultiSelect = {
|
|
|
113
116
|
label?: string;
|
|
114
117
|
labelHtml?: string;
|
|
115
118
|
outerclass?: string;
|
|
119
|
+
isdarkmode?: boolean;
|
|
116
120
|
options?: Option[];
|
|
117
121
|
stringOptions?: string[];
|
|
118
122
|
state: {
|
package/dist/index.js
CHANGED
|
@@ -147,25 +147,56 @@ function getBtnClass(idx) {
|
|
|
147
147
|
// src/components/TextInput.tsx
|
|
148
148
|
var import_react2 = __toESM(require("react"));
|
|
149
149
|
var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
|
|
150
|
-
var input__icon = "w-[2rem] p-[0.9rem] px-[0.7rem] text-[1.2rem] bg-[var(--color-background-icon)] text-[var(--color-icon-input)] mr-2 group-focus-within:text-[var(--color-primary)]";
|
|
150
|
+
var input__icon = "w-[2rem] p-[0.9rem] px-[0.7rem] text-[1.2rem] bg-[var(--color-background-icon)] text-[var(--color-icon-input)] mr-2 group-focus-within:text-[var(--color-primary)] ";
|
|
151
151
|
function TextInput(_a) {
|
|
152
152
|
var _b = _a, {
|
|
153
153
|
label,
|
|
154
154
|
labelFor,
|
|
155
155
|
icon,
|
|
156
|
-
outerclass
|
|
156
|
+
outerclass,
|
|
157
|
+
isdarkmode,
|
|
158
|
+
inputclass
|
|
157
159
|
} = _b, attr = __objRest(_b, [
|
|
158
160
|
"label",
|
|
159
161
|
"labelFor",
|
|
160
162
|
"icon",
|
|
161
|
-
"outerclass"
|
|
163
|
+
"outerclass",
|
|
164
|
+
"isdarkmode",
|
|
165
|
+
"inputclass"
|
|
162
166
|
]);
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
function getThemedClass(prefix) {
|
|
168
|
+
return `var(--color${isdarkmode ? "-dark" : ""}${prefix})`;
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { className: `group ${outerclass} w-full` }, label && /* @__PURE__ */ import_react2.default.createElement(
|
|
171
|
+
"label",
|
|
172
|
+
{
|
|
173
|
+
htmlFor: labelFor,
|
|
174
|
+
className: "text-input__label",
|
|
175
|
+
style: {
|
|
176
|
+
color: getThemedClass("-text-secondary")
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
label
|
|
180
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
className: `text-input__wrapper overflow-hidden ${attr.className}`,
|
|
184
|
+
style: {
|
|
185
|
+
borderColor: getThemedClass("-border"),
|
|
186
|
+
background: getThemedClass("-bg-surface")
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
icon && /* @__PURE__ */ import_react2.default.createElement(import_react_fontawesome2.FontAwesomeIcon, { icon, className: input__icon }),
|
|
190
|
+
/* @__PURE__ */ import_react2.default.createElement(
|
|
191
|
+
"input",
|
|
192
|
+
__spreadProps(__spreadValues({}, attr), {
|
|
193
|
+
className: `text-input w-full ${icon && "!pl-[0.3rem]"} ${inputclass}`,
|
|
194
|
+
style: {
|
|
195
|
+
color: getThemedClass("-text-primary")
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
)
|
|
199
|
+
));
|
|
169
200
|
}
|
|
170
201
|
|
|
171
202
|
// src/components/Slider.tsx
|
|
@@ -189,7 +220,8 @@ var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
|
|
|
189
220
|
var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
|
|
190
221
|
function SingleSelect(attr) {
|
|
191
222
|
var _b;
|
|
192
|
-
const _a = attr, { options = [], stringOptions = [] } = _a, attrInput = __objRest(_a, ["options", "stringOptions"]);
|
|
223
|
+
const _a = attr, { options = [], stringOptions = [], isdarkmode } = _a, attrInput = __objRest(_a, ["options", "stringOptions", "isdarkmode"]);
|
|
224
|
+
const inputValue = attrInput.value;
|
|
193
225
|
const [keyword, setKeyword] = (0, import_react4.useState)("");
|
|
194
226
|
const [selected, setSelected] = (0, import_react4.useState)({
|
|
195
227
|
label: "",
|
|
@@ -204,13 +236,11 @@ function SingleSelect(attr) {
|
|
|
204
236
|
}
|
|
205
237
|
setSelected({ label, value });
|
|
206
238
|
if (attr.stateaction) {
|
|
207
|
-
if (
|
|
208
|
-
if (
|
|
239
|
+
if ((options == null ? void 0 : options.length) > 0) attr.stateaction({ label, value });
|
|
240
|
+
if ((stringOptions == null ? void 0 : stringOptions.length) > 0) attr.stateaction(value);
|
|
209
241
|
}
|
|
210
242
|
setKeyword("");
|
|
211
|
-
|
|
212
|
-
e.target.blur();
|
|
213
|
-
}, 250);
|
|
243
|
+
e.currentTarget.blur();
|
|
214
244
|
}
|
|
215
245
|
function autoUpdateValue(updatedValue) {
|
|
216
246
|
if (updatedValue) {
|
|
@@ -232,40 +262,91 @@ function SingleSelect(attr) {
|
|
|
232
262
|
);
|
|
233
263
|
}, [keyword, availableOptions]);
|
|
234
264
|
(0, import_react4.useEffect)(() => {
|
|
235
|
-
|
|
236
|
-
}, [
|
|
237
|
-
|
|
238
|
-
"
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
"input",
|
|
265
|
+
inputValue && autoUpdateValue(inputValue);
|
|
266
|
+
}, [inputValue]);
|
|
267
|
+
function getThemedClass(prefix) {
|
|
268
|
+
return `var(--color${isdarkmode ? "-dark" : ""}${prefix})`;
|
|
269
|
+
}
|
|
270
|
+
const placeholderClass = `${input2} select-item-placeholder-${isdarkmode ? "dark" : ""}`;
|
|
271
|
+
const optionHoverClass = `select-item-hover${isdarkmode ? "-dark" : ""}`;
|
|
272
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { className: `w-full group ${attr.outerclass}` }, attrInput.label && /* @__PURE__ */ import_react4.default.createElement(
|
|
273
|
+
"label",
|
|
245
274
|
{
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
"button",
|
|
275
|
+
className: "text-input__label",
|
|
276
|
+
htmlFor: attrInput.labelHtml,
|
|
277
|
+
style: { color: getThemedClass("-text-secondary") }
|
|
278
|
+
},
|
|
279
|
+
attrInput.label
|
|
280
|
+
), /* @__PURE__ */ import_react4.default.createElement(
|
|
281
|
+
"div",
|
|
254
282
|
{
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
283
|
+
className: `${attrInput.className} text-input__wrapper relative`,
|
|
284
|
+
style: {
|
|
285
|
+
borderColor: getThemedClass("-border"),
|
|
286
|
+
background: getThemedClass("-bg-surface")
|
|
287
|
+
}
|
|
259
288
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
290
|
+
"input",
|
|
291
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
292
|
+
type: "hidden"
|
|
293
|
+
}, attrInput), attrInput.onChange ? { onChange: attrInput.onChange } : {}), {
|
|
294
|
+
value: (_b = attrInput.value) != null ? _b : selected.value
|
|
295
|
+
})
|
|
296
|
+
),
|
|
297
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
298
|
+
"input",
|
|
263
299
|
{
|
|
264
|
-
|
|
265
|
-
|
|
300
|
+
type: "search",
|
|
301
|
+
value: keyword,
|
|
302
|
+
autoComplete: "off",
|
|
303
|
+
onChange: (e) => setKeyword(e.target.value),
|
|
304
|
+
className: `${attrInput.name}-keyword ${placeholderClass}`,
|
|
305
|
+
placeholder: selected.value ? selected.label : attrInput.placeholder,
|
|
306
|
+
style: {
|
|
307
|
+
color: selected.value ? getThemedClass("-text-primary") : void 0
|
|
308
|
+
}
|
|
266
309
|
}
|
|
267
|
-
)
|
|
268
|
-
|
|
310
|
+
),
|
|
311
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
312
|
+
"div",
|
|
313
|
+
{
|
|
314
|
+
className: "select-item__wrapper",
|
|
315
|
+
style: {
|
|
316
|
+
borderColor: getThemedClass("-border"),
|
|
317
|
+
background: getThemedClass("-bg-surface")
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
filteredOptions.length == 0 && keyword != "" && /* @__PURE__ */ import_react4.default.createElement(
|
|
321
|
+
"button",
|
|
322
|
+
{
|
|
323
|
+
disabled: true,
|
|
324
|
+
className: "select-item",
|
|
325
|
+
style: { color: "var(--color-danger)" }
|
|
326
|
+
},
|
|
327
|
+
"Tidak ada Item"
|
|
328
|
+
),
|
|
329
|
+
filteredOptions.map(({ label, value }) => /* @__PURE__ */ import_react4.default.createElement(
|
|
330
|
+
"button",
|
|
331
|
+
{
|
|
332
|
+
key: value,
|
|
333
|
+
type: "button",
|
|
334
|
+
className: `select-item ${optionHoverClass}`,
|
|
335
|
+
onClick: (e) => selectItem({ label, value }, e),
|
|
336
|
+
style: { color: getThemedClass("-text-secondary") }
|
|
337
|
+
},
|
|
338
|
+
label,
|
|
339
|
+
selected.value == value && /* @__PURE__ */ import_react4.default.createElement(
|
|
340
|
+
import_react_fontawesome4.FontAwesomeIcon,
|
|
341
|
+
{
|
|
342
|
+
icon: import_free_solid_svg_icons3.faCheck,
|
|
343
|
+
style: { color: "var(--color-info)" }
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
))
|
|
347
|
+
),
|
|
348
|
+
/* @__PURE__ */ import_react4.default.createElement(import_react_fontawesome4.FontAwesomeIcon, { icon: import_free_solid_svg_icons3.faChevronDown, style: { color: getThemedClass("-icon-input"), paddingRight: "0.7rem" } })
|
|
349
|
+
));
|
|
269
350
|
}
|
|
270
351
|
SingleSelect.autoFill = autoFillInput;
|
|
271
352
|
function autoFillInput(value, elName, list2) {
|
|
@@ -275,7 +356,6 @@ function autoFillInput(value, elName, list2) {
|
|
|
275
356
|
const el = document.querySelector(`.${elName}-keyword`);
|
|
276
357
|
el == null ? void 0 : el.setAttribute("placeholder", `${filtered == null ? void 0 : filtered.label}`);
|
|
277
358
|
}
|
|
278
|
-
var input__icon2 = "pr-[0.7rem] text-[var(--color-icon-input)]";
|
|
279
359
|
var input2 = "text-input peer ... w-full";
|
|
280
360
|
|
|
281
361
|
// src/components/Tooltip.tsx
|
|
@@ -422,8 +502,10 @@ function MultiSelect(_a) {
|
|
|
422
502
|
"label",
|
|
423
503
|
"labelHtml"
|
|
424
504
|
]);
|
|
425
|
-
const { options = [], stringOptions = [] } = attr;
|
|
505
|
+
const { options = [], stringOptions = [], isdarkmode } = attr;
|
|
426
506
|
const [keyword, setKeyword] = (0, import_react10.useState)("");
|
|
507
|
+
const optionHoverClass = `select-item-hover${isdarkmode ? "-dark" : ""}`;
|
|
508
|
+
const placeholderClass = `${input3} select-item-placeholder-${isdarkmode ? "dark" : ""}`;
|
|
427
509
|
const availableOptions = (0, import_react10.useMemo)(() => {
|
|
428
510
|
const isDefaultOption = options && options.length > 0;
|
|
429
511
|
if (!isDefaultOption)
|
|
@@ -451,42 +533,98 @@ function MultiSelect(_a) {
|
|
|
451
533
|
const isAllSelected = state.value.length == availableOptions.length;
|
|
452
534
|
state.select(isAllSelected ? [] : availableOptions);
|
|
453
535
|
}, [state.value]);
|
|
454
|
-
|
|
455
|
-
"
|
|
536
|
+
function getThemedClass(prefix) {
|
|
537
|
+
return `var(--color${isdarkmode ? "-dark" : ""}${prefix})`;
|
|
538
|
+
}
|
|
539
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", { className: `group w-full ${attr.outerclass}` }, label && /* @__PURE__ */ import_react10.default.createElement(
|
|
540
|
+
"label",
|
|
456
541
|
{
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
"button",
|
|
542
|
+
htmlFor: labelHtml,
|
|
543
|
+
className: "text-input__label",
|
|
544
|
+
style: { color: getThemedClass("-text-secondary") }
|
|
545
|
+
},
|
|
546
|
+
label
|
|
547
|
+
), /* @__PURE__ */ import_react10.default.createElement(
|
|
548
|
+
"div",
|
|
465
549
|
{
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
550
|
+
className: "text-input__wrapper relative",
|
|
551
|
+
style: {
|
|
552
|
+
borderColor: getThemedClass("-border"),
|
|
553
|
+
background: getThemedClass("-bg-surface")
|
|
554
|
+
}
|
|
470
555
|
},
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
import_react_fontawesome7.FontAwesomeIcon,
|
|
556
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
557
|
+
"input",
|
|
474
558
|
{
|
|
475
|
-
|
|
476
|
-
|
|
559
|
+
type: "search",
|
|
560
|
+
value: keyword,
|
|
561
|
+
autoComplete: "off",
|
|
562
|
+
className: `${input3} ${placeholderClass}`,
|
|
563
|
+
onChange: (e) => setKeyword(e.target.value),
|
|
564
|
+
placeholder: `${state.value.length} Dipilih`,
|
|
565
|
+
style: {
|
|
566
|
+
color: state.value.length > 0 ? getThemedClass("-text-primary") : void 0
|
|
567
|
+
}
|
|
477
568
|
}
|
|
569
|
+
),
|
|
570
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
571
|
+
"div",
|
|
572
|
+
{
|
|
573
|
+
className: "select-item__wrapper select-multiple__wrapper",
|
|
574
|
+
style: {
|
|
575
|
+
borderColor: getThemedClass("-border"),
|
|
576
|
+
background: getThemedClass("-bg-surface")
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
getFiltered().length == 0 && keyword != "" && /* @__PURE__ */ import_react10.default.createElement(
|
|
580
|
+
"button",
|
|
581
|
+
{
|
|
582
|
+
disabled: true,
|
|
583
|
+
className: "select-item",
|
|
584
|
+
style: { color: "var(--color-danger)" }
|
|
585
|
+
},
|
|
586
|
+
"Tidak ada Item"
|
|
587
|
+
),
|
|
588
|
+
getFiltered().map(({ label: label2, value }) => /* @__PURE__ */ import_react10.default.createElement(
|
|
589
|
+
"button",
|
|
590
|
+
{
|
|
591
|
+
key: value,
|
|
592
|
+
type: "button",
|
|
593
|
+
onClick: () => selectItem({ label: label2, value }),
|
|
594
|
+
className: `select-item ${optionHoverClass}`,
|
|
595
|
+
style: { color: getThemedClass("-text-secondary") }
|
|
596
|
+
},
|
|
597
|
+
label2,
|
|
598
|
+
isItemExist(value) && /* @__PURE__ */ import_react10.default.createElement(
|
|
599
|
+
import_react_fontawesome7.FontAwesomeIcon,
|
|
600
|
+
{
|
|
601
|
+
icon: import_free_solid_svg_icons6.faCheck,
|
|
602
|
+
style: { color: "var(--color-info)" }
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
))
|
|
606
|
+
),
|
|
607
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
608
|
+
"button",
|
|
609
|
+
{
|
|
610
|
+
type: "button",
|
|
611
|
+
className: "cursor-pointer",
|
|
612
|
+
onClick: selectUnSelectAll
|
|
613
|
+
},
|
|
614
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
615
|
+
import_react_fontawesome7.FontAwesomeIcon,
|
|
616
|
+
{
|
|
617
|
+
icon: import_free_solid_svg_icons6.faListCheck,
|
|
618
|
+
style: {
|
|
619
|
+
color: getThemedClass("-icon-input"),
|
|
620
|
+
paddingRight: "0.7rem",
|
|
621
|
+
fontSize: "1.2rem"
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
)
|
|
478
625
|
)
|
|
479
|
-
))
|
|
480
|
-
"button",
|
|
481
|
-
{
|
|
482
|
-
type: "button",
|
|
483
|
-
className: "cursor-pointer",
|
|
484
|
-
onClick: selectUnSelectAll
|
|
485
|
-
},
|
|
486
|
-
/* @__PURE__ */ import_react10.default.createElement(import_react_fontawesome7.FontAwesomeIcon, { icon: import_free_solid_svg_icons6.faListCheck, className: input__icon3 })
|
|
487
|
-
)));
|
|
626
|
+
));
|
|
488
627
|
}
|
|
489
|
-
var input__icon3 = "pr-[0.7rem] text-[1.2rem] text-[var(--color-icon-input)]";
|
|
490
628
|
var input3 = "text-input peer ... w-full";
|
|
491
629
|
|
|
492
630
|
// src/components/ThemeToggle.tsx
|
|
@@ -529,6 +667,7 @@ function Dashboard() {
|
|
|
529
667
|
return /* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center gap-[1rem]" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
530
668
|
MultiSelect,
|
|
531
669
|
{
|
|
670
|
+
isdarkmode: true,
|
|
532
671
|
label: "Multi Select",
|
|
533
672
|
stringOptions: stringList,
|
|
534
673
|
state: { value: selectedItem, select: setSelectedItem }
|