@mmb-digital/ds-lilly 0.6.2-beta.1 → 0.7.0
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 +42 -17
- package/dist/types/src/components/Form/Autocomplete2/Autocomplete2.d.ts +3 -1
- package/dist/types/src/components/Form/Select2/Select2.d.ts +3 -1
- package/package.json +1 -1
- package/dist/.DS_Store +0 -0
- package/dist/ds-lilly.css.map +0 -1
- package/dist/ds-lilly.d.ts +0 -2498
- package/dist/ds-lilly.js.map +0 -1
package/dist/ds-lilly.js
CHANGED
|
@@ -98469,7 +98469,7 @@ var Autocomplete2_spreadArray = (undefined && undefined.__spreadArray) || functi
|
|
|
98469
98469
|
|
|
98470
98470
|
|
|
98471
98471
|
var Autocomplete2 = function (_a) {
|
|
98472
|
-
var _b = _a.asyncDelayMilliseconds, asyncDelayMilliseconds = _b === void 0 ? 200 : _b, _c = _a.canAlwaysCreateNewItem, canAlwaysCreateNewItem = _c === void 0 ? false : _c, disabledTooltip = _a.disabledTooltip, _d = _a.displayDetails, displayDetails = _d === void 0 ? false : _d, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _e = _a.filterMinimumLength, filterMinimumLength = _e === void 0 ? 2 : _e, _f = _a.hasFullWidthOptions, hasFullWidthOptions = _f === void 0 ? true : _f, help = _a.help, isDisabled = _a.isDisabled, isLazyLoaded = _a.isLazyLoaded, isLoading = _a.isLoading, _g = _a.items, inputItems = _g === void 0 ? [] : _g, label = _a.label, labelTooltip = _a.labelTooltip, loadItems = _a.loadItems, loadMoreItems = _a.loadMoreItems, name = _a.name, messages = _a.messages, _h = _a.newItemMinimumLength, newItemMinimumLength = _h === void 0 ? 2 : _h, onBlur = _a.onBlur, onChange = _a.onChange, onCreateNewItem = _a.onCreateNewItem, onFocus = _a.onFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
98472
|
+
var _b = _a.asyncDelayMilliseconds, asyncDelayMilliseconds = _b === void 0 ? 200 : _b, _c = _a.canAlwaysCreateNewItem, canAlwaysCreateNewItem = _c === void 0 ? false : _c, disabledTooltip = _a.disabledTooltip, _d = _a.displayDetails, displayDetails = _d === void 0 ? false : _d, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _e = _a.filterMinimumLength, filterMinimumLength = _e === void 0 ? 2 : _e, _f = _a.hasFullWidthOptions, hasFullWidthOptions = _f === void 0 ? true : _f, help = _a.help, isDisabled = _a.isDisabled, isLazyLoaded = _a.isLazyLoaded, isLoading = _a.isLoading, _g = _a.items, inputItems = _g === void 0 ? [] : _g, label = _a.label, labelTooltip = _a.labelTooltip, loadItems = _a.loadItems, loadMoreItems = _a.loadMoreItems, name = _a.name, messages = _a.messages, _h = _a.newItemMinimumLength, newItemMinimumLength = _h === void 0 ? 2 : _h, onBlur = _a.onBlur, onChange = _a.onChange, onCreateNewItem = _a.onCreateNewItem, onFocus = _a.onFocus, onItemFocus = _a.onItemFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
98473
98473
|
var _j = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _j[0], setIsDropdownVisible = _j[1];
|
|
98474
98474
|
var _k = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(null), buttonValue = _k[0], setButtonValue = _k[1];
|
|
98475
98475
|
var _l = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), typingMode = _l[0], setTypingMode = _l[1];
|
|
@@ -98651,15 +98651,17 @@ var Autocomplete2 = function (_a) {
|
|
|
98651
98651
|
(_b = document.getElementById(name + "_list-createNew")) === null || _b === void 0 ? void 0 : _b.focus();
|
|
98652
98652
|
};
|
|
98653
98653
|
var focusFulltextInput = function () {
|
|
98654
|
-
|
|
98655
|
-
|
|
98656
|
-
|
|
98657
|
-
|
|
98658
|
-
|
|
98659
|
-
|
|
98660
|
-
|
|
98661
|
-
|
|
98662
|
-
|
|
98654
|
+
setTimeout(function () {
|
|
98655
|
+
var _a;
|
|
98656
|
+
try {
|
|
98657
|
+
var inputElement = document.getElementById(name + "_input");
|
|
98658
|
+
inputElement === null || inputElement === void 0 ? void 0 : inputElement.select();
|
|
98659
|
+
}
|
|
98660
|
+
catch (err) {
|
|
98661
|
+
// set focus as failback
|
|
98662
|
+
(_a = document.getElementById(name + "_input")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
98663
|
+
}
|
|
98664
|
+
});
|
|
98663
98665
|
};
|
|
98664
98666
|
var resetFulltext = function (clearFulltext) {
|
|
98665
98667
|
if (clearFulltext === void 0) { clearFulltext = true; }
|
|
@@ -98760,6 +98762,12 @@ var Autocomplete2 = function (_a) {
|
|
|
98760
98762
|
var position = getItemIndexPosition({ item: item, category: category });
|
|
98761
98763
|
setCurrentItemPosition(position);
|
|
98762
98764
|
scrollToItem(item, category);
|
|
98765
|
+
if (onItemFocus && position !== currentItemPosition) {
|
|
98766
|
+
var focusedItem_1 = isCategorised(items)
|
|
98767
|
+
? items[category].items[item]
|
|
98768
|
+
: items[item];
|
|
98769
|
+
onItemFocus(focusedItem_1);
|
|
98770
|
+
}
|
|
98763
98771
|
};
|
|
98764
98772
|
var handleCreateNewOption = function () {
|
|
98765
98773
|
setButtonValue({ label: fulltextValue, value: fulltextValue });
|
|
@@ -99002,10 +99010,14 @@ var Autocomplete2 = function (_a) {
|
|
|
99002
99010
|
}); };
|
|
99003
99011
|
var handleDropdownVisibilityChange = function (isVisible) {
|
|
99004
99012
|
if (!isVisible) {
|
|
99013
|
+
var trimmedFulltextValue = fulltextValue.trim();
|
|
99005
99014
|
setIsDropdownVisible(isVisible);
|
|
99006
99015
|
setTypingMode(isVisible);
|
|
99016
|
+
if (!trimmedFulltextValue) {
|
|
99017
|
+
propagateChange();
|
|
99018
|
+
}
|
|
99007
99019
|
resetFulltext();
|
|
99008
|
-
handleBlur(buttonValue);
|
|
99020
|
+
handleBlur(trimmedFulltextValue ? buttonValue : undefined);
|
|
99009
99021
|
}
|
|
99010
99022
|
};
|
|
99011
99023
|
var renderDropdownContent = function () {
|
|
@@ -107275,7 +107287,7 @@ var Select2_spreadArray = (undefined && undefined.__spreadArray) || function (to
|
|
|
107275
107287
|
|
|
107276
107288
|
var Select2 = function (_a) {
|
|
107277
107289
|
var _b;
|
|
107278
|
-
var disabledTooltip = _a.disabledTooltip, _c = _a.displayDetails, displayDetails = _c === void 0 ? false : _c, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _d = _a.hasFullWidthOptions, hasFullWidthOptions = _d === void 0 ? true : _d, help = _a.help, isDisabled = _a.isDisabled, items = _a.items, label = _a.label, labelTooltip = _a.labelTooltip, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
107290
|
+
var disabledTooltip = _a.disabledTooltip, _c = _a.displayDetails, displayDetails = _c === void 0 ? false : _c, dropdownTheme = _a.dropdownTheme, emptyValueLabel = _a.emptyValueLabel, error = _a.error, _d = _a.hasFullWidthOptions, hasFullWidthOptions = _d === void 0 ? true : _d, help = _a.help, isDisabled = _a.isDisabled, items = _a.items, label = _a.label, labelTooltip = _a.labelTooltip, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, onItemFocus = _a.onItemFocus, placeholder = _a.placeholder, testId = _a.testId, theme = _a.theme, value = _a.value;
|
|
107279
107291
|
var _e = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _e[0], setIsDropdownVisible = _e[1];
|
|
107280
107292
|
var _f = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(null), buttonValue = _f[0], setButtonValue = _f[1];
|
|
107281
107293
|
var _g = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(-1), currentItemPosition = _g[0], setCurrentItemPosition = _g[1];
|
|
@@ -107345,12 +107357,19 @@ var Select2 = function (_a) {
|
|
|
107345
107357
|
var itemIndexPosition = getItemIndexPosition(itemIndex);
|
|
107346
107358
|
setCurrentItemPosition(itemIndexPosition);
|
|
107347
107359
|
}, [isDropdownVisible, getItemIndexByValue, value, getItemIndexPosition]);
|
|
107348
|
-
var scrollToItem = function (item, category) {
|
|
107349
|
-
var _a;
|
|
107360
|
+
var scrollToItem = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (item, category) {
|
|
107361
|
+
var _a, _b, _c, _d, _e;
|
|
107350
107362
|
if (category === void 0) { category = -1; }
|
|
107351
107363
|
var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
|
|
107352
|
-
|
|
107353
|
-
|
|
107364
|
+
var dropdownId = name + "_dropdown";
|
|
107365
|
+
var dropdownHalfHeight = (((_a = document.getElementById(dropdownId)) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
|
|
107366
|
+
var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
|
|
107367
|
+
var itemOffset = ((_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0;
|
|
107368
|
+
if (itemOffset > dropdownHalfHeight) {
|
|
107369
|
+
(_d = document
|
|
107370
|
+
.getElementById(dropdownId)) === null || _d === void 0 ? void 0 : _d.scrollTo(0, (((_e = document.getElementById(itemElementId)) === null || _e === void 0 ? void 0 : _e.offsetTop) || 0) - dropdownHalfHeight + itemHalfHeight);
|
|
107371
|
+
}
|
|
107372
|
+
}, [isCategorised, name]);
|
|
107354
107373
|
var handleComboBoxClick = function () {
|
|
107355
107374
|
if (!isDropdownVisible) {
|
|
107356
107375
|
setTimeout(function () {
|
|
@@ -107419,6 +107438,12 @@ var Select2 = function (_a) {
|
|
|
107419
107438
|
var position = getItemIndexPosition({ item: item, category: category });
|
|
107420
107439
|
setCurrentItemPosition(position);
|
|
107421
107440
|
scrollToItem(item, category);
|
|
107441
|
+
if (onItemFocus && position !== currentItemPosition) {
|
|
107442
|
+
var focusedItem_1 = isCategorised
|
|
107443
|
+
? items[category].items[item]
|
|
107444
|
+
: items[item];
|
|
107445
|
+
onItemFocus(focusedItem_1);
|
|
107446
|
+
}
|
|
107422
107447
|
};
|
|
107423
107448
|
var handleOptionKeyPress = function (event) {
|
|
107424
107449
|
var key = event.key;
|
|
@@ -107515,7 +107540,7 @@ var Select2 = function (_a) {
|
|
|
107515
107540
|
};
|
|
107516
107541
|
return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(FormGroup2, Select2_assign({ theme: classBinder_cx({ 'f-group2--open': isDropdownVisible }, theme) }, fromGroupProps),
|
|
107517
107542
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(contexts_Select2Context.Provider, { value: select2context },
|
|
107518
|
-
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" },
|
|
107543
|
+
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { dropdownId: name + "_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" },
|
|
107519
107544
|
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', { 'f-control2--large': displayDetails }), disabled: isDisabled, id: name + "_button", name: name, type: "button", onClick: handleComboBoxClick, onFocus: onFocus, onKeyDown: handleButtonKeyPress },
|
|
107520
107545
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: classBinder_cx("f-control2__" + (buttonValue ? 'value' : 'placeholder')) }, buttonValue ? buttonValue : placeholder),
|
|
107521
107546
|
external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" }))), onVisibleChange: function (state) { return setIsDropdownVisible(state); } }, isCategorised ? external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2CategorisedOptions, null) : external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2Options, null)))));
|
|
@@ -43,6 +43,8 @@ export interface Autocomplete2PropsType extends FormField2PropsType {
|
|
|
43
43
|
newItemMinimumLength?: number;
|
|
44
44
|
/** A callback to create new item */
|
|
45
45
|
onCreateNewItem?: (value?: string) => void;
|
|
46
|
+
/** A callback called on highlight dropdown item */
|
|
47
|
+
onItemFocus?: (item: ItemType | CategorisedItemType) => void;
|
|
46
48
|
}
|
|
47
|
-
export declare const Autocomplete2: ({ asyncDelayMilliseconds, canAlwaysCreateNewItem, disabledTooltip, displayDetails, dropdownTheme, emptyValueLabel, error, filterMinimumLength, hasFullWidthOptions, help, isDisabled, isLazyLoaded, isLoading, items: inputItems, label, labelTooltip, loadItems, loadMoreItems, name, messages, newItemMinimumLength, onBlur, onChange, onCreateNewItem, onFocus, placeholder, testId, theme, value }: Autocomplete2PropsType) => JSX.Element;
|
|
49
|
+
export declare const Autocomplete2: ({ asyncDelayMilliseconds, canAlwaysCreateNewItem, disabledTooltip, displayDetails, dropdownTheme, emptyValueLabel, error, filterMinimumLength, hasFullWidthOptions, help, isDisabled, isLazyLoaded, isLoading, items: inputItems, label, labelTooltip, loadItems, loadMoreItems, name, messages, newItemMinimumLength, onBlur, onChange, onCreateNewItem, onFocus, onItemFocus, placeholder, testId, theme, value }: Autocomplete2PropsType) => JSX.Element;
|
|
48
50
|
//# sourceMappingURL=Autocomplete2.d.ts.map
|
|
@@ -11,6 +11,8 @@ export interface Select2PropsType extends FormField2PropsType {
|
|
|
11
11
|
hasFullWidthOptions?: boolean;
|
|
12
12
|
/** List of options to select. */
|
|
13
13
|
items: ItemType[] | CategorisedItemType[];
|
|
14
|
+
/** A callback called on highlight dropdown item */
|
|
15
|
+
onItemFocus?: (item: ItemType | CategorisedItemType) => void;
|
|
14
16
|
}
|
|
15
17
|
export interface ItemType {
|
|
16
18
|
/** Optional value for withAmount variant. */
|
|
@@ -32,5 +34,5 @@ export interface CategorisedItemType {
|
|
|
32
34
|
label: string;
|
|
33
35
|
items: ItemType[];
|
|
34
36
|
}
|
|
35
|
-
export declare const Select2: ({ disabledTooltip, displayDetails, dropdownTheme, emptyValueLabel, error, hasFullWidthOptions, help, isDisabled, items, label, labelTooltip, name, onBlur, onChange, onFocus, placeholder, testId, theme, value }: Select2PropsType) => JSX.Element;
|
|
37
|
+
export declare const Select2: ({ disabledTooltip, displayDetails, dropdownTheme, emptyValueLabel, error, hasFullWidthOptions, help, isDisabled, items, label, labelTooltip, name, onBlur, onChange, onFocus, onItemFocus, placeholder, testId, theme, value }: Select2PropsType) => JSX.Element;
|
|
36
38
|
//# sourceMappingURL=Select2.d.ts.map
|
package/package.json
CHANGED
package/dist/.DS_Store
DELETED
|
Binary file
|