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
package/dist/cjs/index.js
CHANGED
|
@@ -2668,6 +2668,65 @@ const CopiableBox = (props) => {
|
|
|
2668
2668
|
"Copy")))));
|
|
2669
2669
|
};
|
|
2670
2670
|
|
|
2671
|
+
/**
|
|
2672
|
+
* Simple tooltip component
|
|
2673
|
+
* @author Gabe Abrams
|
|
2674
|
+
*/
|
|
2675
|
+
/*------------------------------------------------------------------------*/
|
|
2676
|
+
/* ------------------------------ Component ----------------------------- */
|
|
2677
|
+
/*------------------------------------------------------------------------*/
|
|
2678
|
+
const Tooltip = (props) => {
|
|
2679
|
+
/*------------------------------------------------------------------------*/
|
|
2680
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
2681
|
+
/*------------------------------------------------------------------------*/
|
|
2682
|
+
/* -------------- Props ------------- */
|
|
2683
|
+
// Destructure all props
|
|
2684
|
+
const { text, children, } = props;
|
|
2685
|
+
/* -------------- Refs -------------- */
|
|
2686
|
+
// Child ref
|
|
2687
|
+
const childRef = React.useRef(undefined);
|
|
2688
|
+
/*------------------------------------------------------------------------*/
|
|
2689
|
+
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
2690
|
+
/*------------------------------------------------------------------------*/
|
|
2691
|
+
/**
|
|
2692
|
+
* Update (also called on mount)
|
|
2693
|
+
* @author Gabe Abrams
|
|
2694
|
+
*/
|
|
2695
|
+
React.useEffect(() => {
|
|
2696
|
+
// Skip if no child
|
|
2697
|
+
if (!childRef.current) {
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
// Store copy of tooltip
|
|
2701
|
+
let t;
|
|
2702
|
+
// Initialize tooltip
|
|
2703
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
2704
|
+
// Import bootstrap tooltip
|
|
2705
|
+
const BSTooltip = (yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('bootstrap')); })).Tooltip;
|
|
2706
|
+
// Initialize
|
|
2707
|
+
t = new BSTooltip(childRef.current, {
|
|
2708
|
+
title: text,
|
|
2709
|
+
placement: 'top',
|
|
2710
|
+
trigger: 'hover',
|
|
2711
|
+
});
|
|
2712
|
+
}))();
|
|
2713
|
+
// Clean up tooltip
|
|
2714
|
+
return () => {
|
|
2715
|
+
if (t) {
|
|
2716
|
+
t.dispose();
|
|
2717
|
+
}
|
|
2718
|
+
};
|
|
2719
|
+
}, [text]);
|
|
2720
|
+
/*------------------------------------------------------------------------*/
|
|
2721
|
+
/* ------------------------------- Render ------------------------------- */
|
|
2722
|
+
/*------------------------------------------------------------------------*/
|
|
2723
|
+
/*----------------------------------------*/
|
|
2724
|
+
/* --------------- Main UI -------------- */
|
|
2725
|
+
/*----------------------------------------*/
|
|
2726
|
+
// Clone child and add ref
|
|
2727
|
+
return React__default["default"].cloneElement(children, { ref: childRef });
|
|
2728
|
+
};
|
|
2729
|
+
|
|
2671
2730
|
/**
|
|
2672
2731
|
* Reusable nested item picker
|
|
2673
2732
|
* @author Yuen Ler Chow
|
|
@@ -2705,12 +2764,12 @@ const NestableItemList = (props) => {
|
|
|
2705
2764
|
/*------------------------------------------------------------------------*/
|
|
2706
2765
|
/* -------------- Props ------------- */
|
|
2707
2766
|
// Destructure all props
|
|
2708
|
-
const { items, onChanged, } = props;
|
|
2767
|
+
const { items, onChanged, startWithGroupsExpanded, } = props;
|
|
2709
2768
|
/* -------------- State ------------- */
|
|
2710
2769
|
// Create initial map of child expanded booleans
|
|
2711
2770
|
const initChildExpanded = {};
|
|
2712
2771
|
items.forEach((item) => {
|
|
2713
|
-
initChildExpanded[String(item.id)] =
|
|
2772
|
+
initChildExpanded[String(item.id)] = !!startWithGroupsExpanded;
|
|
2714
2773
|
});
|
|
2715
2774
|
// Initial state
|
|
2716
2775
|
const initialState = {
|
|
@@ -2799,6 +2858,14 @@ const NestableItemList = (props) => {
|
|
|
2799
2858
|
/* ------------------------------- Render ------------------------------- */
|
|
2800
2859
|
/*------------------------------------------------------------------------*/
|
|
2801
2860
|
return (React__default["default"].createElement("div", null, items.map((item) => {
|
|
2861
|
+
var _a;
|
|
2862
|
+
// Human-readable label for accessibility. Prefer the explicit
|
|
2863
|
+
// ariaLabel, then fall back to the name if it is a plain string
|
|
2864
|
+
const accessibleName = ((_a = item.ariaLabel) !== null && _a !== void 0 ? _a : (typeof item.name === 'string' ? item.name : ''));
|
|
2865
|
+
// Checkbox and Text
|
|
2866
|
+
const checkbox = (React__default["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) => {
|
|
2867
|
+
onChanged(changeChecked(item.id, checked, items));
|
|
2868
|
+
}, ariaLabel: `Select ${accessibleName}`, checkedVariant: Variant$1.Light, uncheckedVariant: Variant$1.Light }));
|
|
2802
2869
|
return (React__default["default"].createElement("div", { key: item.id },
|
|
2803
2870
|
React__default["default"].createElement("span", { className: "NestableItemList-dropdown-button-container d-inline-block", style: {
|
|
2804
2871
|
minWidth: '2rem',
|
|
@@ -2810,17 +2877,18 @@ const NestableItemList = (props) => {
|
|
|
2810
2877
|
type: ActionType$9.ToggleChild,
|
|
2811
2878
|
id: item.id,
|
|
2812
2879
|
});
|
|
2813
|
-
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${
|
|
2880
|
+
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${accessibleName}` },
|
|
2814
2881
|
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: childExpanded[item.id] ? freeSolidSvgIcons.faChevronDown : freeSolidSvgIcons.faChevronRight })))),
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2882
|
+
item.tooltip
|
|
2883
|
+
? (React__default["default"].createElement(Tooltip, { text: item.tooltip },
|
|
2884
|
+
React__default["default"].createElement("span", { className: "d-inline-block" }, checkbox)))
|
|
2885
|
+
: checkbox,
|
|
2818
2886
|
(item.isGroup && childExpanded[item.id]) && (React__default["default"].createElement("div", { className: "NestableItemList-children-container", style: {
|
|
2819
2887
|
paddingLeft: '2.2rem',
|
|
2820
2888
|
} },
|
|
2821
2889
|
React__default["default"].createElement(NestableItemList, { items: item.children, onChanged: (updatedItems) => {
|
|
2822
2890
|
onChanged(changeItems(item.id, updatedItems));
|
|
2823
|
-
} })))));
|
|
2891
|
+
}, startWithGroupsExpanded: startWithGroupsExpanded })))));
|
|
2824
2892
|
})));
|
|
2825
2893
|
};
|
|
2826
2894
|
|
|
@@ -2837,7 +2905,7 @@ const ItemPicker = (props) => {
|
|
|
2837
2905
|
/*------------------------------------------------------------------------*/
|
|
2838
2906
|
/* -------------- Props ------------- */
|
|
2839
2907
|
// Destructure all props
|
|
2840
|
-
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, } = props;
|
|
2908
|
+
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, startWithGroupsExpanded, } = props;
|
|
2841
2909
|
/*------------------------------------------------------------------------*/
|
|
2842
2910
|
/* ------------------------- Component Functions ------------------------ */
|
|
2843
2911
|
/*------------------------------------------------------------------------*/
|
|
@@ -2894,7 +2962,7 @@ const ItemPicker = (props) => {
|
|
|
2894
2962
|
// Main UI
|
|
2895
2963
|
return (React__default["default"].createElement(TabBox, { title: title, noBottomMargin: noBottomMargin, topRightChildren: selectAllOrNone },
|
|
2896
2964
|
React__default["default"].createElement("div", { style: { overflowX: 'auto' } },
|
|
2897
|
-
React__default["default"].createElement(NestableItemList, { items: items, onChanged: onChanged }))));
|
|
2965
|
+
React__default["default"].createElement(NestableItemList, { items: items, onChanged: onChanged, startWithGroupsExpanded: startWithGroupsExpanded }))));
|
|
2898
2966
|
};
|
|
2899
2967
|
|
|
2900
2968
|
/**
|
|
@@ -13471,65 +13539,6 @@ const DBEntryManagerPanel = (props) => {
|
|
|
13471
13539
|
return (React__default["default"].createElement("div", null, body));
|
|
13472
13540
|
};
|
|
13473
13541
|
|
|
13474
|
-
/**
|
|
13475
|
-
* Simple tooltip component
|
|
13476
|
-
* @author Gabe Abrams
|
|
13477
|
-
*/
|
|
13478
|
-
/*------------------------------------------------------------------------*/
|
|
13479
|
-
/* ------------------------------ Component ----------------------------- */
|
|
13480
|
-
/*------------------------------------------------------------------------*/
|
|
13481
|
-
const Tooltip = (props) => {
|
|
13482
|
-
/*------------------------------------------------------------------------*/
|
|
13483
|
-
/* -------------------------------- Setup ------------------------------- */
|
|
13484
|
-
/*------------------------------------------------------------------------*/
|
|
13485
|
-
/* -------------- Props ------------- */
|
|
13486
|
-
// Destructure all props
|
|
13487
|
-
const { text, children, } = props;
|
|
13488
|
-
/* -------------- Refs -------------- */
|
|
13489
|
-
// Child ref
|
|
13490
|
-
const childRef = React.useRef(undefined);
|
|
13491
|
-
/*------------------------------------------------------------------------*/
|
|
13492
|
-
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
13493
|
-
/*------------------------------------------------------------------------*/
|
|
13494
|
-
/**
|
|
13495
|
-
* Update (also called on mount)
|
|
13496
|
-
* @author Gabe Abrams
|
|
13497
|
-
*/
|
|
13498
|
-
React.useEffect(() => {
|
|
13499
|
-
// Skip if no child
|
|
13500
|
-
if (!childRef.current) {
|
|
13501
|
-
return;
|
|
13502
|
-
}
|
|
13503
|
-
// Store copy of tooltip
|
|
13504
|
-
let t;
|
|
13505
|
-
// Initialize tooltip
|
|
13506
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
13507
|
-
// Import bootstrap tooltip
|
|
13508
|
-
const BSTooltip = (yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('bootstrap')); })).Tooltip;
|
|
13509
|
-
// Initialize
|
|
13510
|
-
t = new BSTooltip(childRef.current, {
|
|
13511
|
-
title: text,
|
|
13512
|
-
placement: 'top',
|
|
13513
|
-
trigger: 'hover',
|
|
13514
|
-
});
|
|
13515
|
-
}))();
|
|
13516
|
-
// Clean up tooltip
|
|
13517
|
-
return () => {
|
|
13518
|
-
if (t) {
|
|
13519
|
-
t.dispose();
|
|
13520
|
-
}
|
|
13521
|
-
};
|
|
13522
|
-
}, [text]);
|
|
13523
|
-
/*------------------------------------------------------------------------*/
|
|
13524
|
-
/* ------------------------------- Render ------------------------------- */
|
|
13525
|
-
/*------------------------------------------------------------------------*/
|
|
13526
|
-
/*----------------------------------------*/
|
|
13527
|
-
/* --------------- Main UI -------------- */
|
|
13528
|
-
/*----------------------------------------*/
|
|
13529
|
-
// Clone child and add ref
|
|
13530
|
-
return React__default["default"].cloneElement(children, { ref: childRef });
|
|
13531
|
-
};
|
|
13532
|
-
|
|
13533
13542
|
/**
|
|
13534
13543
|
* A toggle switch that toggles on or off
|
|
13535
13544
|
* @author Alessandra De Lucas
|