@mmb-digital/ds-lilly 0.3.5 → 0.3.9
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/ds-lilly.js
CHANGED
|
@@ -96310,7 +96310,7 @@ var Dropdown_assign = (undefined && undefined.__assign) || function () {
|
|
|
96310
96310
|
|
|
96311
96311
|
var SCROLL_DEVIATION = 16;
|
|
96312
96312
|
var Dropdown = function (_a) {
|
|
96313
|
-
var children = _a.children, closeOnOutsideClick = _a.closeOnOutsideClick, closeOnTriggerHidden = _a.closeOnTriggerHidden, _b = _a.delayHide, delayHide = _b === void 0 ? 200 : _b, delayShow = _a.delayShow, forceVisibility = _a.forceVisibility, _c = _a.hasSameWidthAsTrigger, hasSameWidthAsTrigger = _c === void 0 ? false : _c, interactive = _a.interactive, _d = _a.isOpenByDefault, isOpenByDefault = _d === void 0 ? false : _d, onOutsideClick = _a.onOutsideClick, onScrollToEnd = _a.onScrollToEnd, onVisibleChange = _a.onVisibleChange, _e = _a.placement, placement = _e === void 0 ? 'auto' : _e, testId = _a.testId, theme = _a.theme, _f = _a.trigger, trigger = _f === void 0 ? 'focus' : _f, triggerComponent = _a.triggerComponent;
|
|
96313
|
+
var children = _a.children, closeOnOutsideClick = _a.closeOnOutsideClick, closeOnTriggerHidden = _a.closeOnTriggerHidden, _b = _a.delayHide, delayHide = _b === void 0 ? 200 : _b, delayShow = _a.delayShow, dropdownId = _a.dropdownId, forceVisibility = _a.forceVisibility, _c = _a.hasSameWidthAsTrigger, hasSameWidthAsTrigger = _c === void 0 ? false : _c, interactive = _a.interactive, _d = _a.isOpenByDefault, isOpenByDefault = _d === void 0 ? false : _d, onOutsideClick = _a.onOutsideClick, onScrollToEnd = _a.onScrollToEnd, onVisibleChange = _a.onVisibleChange, _e = _a.placement, placement = _e === void 0 ? 'auto' : _e, testId = _a.testId, theme = _a.theme, _f = _a.trigger, trigger = _f === void 0 ? 'focus' : _f, triggerComponent = _a.triggerComponent;
|
|
96314
96314
|
var tooltipRef = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])();
|
|
96315
96315
|
var _g = usePopperTooltip({
|
|
96316
96316
|
closeOnOutsideClick: closeOnOutsideClick,
|
|
@@ -96342,7 +96342,7 @@ var Dropdown = function (_a) {
|
|
|
96342
96342
|
visible && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["Fragment"], null,
|
|
96343
96343
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", Dropdown_assign({ ref: setRef, "data-testid": testId }, getTooltipProps({
|
|
96344
96344
|
className: classBinder_cx('c-dropdown', { 'c-dropdown--fullWidth': hasSameWidthAsTrigger }, theme)
|
|
96345
|
-
}), { onScroll: handleScroll }), children),
|
|
96345
|
+
}), { id: dropdownId, onScroll: handleScroll }), children),
|
|
96346
96346
|
onOutsideClick && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "c-dropdown__outside", onClick: onOutsideClick })))));
|
|
96347
96347
|
};
|
|
96348
96348
|
|
|
@@ -98331,11 +98331,11 @@ var Autocomplete2 = function (_a) {
|
|
|
98331
98331
|
.map(function (item, index) { return (!item.isDisabled ? { category: -1, item: index } : undefined); })
|
|
98332
98332
|
.filter(Boolean);
|
|
98333
98333
|
}
|
|
98334
|
-
if (emptyValueLabel) {
|
|
98334
|
+
if (emptyValueLabel && map.length > 0 && (fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value)) {
|
|
98335
98335
|
return Autocomplete2_spreadArray([{ item: -1, category: -1 }], map);
|
|
98336
98336
|
}
|
|
98337
98337
|
return map;
|
|
98338
|
-
}, [items, isCategorised]);
|
|
98338
|
+
}, [items, isCategorised, fulltextValue, value, buttonValue]);
|
|
98339
98339
|
var showCreatable = !!onCreateNewItem &&
|
|
98340
98340
|
(itemsIndex.length === 0 || canAlwaysCreateNewItem) &&
|
|
98341
98341
|
typingMode &&
|
|
@@ -98436,11 +98436,22 @@ var Autocomplete2 = function (_a) {
|
|
|
98436
98436
|
}
|
|
98437
98437
|
}, [pagingState.loading]);
|
|
98438
98438
|
var scrollToItem = function (item, category, center) {
|
|
98439
|
-
var _a;
|
|
98439
|
+
var _a, _b, _c, _d, _e, _f;
|
|
98440
98440
|
if (category === void 0) { category = -1; }
|
|
98441
98441
|
if (center === void 0) { center = false; }
|
|
98442
98442
|
var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
|
|
98443
|
-
|
|
98443
|
+
if (center) {
|
|
98444
|
+
var dropdownHalfHeight = (((_a = document.getElementById('autocomplete_dropdown')) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
|
|
98445
|
+
var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
|
|
98446
|
+
var itemOffset = ((_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0;
|
|
98447
|
+
if (itemOffset > dropdownHalfHeight) {
|
|
98448
|
+
(_d = document
|
|
98449
|
+
.getElementById('autocomplete_dropdown')) === null || _d === void 0 ? void 0 : _d.scrollTo(0, (((_e = document.getElementById(itemElementId)) === null || _e === void 0 ? void 0 : _e.offsetTop) || 0) - dropdownHalfHeight + itemHalfHeight);
|
|
98450
|
+
}
|
|
98451
|
+
}
|
|
98452
|
+
else {
|
|
98453
|
+
(_f = document.getElementById(itemElementId)) === null || _f === void 0 ? void 0 : _f.scrollIntoView({ block: 'nearest' });
|
|
98454
|
+
}
|
|
98444
98455
|
};
|
|
98445
98456
|
var focusCreatable = function () {
|
|
98446
98457
|
var _a, _b;
|
|
@@ -98501,7 +98512,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98501
98512
|
loadAsyncItems();
|
|
98502
98513
|
}
|
|
98503
98514
|
var selectedItem_1 = itemsIndex[currentItemPosition];
|
|
98504
|
-
if (selectedItem_1) {
|
|
98515
|
+
if (selectedItem_1 && selectedItem_1.item !== -1) {
|
|
98505
98516
|
setTimeout(function () { return scrollToItem(selectedItem_1.item, selectedItem_1.category, true); }, 100);
|
|
98506
98517
|
}
|
|
98507
98518
|
}
|
|
@@ -98684,11 +98695,12 @@ var Autocomplete2 = function (_a) {
|
|
|
98684
98695
|
if (key === KEYS.Enter) {
|
|
98685
98696
|
event.preventDefault();
|
|
98686
98697
|
if (isDropdownVisible) {
|
|
98698
|
+
var minItemsToAutoselect = emptyValueLabel && !value ? 2 : 1;
|
|
98687
98699
|
if (showCreatable && itemsIndex.length === 0) {
|
|
98688
98700
|
handleCreateNewOption();
|
|
98689
98701
|
}
|
|
98690
|
-
else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length
|
|
98691
|
-
var _a = itemsIndex[
|
|
98702
|
+
else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length >= minItemsToAutoselect) {
|
|
98703
|
+
var _a = itemsIndex[minItemsToAutoselect - 1], category = _a.category, item = _a.item;
|
|
98692
98704
|
var selectedItem = isCategorised
|
|
98693
98705
|
? items[category].items[item]
|
|
98694
98706
|
: items[item];
|
|
@@ -98833,7 +98845,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98833
98845
|
};
|
|
98834
98846
|
var focusedItem = itemsIndex[currentItemPosition];
|
|
98835
98847
|
var select2context = {
|
|
98836
|
-
emptyValueLabel: emptyValueLabel,
|
|
98848
|
+
emptyValueLabel: itemsIndex.length > 0 && (fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value) ? emptyValueLabel : undefined,
|
|
98837
98849
|
focusedCategoryIndex: focusedItem ? focusedItem.category : -1,
|
|
98838
98850
|
focusedItemIndex: focusedItem ? focusedItem.item : -1,
|
|
98839
98851
|
items: items,
|
|
@@ -98856,7 +98868,7 @@ var Autocomplete2 = function (_a) {
|
|
|
98856
98868
|
};
|
|
98857
98869
|
return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(FormGroup2, Autocomplete2_assign({ theme: classBinder_cx({ 'f-group2--open': isDropdownVisible }, theme) }, fromGroupProps),
|
|
98858
98870
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(contexts_Select2Context.Provider, { value: select2context },
|
|
98859
|
-
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { forceVisibility: isDropdownVisible, hasSameWidthAsTrigger: hasFullWidthOptions, placement: "bottom-start", theme: dropdownTheme, trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-controlWrap", "data-testid": testId, role: "combobox" }, typingMode ? (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('f-control2 f-control2--select', { 'f-control2--large': displayDetails }) },
|
|
98871
|
+
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { dropdownId: "autocomplete_dropdown", forceVisibility: isDropdownVisible, hasSameWidthAsTrigger: hasFullWidthOptions, placement: "bottom-start", theme: dropdownTheme, trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-controlWrap", "data-testid": testId, role: "combobox" }, typingMode ? (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('f-control2 f-control2--select', { 'f-control2--large': displayDetails }) },
|
|
98860
98872
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("input", { autoComplete: "off", className: classBinder_cx('f-autocomplete__input'), disabled: isDisabled, id: name + "_input", name: name, placeholder: placeholder, type: "text", value: fulltextValue, onChange: handleFulltextChange, onKeyDown: handleFulltextKeyPress }),
|
|
98861
98873
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-invalid": !!error, className: classBinder_cx('f-autocomplete__button'), disabled: isDisabled, id: name + "_toggle_button", name: name, tabIndex: -1, type: "button", onClick: toggleDropdown },
|
|
98862
98874
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" })))) : (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-expanded": isDropdownVisible, "aria-haspopup": "listbox", "aria-invalid": !!error, "aria-labelledby": name + "_label " + name, className: classBinder_cx('f-control2 f-control2--select', {
|
|
@@ -104284,20 +104296,15 @@ var Checkbox2_assign = (undefined && undefined.__assign) || function () {
|
|
|
104284
104296
|
|
|
104285
104297
|
|
|
104286
104298
|
var Checkbox2 = function (_a) {
|
|
104287
|
-
var _b = _a.allowEventPropagation, allowEventPropagation = _b === void 0 ? false : _b, disabledTooltip = _a.disabledTooltip, error = _a.error, help = _a.help, isDisabled = _a.isDisabled, label = _a.label, labelTooltip = _a.labelTooltip, name = _a.name, onChange = _a.onChange, testId = _a.testId, theme = _a.theme,
|
|
104288
|
-
var _d = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(defaultState), isChecked = _d[0], setIsChecked = _d[1];
|
|
104299
|
+
var _b = _a.allowEventPropagation, allowEventPropagation = _b === void 0 ? false : _b, disabledTooltip = _a.disabledTooltip, error = _a.error, help = _a.help, isDisabled = _a.isDisabled, label = _a.label, labelTooltip = _a.labelTooltip, name = _a.name, onChange = _a.onChange, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
104289
104300
|
var handleOnChange = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (event) {
|
|
104290
104301
|
if (!isDisabled) {
|
|
104291
|
-
onChange && onChange(!
|
|
104292
|
-
setIsChecked(!isChecked);
|
|
104302
|
+
onChange && onChange(!value);
|
|
104293
104303
|
}
|
|
104294
104304
|
if (!allowEventPropagation) {
|
|
104295
104305
|
event.stopPropagation();
|
|
104296
104306
|
}
|
|
104297
|
-
}, [allowEventPropagation,
|
|
104298
|
-
Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
|
|
104299
|
-
setIsChecked(defaultState);
|
|
104300
|
-
}, [defaultState]);
|
|
104307
|
+
}, [allowEventPropagation, value, isDisabled, onChange]);
|
|
104301
104308
|
var handleOnKeyPress = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (event) {
|
|
104302
104309
|
var key = event.key;
|
|
104303
104310
|
if (key === KEYS.Space)
|
|
@@ -104312,17 +104319,14 @@ var Checkbox2 = function (_a) {
|
|
|
104312
104319
|
name: name,
|
|
104313
104320
|
theme: theme
|
|
104314
104321
|
};
|
|
104315
|
-
Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
|
|
104316
|
-
setIsChecked(defaultState);
|
|
104317
|
-
}, [defaultState]);
|
|
104318
104322
|
return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(FormGroup2, Checkbox2_assign({}, formGroupProps),
|
|
104319
|
-
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("label", { "aria-checked":
|
|
104323
|
+
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("label", { "aria-checked": value ? 'true' : 'false', className: classBinder_cx('f-checkbox2', {
|
|
104320
104324
|
'f-checkbox2--disabled': isDisabled
|
|
104321
104325
|
}, theme), "data-testid": testId, id: name, role: "checkbox", tabIndex: 0, onClick: handleOnChange, onKeyPress: handleOnKeyPress },
|
|
104322
104326
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: "f-checkbox2__over" },
|
|
104323
104327
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: classBinder_cx('f-checkbox2__indicator', {
|
|
104324
|
-
'f-checkbox2__indicator--checked':
|
|
104325
|
-
}) },
|
|
104328
|
+
'f-checkbox2__indicator--checked': value
|
|
104329
|
+
}) }, value && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "tickFill" }))),
|
|
104326
104330
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: "f-checkbox2__text" },
|
|
104327
104331
|
label,
|
|
104328
104332
|
labelTooltip && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Tooltip, { content: labelTooltip },
|
|
@@ -13,6 +13,8 @@ export interface DropdownPropsType extends ComponentPropsType {
|
|
|
13
13
|
delayHide?: number;
|
|
14
14
|
/** Delay in showing the tooltip (ms). */
|
|
15
15
|
delayShow?: number;
|
|
16
|
+
/** Dropdown menu element ID */
|
|
17
|
+
dropdownId?: string;
|
|
16
18
|
/** Set to use same width as triggerComponent. */
|
|
17
19
|
hasSameWidthAsTrigger?: boolean;
|
|
18
20
|
/** If true, hovering the tooltip will keep it open. */
|
|
@@ -33,5 +35,5 @@ export interface DropdownPropsType extends ComponentPropsType {
|
|
|
33
35
|
triggerComponent: ReactElement;
|
|
34
36
|
forceVisibility?: boolean;
|
|
35
37
|
}
|
|
36
|
-
export declare const Dropdown: ({ children, closeOnOutsideClick, closeOnTriggerHidden, delayHide, delayShow, forceVisibility, hasSameWidthAsTrigger, interactive, isOpenByDefault, onOutsideClick, onScrollToEnd, onVisibleChange, placement, testId, theme, trigger, triggerComponent }: DropdownPropsType) => JSX.Element;
|
|
38
|
+
export declare const Dropdown: ({ children, closeOnOutsideClick, closeOnTriggerHidden, delayHide, delayShow, dropdownId, forceVisibility, hasSameWidthAsTrigger, interactive, isOpenByDefault, onOutsideClick, onScrollToEnd, onVisibleChange, placement, testId, theme, trigger, triggerComponent }: DropdownPropsType) => JSX.Element;
|
|
37
39
|
//# sourceMappingURL=Dropdown.d.ts.map
|
|
@@ -2,5 +2,5 @@ import { FormField2PropsType } from '../../../types';
|
|
|
2
2
|
export declare type Checkbox2PropsType = Omit<FormField2PropsType, 'value'> & {
|
|
3
3
|
value?: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare const Checkbox2: ({ allowEventPropagation, disabledTooltip, error, help, isDisabled, label, labelTooltip, name, onChange, testId, theme, value
|
|
5
|
+
export declare const Checkbox2: ({ allowEventPropagation, disabledTooltip, error, help, isDisabled, label, labelTooltip, name, onChange, testId, theme, value }: Checkbox2PropsType) => JSX.Element;
|
|
6
6
|
//# sourceMappingURL=Checkbox2.d.ts.map
|