@idds/react 1.4.3 → 1.4.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.
package/dist/index.es.js CHANGED
@@ -535,7 +535,9 @@ function clsx() {
535
535
  for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
536
536
  return n;
537
537
  }
538
- const AccordionGroupContext = createContext(null);
538
+ const AccordionGroupContext = createContext(
539
+ null
540
+ );
539
541
  function useAccordionGroup() {
540
542
  const context = useContext(AccordionGroupContext);
541
543
  return context;
@@ -557,19 +559,29 @@ function AccordionGroup(props) {
557
559
  const [version, setVersion] = useState(0);
558
560
  const openIndexesRef = useRef(openIndexes);
559
561
  openIndexesRef.current = openIndexes;
560
- const registerItem = useCallback((itemId, defaultOpen) => {
561
- const index = itemsRef.current.size;
562
- itemsRef.current.set(itemId, index);
563
- if (!allowMultiple && defaultOpen) {
564
- setOpenIndexes((prev) => {
565
- if (prev.length === 0) {
566
- return [index];
567
- }
568
- return prev;
569
- });
570
- }
571
- return index;
572
- }, [allowMultiple]);
562
+ const registerItem = useCallback(
563
+ (itemId, defaultOpen) => {
564
+ const index = itemsRef.current.size;
565
+ itemsRef.current.set(itemId, index);
566
+ if (defaultOpen) {
567
+ setOpenIndexes((prev) => {
568
+ if (allowMultiple) {
569
+ if (!prev.includes(index)) {
570
+ return [...prev, index];
571
+ }
572
+ return prev;
573
+ } else {
574
+ if (prev.length === 0) {
575
+ return [index];
576
+ }
577
+ return prev;
578
+ }
579
+ });
580
+ }
581
+ return index;
582
+ },
583
+ [allowMultiple]
584
+ );
573
585
  const unregisterItem = useCallback((itemId) => {
574
586
  const index = itemsRef.current.get(itemId);
575
587
  if (index !== void 0) {
@@ -629,7 +641,14 @@ function AccordionGroup(props) {
629
641
  version
630
642
  // Include version untuk trigger re-render
631
643
  }),
632
- [allowMultiple, registerItem, unregisterItem, handleItemToggle, isItemOpen, version]
644
+ [
645
+ allowMultiple,
646
+ registerItem,
647
+ unregisterItem,
648
+ handleItemToggle,
649
+ isItemOpen,
650
+ version
651
+ ]
633
652
  );
634
653
  return /* @__PURE__ */ jsx(AccordionGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: clsx("ina-accordion-group", className), children }) });
635
654
  }
@@ -2581,7 +2600,8 @@ function FileUpload({
2581
2600
  disabled = false,
2582
2601
  className = "",
2583
2602
  onChange,
2584
- onRemove
2603
+ onRemove,
2604
+ ...rest
2585
2605
  }) {
2586
2606
  const fileInputRef = useRef(null);
2587
2607
  const [files, setFiles] = useState([]);
@@ -2789,12 +2809,13 @@ function FileUpload({
2789
2809
  /* @__PURE__ */ jsx(
2790
2810
  "input",
2791
2811
  {
2812
+ ...rest,
2792
2813
  ref: fileInputRef,
2793
2814
  type: "file",
2794
2815
  accept: type,
2795
2816
  multiple,
2796
2817
  disabled,
2797
- className: "ina-file-upload__input",
2818
+ className: clsx("ina-file-upload__input", className),
2798
2819
  onChange: handleFileChange
2799
2820
  }
2800
2821
  ),
@@ -2967,7 +2988,8 @@ function SingleFileUpload({
2967
2988
  progress: externalProgress,
2968
2989
  status: externalStatus,
2969
2990
  onChange,
2970
- onRemove
2991
+ onRemove,
2992
+ ...rest
2971
2993
  }) {
2972
2994
  const fileInputRef = useRef(null);
2973
2995
  const [file, setFile] = useState(null);
@@ -3199,11 +3221,12 @@ function SingleFileUpload({
3199
3221
  /* @__PURE__ */ jsx(
3200
3222
  "input",
3201
3223
  {
3224
+ ...rest,
3202
3225
  ref: fileInputRef,
3203
3226
  type: "file",
3204
3227
  accept,
3205
3228
  disabled,
3206
- className: "ina-single-file-upload__input",
3229
+ className: clsx("ina-single-file-upload__input", className),
3207
3230
  onChange: handleFileChange
3208
3231
  }
3209
3232
  ),