dce-reactkit 5.0.6 → 5.0.7
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/cjs/index.js +77 -68
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ItemPicker/NestableItemList.d.ts +1 -0
- package/dist/cjs/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/cjs/types/components/ItemPicker/types/PickableItem.d.ts +4 -1
- package/dist/esm/index.js +77 -68
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ItemPicker/NestableItemList.d.ts +1 -0
- package/dist/esm/types/components/ItemPicker/index.d.ts +1 -0
- package/dist/esm/types/components/ItemPicker/types/PickableItem.d.ts +4 -1
- package/dist/index.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/ItemPicker/NestableItemList.tsx +42 -15
- package/src/components/ItemPicker/index.tsx +4 -0
- package/src/components/ItemPicker/types/PickableItem.tsx +7 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
/**
|
|
2
3
|
* An item that can be chosen (for use within ItemPicker)
|
|
3
4
|
* @author Gabe Abrams
|
|
4
5
|
*/
|
|
5
6
|
type PickableItem = ({
|
|
6
7
|
id: number | string;
|
|
7
|
-
name:
|
|
8
|
+
name: React.ReactNode;
|
|
9
|
+
ariaLabel?: string;
|
|
8
10
|
link?: string;
|
|
11
|
+
tooltip?: string;
|
|
9
12
|
} & ({
|
|
10
13
|
isGroup: false;
|
|
11
14
|
checked: boolean;
|
package/dist/esm/index.js
CHANGED
|
@@ -2642,6 +2642,65 @@ const CopiableBox = (props) => {
|
|
|
2642
2642
|
"Copy")))));
|
|
2643
2643
|
};
|
|
2644
2644
|
|
|
2645
|
+
/**
|
|
2646
|
+
* Simple tooltip component
|
|
2647
|
+
* @author Gabe Abrams
|
|
2648
|
+
*/
|
|
2649
|
+
/*------------------------------------------------------------------------*/
|
|
2650
|
+
/* ------------------------------ Component ----------------------------- */
|
|
2651
|
+
/*------------------------------------------------------------------------*/
|
|
2652
|
+
const Tooltip = (props) => {
|
|
2653
|
+
/*------------------------------------------------------------------------*/
|
|
2654
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
2655
|
+
/*------------------------------------------------------------------------*/
|
|
2656
|
+
/* -------------- Props ------------- */
|
|
2657
|
+
// Destructure all props
|
|
2658
|
+
const { text, children, } = props;
|
|
2659
|
+
/* -------------- Refs -------------- */
|
|
2660
|
+
// Child ref
|
|
2661
|
+
const childRef = useRef(undefined);
|
|
2662
|
+
/*------------------------------------------------------------------------*/
|
|
2663
|
+
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
2664
|
+
/*------------------------------------------------------------------------*/
|
|
2665
|
+
/**
|
|
2666
|
+
* Update (also called on mount)
|
|
2667
|
+
* @author Gabe Abrams
|
|
2668
|
+
*/
|
|
2669
|
+
useEffect(() => {
|
|
2670
|
+
// Skip if no child
|
|
2671
|
+
if (!childRef.current) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
// Store copy of tooltip
|
|
2675
|
+
let t;
|
|
2676
|
+
// Initialize tooltip
|
|
2677
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
2678
|
+
// Import bootstrap tooltip
|
|
2679
|
+
const BSTooltip = (yield import('bootstrap')).Tooltip;
|
|
2680
|
+
// Initialize
|
|
2681
|
+
t = new BSTooltip(childRef.current, {
|
|
2682
|
+
title: text,
|
|
2683
|
+
placement: 'top',
|
|
2684
|
+
trigger: 'hover',
|
|
2685
|
+
});
|
|
2686
|
+
}))();
|
|
2687
|
+
// Clean up tooltip
|
|
2688
|
+
return () => {
|
|
2689
|
+
if (t) {
|
|
2690
|
+
t.dispose();
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
}, [text]);
|
|
2694
|
+
/*------------------------------------------------------------------------*/
|
|
2695
|
+
/* ------------------------------- Render ------------------------------- */
|
|
2696
|
+
/*------------------------------------------------------------------------*/
|
|
2697
|
+
/*----------------------------------------*/
|
|
2698
|
+
/* --------------- Main UI -------------- */
|
|
2699
|
+
/*----------------------------------------*/
|
|
2700
|
+
// Clone child and add ref
|
|
2701
|
+
return React__default.cloneElement(children, { ref: childRef });
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2645
2704
|
/**
|
|
2646
2705
|
* Reusable nested item picker
|
|
2647
2706
|
* @author Yuen Ler Chow
|
|
@@ -2679,12 +2738,12 @@ const NestableItemList = (props) => {
|
|
|
2679
2738
|
/*------------------------------------------------------------------------*/
|
|
2680
2739
|
/* -------------- Props ------------- */
|
|
2681
2740
|
// Destructure all props
|
|
2682
|
-
const { items, onChanged, } = props;
|
|
2741
|
+
const { items, onChanged, startWithGroupsExpanded, } = props;
|
|
2683
2742
|
/* -------------- State ------------- */
|
|
2684
2743
|
// Create initial map of child expanded booleans
|
|
2685
2744
|
const initChildExpanded = {};
|
|
2686
2745
|
items.forEach((item) => {
|
|
2687
|
-
initChildExpanded[String(item.id)] =
|
|
2746
|
+
initChildExpanded[String(item.id)] = !!startWithGroupsExpanded;
|
|
2688
2747
|
});
|
|
2689
2748
|
// Initial state
|
|
2690
2749
|
const initialState = {
|
|
@@ -2773,6 +2832,14 @@ const NestableItemList = (props) => {
|
|
|
2773
2832
|
/* ------------------------------- Render ------------------------------- */
|
|
2774
2833
|
/*------------------------------------------------------------------------*/
|
|
2775
2834
|
return (React__default.createElement("div", null, items.map((item) => {
|
|
2835
|
+
var _a;
|
|
2836
|
+
// Human-readable label for accessibility. Prefer the explicit
|
|
2837
|
+
// ariaLabel, then fall back to the name if it is a plain string
|
|
2838
|
+
const accessibleName = ((_a = item.ariaLabel) !== null && _a !== void 0 ? _a : (typeof item.name === 'string' ? item.name : ''));
|
|
2839
|
+
// Checkbox and Text
|
|
2840
|
+
const checkbox = (React__default.createElement(CheckboxButton, { className: `NestableItemList-CheckboxButton-${item.id}`, text: item.name, checked: item.isGroup ? allChecked(item.children) : item.checked, dashed: item.isGroup ? !noneChecked(item.children) : false, onChanged: (checked) => {
|
|
2841
|
+
onChanged(changeChecked(item.id, checked, items));
|
|
2842
|
+
}, ariaLabel: `Select ${accessibleName}`, checkedVariant: Variant$1.Light, uncheckedVariant: Variant$1.Light }));
|
|
2776
2843
|
return (React__default.createElement("div", { key: item.id },
|
|
2777
2844
|
React__default.createElement("span", { className: "NestableItemList-dropdown-button-container d-inline-block", style: {
|
|
2778
2845
|
minWidth: '2rem',
|
|
@@ -2784,17 +2851,18 @@ const NestableItemList = (props) => {
|
|
|
2784
2851
|
type: ActionType$9.ToggleChild,
|
|
2785
2852
|
id: item.id,
|
|
2786
2853
|
});
|
|
2787
|
-
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${
|
|
2854
|
+
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${accessibleName}` },
|
|
2788
2855
|
React__default.createElement(FontAwesomeIcon, { icon: childExpanded[item.id] ? faChevronDown : faChevronRight })))),
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2856
|
+
item.tooltip
|
|
2857
|
+
? (React__default.createElement(Tooltip, { text: item.tooltip },
|
|
2858
|
+
React__default.createElement("span", { className: "d-inline-block" }, checkbox)))
|
|
2859
|
+
: checkbox,
|
|
2792
2860
|
(item.isGroup && childExpanded[item.id]) && (React__default.createElement("div", { className: "NestableItemList-children-container", style: {
|
|
2793
2861
|
paddingLeft: '2.2rem',
|
|
2794
2862
|
} },
|
|
2795
2863
|
React__default.createElement(NestableItemList, { items: item.children, onChanged: (updatedItems) => {
|
|
2796
2864
|
onChanged(changeItems(item.id, updatedItems));
|
|
2797
|
-
} })))));
|
|
2865
|
+
}, startWithGroupsExpanded: startWithGroupsExpanded })))));
|
|
2798
2866
|
})));
|
|
2799
2867
|
};
|
|
2800
2868
|
|
|
@@ -2811,7 +2879,7 @@ const ItemPicker = (props) => {
|
|
|
2811
2879
|
/*------------------------------------------------------------------------*/
|
|
2812
2880
|
/* -------------- Props ------------- */
|
|
2813
2881
|
// Destructure all props
|
|
2814
|
-
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, } = props;
|
|
2882
|
+
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, startWithGroupsExpanded, } = props;
|
|
2815
2883
|
/*------------------------------------------------------------------------*/
|
|
2816
2884
|
/* ------------------------- Component Functions ------------------------ */
|
|
2817
2885
|
/*------------------------------------------------------------------------*/
|
|
@@ -2868,7 +2936,7 @@ const ItemPicker = (props) => {
|
|
|
2868
2936
|
// Main UI
|
|
2869
2937
|
return (React__default.createElement(TabBox, { title: title, noBottomMargin: noBottomMargin, topRightChildren: selectAllOrNone },
|
|
2870
2938
|
React__default.createElement("div", { style: { overflowX: 'auto' } },
|
|
2871
|
-
React__default.createElement(NestableItemList, { items: items, onChanged: onChanged }))));
|
|
2939
|
+
React__default.createElement(NestableItemList, { items: items, onChanged: onChanged, startWithGroupsExpanded: startWithGroupsExpanded }))));
|
|
2872
2940
|
};
|
|
2873
2941
|
|
|
2874
2942
|
/**
|
|
@@ -13445,65 +13513,6 @@ const DBEntryManagerPanel = (props) => {
|
|
|
13445
13513
|
return (React__default.createElement("div", null, body));
|
|
13446
13514
|
};
|
|
13447
13515
|
|
|
13448
|
-
/**
|
|
13449
|
-
* Simple tooltip component
|
|
13450
|
-
* @author Gabe Abrams
|
|
13451
|
-
*/
|
|
13452
|
-
/*------------------------------------------------------------------------*/
|
|
13453
|
-
/* ------------------------------ Component ----------------------------- */
|
|
13454
|
-
/*------------------------------------------------------------------------*/
|
|
13455
|
-
const Tooltip = (props) => {
|
|
13456
|
-
/*------------------------------------------------------------------------*/
|
|
13457
|
-
/* -------------------------------- Setup ------------------------------- */
|
|
13458
|
-
/*------------------------------------------------------------------------*/
|
|
13459
|
-
/* -------------- Props ------------- */
|
|
13460
|
-
// Destructure all props
|
|
13461
|
-
const { text, children, } = props;
|
|
13462
|
-
/* -------------- Refs -------------- */
|
|
13463
|
-
// Child ref
|
|
13464
|
-
const childRef = useRef(undefined);
|
|
13465
|
-
/*------------------------------------------------------------------------*/
|
|
13466
|
-
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
13467
|
-
/*------------------------------------------------------------------------*/
|
|
13468
|
-
/**
|
|
13469
|
-
* Update (also called on mount)
|
|
13470
|
-
* @author Gabe Abrams
|
|
13471
|
-
*/
|
|
13472
|
-
useEffect(() => {
|
|
13473
|
-
// Skip if no child
|
|
13474
|
-
if (!childRef.current) {
|
|
13475
|
-
return;
|
|
13476
|
-
}
|
|
13477
|
-
// Store copy of tooltip
|
|
13478
|
-
let t;
|
|
13479
|
-
// Initialize tooltip
|
|
13480
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
13481
|
-
// Import bootstrap tooltip
|
|
13482
|
-
const BSTooltip = (yield import('bootstrap')).Tooltip;
|
|
13483
|
-
// Initialize
|
|
13484
|
-
t = new BSTooltip(childRef.current, {
|
|
13485
|
-
title: text,
|
|
13486
|
-
placement: 'top',
|
|
13487
|
-
trigger: 'hover',
|
|
13488
|
-
});
|
|
13489
|
-
}))();
|
|
13490
|
-
// Clean up tooltip
|
|
13491
|
-
return () => {
|
|
13492
|
-
if (t) {
|
|
13493
|
-
t.dispose();
|
|
13494
|
-
}
|
|
13495
|
-
};
|
|
13496
|
-
}, [text]);
|
|
13497
|
-
/*------------------------------------------------------------------------*/
|
|
13498
|
-
/* ------------------------------- Render ------------------------------- */
|
|
13499
|
-
/*------------------------------------------------------------------------*/
|
|
13500
|
-
/*----------------------------------------*/
|
|
13501
|
-
/* --------------- Main UI -------------- */
|
|
13502
|
-
/*----------------------------------------*/
|
|
13503
|
-
// Clone child and add ref
|
|
13504
|
-
return React__default.cloneElement(children, { ref: childRef });
|
|
13505
|
-
};
|
|
13506
|
-
|
|
13507
13516
|
/**
|
|
13508
13517
|
* A toggle switch that toggles on or off
|
|
13509
13518
|
* @author Alessandra De Lucas
|