dce-reactkit 5.0.6 → 5.0.8
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 +96 -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/cjs/types/helpers/visitServerEndpoint.d.ts +5 -0
- package/dist/esm/index.js +96 -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/esm/types/helpers/visitServerEndpoint.d.ts +5 -0
- package/dist/index.d.ts +9 -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/src/components/Tooltip.tsx +17 -0
- package/src/helpers/visitServerEndpoint.tsx +5 -0
package/dist/cjs/index.js
CHANGED
|
@@ -826,6 +826,8 @@ const _setStubResponse = (opts) => {
|
|
|
826
826
|
* @param opts.path - the path of the server endpoint
|
|
827
827
|
* @param [opts.method=GET] - the method of the endpoint
|
|
828
828
|
* @param [opts.params] - query/body parameters to include
|
|
829
|
+
* @param [opts.headers] - custom headers to include; values must already be
|
|
830
|
+
* string to avoid issue with header serialization
|
|
829
831
|
* @returns response from server
|
|
830
832
|
*/
|
|
831
833
|
const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -875,6 +877,7 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
|
|
|
875
877
|
path: opts.path,
|
|
876
878
|
method: (_c = opts.method) !== null && _c !== void 0 ? _c : 'GET',
|
|
877
879
|
params,
|
|
880
|
+
headers: opts.headers,
|
|
878
881
|
});
|
|
879
882
|
// Check for failure
|
|
880
883
|
if (!response || !response.body) {
|
|
@@ -2668,6 +2671,81 @@ const CopiableBox = (props) => {
|
|
|
2668
2671
|
"Copy")))));
|
|
2669
2672
|
};
|
|
2670
2673
|
|
|
2674
|
+
/**
|
|
2675
|
+
* Simple tooltip component
|
|
2676
|
+
* @author Gabe Abrams
|
|
2677
|
+
*/
|
|
2678
|
+
/*------------------------------------------------------------------------*/
|
|
2679
|
+
/* ------------------------------ Component ----------------------------- */
|
|
2680
|
+
/*------------------------------------------------------------------------*/
|
|
2681
|
+
const Tooltip = (props) => {
|
|
2682
|
+
/*------------------------------------------------------------------------*/
|
|
2683
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
2684
|
+
/*------------------------------------------------------------------------*/
|
|
2685
|
+
/* -------------- Props ------------- */
|
|
2686
|
+
// Destructure all props
|
|
2687
|
+
const { text, children, } = props;
|
|
2688
|
+
/* -------------- Refs -------------- */
|
|
2689
|
+
// Child ref
|
|
2690
|
+
const childRef = React.useRef(undefined);
|
|
2691
|
+
/*------------------------------------------------------------------------*/
|
|
2692
|
+
/* ------------------------- Lifecycle Functions ------------------------ */
|
|
2693
|
+
/*------------------------------------------------------------------------*/
|
|
2694
|
+
/**
|
|
2695
|
+
* Update (also called on mount)
|
|
2696
|
+
* @author Gabe Abrams
|
|
2697
|
+
*/
|
|
2698
|
+
React.useEffect(() => {
|
|
2699
|
+
// Skip if no child
|
|
2700
|
+
if (!childRef.current) {
|
|
2701
|
+
return;
|
|
2702
|
+
}
|
|
2703
|
+
// Store copy of tooltip
|
|
2704
|
+
let t;
|
|
2705
|
+
// Initialize tooltip
|
|
2706
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
2707
|
+
// Import bootstrap tooltip
|
|
2708
|
+
const BSTooltip = (yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('bootstrap')); })).Tooltip;
|
|
2709
|
+
// The child may have unmounted while the dynamic import above was
|
|
2710
|
+
// resolving (React nulls the ref on unmount). Constructing a
|
|
2711
|
+
// Bootstrap tooltip with a null element causes an error,
|
|
2712
|
+
// so bail out instead
|
|
2713
|
+
if (!childRef.current) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
// Initialize
|
|
2717
|
+
t = new BSTooltip(childRef.current, {
|
|
2718
|
+
title: text,
|
|
2719
|
+
placement: 'top',
|
|
2720
|
+
trigger: 'hover',
|
|
2721
|
+
});
|
|
2722
|
+
}))();
|
|
2723
|
+
// Clean up tooltip
|
|
2724
|
+
return () => {
|
|
2725
|
+
if (t) {
|
|
2726
|
+
t.dispose();
|
|
2727
|
+
// Bootstrap's hide() queues a transition-end callback that can
|
|
2728
|
+
// fire AFTER dispose and touch the (now null) trigger map and
|
|
2729
|
+
// element (twbs/bootstrap issue #37474). Point those private
|
|
2730
|
+
// fields at harmless stand-ins so the late callback is a no-op
|
|
2731
|
+
// instead of a crash.
|
|
2732
|
+
/* eslint-disable no-underscore-dangle */
|
|
2733
|
+
t._activeTrigger = {};
|
|
2734
|
+
t._element = document.createElement('noscript');
|
|
2735
|
+
/* eslint-enable no-underscore-dangle */
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
}, [text]);
|
|
2739
|
+
/*------------------------------------------------------------------------*/
|
|
2740
|
+
/* ------------------------------- Render ------------------------------- */
|
|
2741
|
+
/*------------------------------------------------------------------------*/
|
|
2742
|
+
/*----------------------------------------*/
|
|
2743
|
+
/* --------------- Main UI -------------- */
|
|
2744
|
+
/*----------------------------------------*/
|
|
2745
|
+
// Clone child and add ref
|
|
2746
|
+
return React__default["default"].cloneElement(children, { ref: childRef });
|
|
2747
|
+
};
|
|
2748
|
+
|
|
2671
2749
|
/**
|
|
2672
2750
|
* Reusable nested item picker
|
|
2673
2751
|
* @author Yuen Ler Chow
|
|
@@ -2705,12 +2783,12 @@ const NestableItemList = (props) => {
|
|
|
2705
2783
|
/*------------------------------------------------------------------------*/
|
|
2706
2784
|
/* -------------- Props ------------- */
|
|
2707
2785
|
// Destructure all props
|
|
2708
|
-
const { items, onChanged, } = props;
|
|
2786
|
+
const { items, onChanged, startWithGroupsExpanded, } = props;
|
|
2709
2787
|
/* -------------- State ------------- */
|
|
2710
2788
|
// Create initial map of child expanded booleans
|
|
2711
2789
|
const initChildExpanded = {};
|
|
2712
2790
|
items.forEach((item) => {
|
|
2713
|
-
initChildExpanded[String(item.id)] =
|
|
2791
|
+
initChildExpanded[String(item.id)] = !!startWithGroupsExpanded;
|
|
2714
2792
|
});
|
|
2715
2793
|
// Initial state
|
|
2716
2794
|
const initialState = {
|
|
@@ -2799,6 +2877,14 @@ const NestableItemList = (props) => {
|
|
|
2799
2877
|
/* ------------------------------- Render ------------------------------- */
|
|
2800
2878
|
/*------------------------------------------------------------------------*/
|
|
2801
2879
|
return (React__default["default"].createElement("div", null, items.map((item) => {
|
|
2880
|
+
var _a;
|
|
2881
|
+
// Human-readable label for accessibility. Prefer the explicit
|
|
2882
|
+
// ariaLabel, then fall back to the name if it is a plain string
|
|
2883
|
+
const accessibleName = ((_a = item.ariaLabel) !== null && _a !== void 0 ? _a : (typeof item.name === 'string' ? item.name : ''));
|
|
2884
|
+
// Checkbox and Text
|
|
2885
|
+
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) => {
|
|
2886
|
+
onChanged(changeChecked(item.id, checked, items));
|
|
2887
|
+
}, ariaLabel: `Select ${accessibleName}`, checkedVariant: Variant$1.Light, uncheckedVariant: Variant$1.Light }));
|
|
2802
2888
|
return (React__default["default"].createElement("div", { key: item.id },
|
|
2803
2889
|
React__default["default"].createElement("span", { className: "NestableItemList-dropdown-button-container d-inline-block", style: {
|
|
2804
2890
|
minWidth: '2rem',
|
|
@@ -2810,17 +2896,18 @@ const NestableItemList = (props) => {
|
|
|
2810
2896
|
type: ActionType$9.ToggleChild,
|
|
2811
2897
|
id: item.id,
|
|
2812
2898
|
});
|
|
2813
|
-
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${
|
|
2899
|
+
}, "aria-label": `${childExpanded[item.id] ? 'Hide' : 'Show'} items in ${accessibleName}` },
|
|
2814
2900
|
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: childExpanded[item.id] ? freeSolidSvgIcons.faChevronDown : freeSolidSvgIcons.faChevronRight })))),
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2901
|
+
item.tooltip
|
|
2902
|
+
? (React__default["default"].createElement(Tooltip, { text: item.tooltip },
|
|
2903
|
+
React__default["default"].createElement("span", { className: "d-inline-block" }, checkbox)))
|
|
2904
|
+
: checkbox,
|
|
2818
2905
|
(item.isGroup && childExpanded[item.id]) && (React__default["default"].createElement("div", { className: "NestableItemList-children-container", style: {
|
|
2819
2906
|
paddingLeft: '2.2rem',
|
|
2820
2907
|
} },
|
|
2821
2908
|
React__default["default"].createElement(NestableItemList, { items: item.children, onChanged: (updatedItems) => {
|
|
2822
2909
|
onChanged(changeItems(item.id, updatedItems));
|
|
2823
|
-
} })))));
|
|
2910
|
+
}, startWithGroupsExpanded: startWithGroupsExpanded })))));
|
|
2824
2911
|
})));
|
|
2825
2912
|
};
|
|
2826
2913
|
|
|
@@ -2837,7 +2924,7 @@ const ItemPicker = (props) => {
|
|
|
2837
2924
|
/*------------------------------------------------------------------------*/
|
|
2838
2925
|
/* -------------- Props ------------- */
|
|
2839
2926
|
// Destructure all props
|
|
2840
|
-
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, } = props;
|
|
2927
|
+
const { title, items, onChanged, noBottomMargin, hideSelectAllOrNoneButtons, startWithGroupsExpanded, } = props;
|
|
2841
2928
|
/*------------------------------------------------------------------------*/
|
|
2842
2929
|
/* ------------------------- Component Functions ------------------------ */
|
|
2843
2930
|
/*------------------------------------------------------------------------*/
|
|
@@ -2894,7 +2981,7 @@ const ItemPicker = (props) => {
|
|
|
2894
2981
|
// Main UI
|
|
2895
2982
|
return (React__default["default"].createElement(TabBox, { title: title, noBottomMargin: noBottomMargin, topRightChildren: selectAllOrNone },
|
|
2896
2983
|
React__default["default"].createElement("div", { style: { overflowX: 'auto' } },
|
|
2897
|
-
React__default["default"].createElement(NestableItemList, { items: items, onChanged: onChanged }))));
|
|
2984
|
+
React__default["default"].createElement(NestableItemList, { items: items, onChanged: onChanged, startWithGroupsExpanded: startWithGroupsExpanded }))));
|
|
2898
2985
|
};
|
|
2899
2986
|
|
|
2900
2987
|
/**
|
|
@@ -13471,65 +13558,6 @@ const DBEntryManagerPanel = (props) => {
|
|
|
13471
13558
|
return (React__default["default"].createElement("div", null, body));
|
|
13472
13559
|
};
|
|
13473
13560
|
|
|
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
13561
|
/**
|
|
13534
13562
|
* A toggle switch that toggles on or off
|
|
13535
13563
|
* @author Alessandra De Lucas
|