@haiilo/catalyst 14.1.0 → 14.2.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/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/{p-15f91e64.entry.js → p-6e04e50f.entry.js} +3 -3
- package/dist/catalyst/p-6e04e50f.entry.js.map +1 -0
- package/dist/cjs/cat-alert_30.cjs.entry.js +93 -75
- package/dist/collection/components/cat-select/cat-select.js +18 -5
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/components/cat-select2.js +18 -5
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/floating-ui.dom.js +75 -70
- package/dist/components/floating-ui.dom.js.map +1 -1
- package/dist/esm/cat-alert_30.entry.js +93 -75
- package/dist/types/components/cat-select/cat-select.d.ts +4 -0
- package/package.json +2 -2
- package/dist/catalyst/p-15f91e64.entry.js.map +0 -1
|
@@ -4893,6 +4893,71 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
|
4893
4893
|
return coords;
|
|
4894
4894
|
}
|
|
4895
4895
|
|
|
4896
|
+
/**
|
|
4897
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
4898
|
+
* element is overflowing a given clipping boundary on each side.
|
|
4899
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
4900
|
+
* - negative = how many pixels left before it will overflow
|
|
4901
|
+
* - 0 = lies flush with the boundary
|
|
4902
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
4903
|
+
*/
|
|
4904
|
+
async function detectOverflow(state, options) {
|
|
4905
|
+
var _await$platform$isEle;
|
|
4906
|
+
if (options === void 0) {
|
|
4907
|
+
options = {};
|
|
4908
|
+
}
|
|
4909
|
+
const {
|
|
4910
|
+
x,
|
|
4911
|
+
y,
|
|
4912
|
+
platform,
|
|
4913
|
+
rects,
|
|
4914
|
+
elements,
|
|
4915
|
+
strategy
|
|
4916
|
+
} = state;
|
|
4917
|
+
const {
|
|
4918
|
+
boundary = 'clippingAncestors',
|
|
4919
|
+
rootBoundary = 'viewport',
|
|
4920
|
+
elementContext = 'floating',
|
|
4921
|
+
altBoundary = false,
|
|
4922
|
+
padding = 0
|
|
4923
|
+
} = evaluate(options, state);
|
|
4924
|
+
const paddingObject = getPaddingObject(padding);
|
|
4925
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
4926
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
4927
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
4928
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
4929
|
+
boundary,
|
|
4930
|
+
rootBoundary,
|
|
4931
|
+
strategy
|
|
4932
|
+
}));
|
|
4933
|
+
const rect = elementContext === 'floating' ? {
|
|
4934
|
+
x,
|
|
4935
|
+
y,
|
|
4936
|
+
width: rects.floating.width,
|
|
4937
|
+
height: rects.floating.height
|
|
4938
|
+
} : rects.reference;
|
|
4939
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
4940
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
4941
|
+
x: 1,
|
|
4942
|
+
y: 1
|
|
4943
|
+
} : {
|
|
4944
|
+
x: 1,
|
|
4945
|
+
y: 1
|
|
4946
|
+
};
|
|
4947
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
4948
|
+
elements,
|
|
4949
|
+
rect,
|
|
4950
|
+
offsetParent,
|
|
4951
|
+
strategy
|
|
4952
|
+
}) : rect);
|
|
4953
|
+
return {
|
|
4954
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
4955
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
4956
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
4957
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
4958
|
+
};
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4896
4961
|
/**
|
|
4897
4962
|
* Computes the `x` and `y` coordinates that will place the floating element
|
|
4898
4963
|
* next to a given reference element.
|
|
@@ -4922,6 +4987,7 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
4922
4987
|
let middlewareData = {};
|
|
4923
4988
|
let resetCount = 0;
|
|
4924
4989
|
for (let i = 0; i < validMiddleware.length; i++) {
|
|
4990
|
+
var _platform$detectOverf;
|
|
4925
4991
|
const {
|
|
4926
4992
|
name,
|
|
4927
4993
|
fn
|
|
@@ -4939,7 +5005,10 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
4939
5005
|
strategy,
|
|
4940
5006
|
middlewareData,
|
|
4941
5007
|
rects,
|
|
4942
|
-
platform
|
|
5008
|
+
platform: {
|
|
5009
|
+
...platform,
|
|
5010
|
+
detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
|
|
5011
|
+
},
|
|
4943
5012
|
elements: {
|
|
4944
5013
|
reference,
|
|
4945
5014
|
floating
|
|
@@ -4984,71 +5053,6 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
4984
5053
|
};
|
|
4985
5054
|
};
|
|
4986
5055
|
|
|
4987
|
-
/**
|
|
4988
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
4989
|
-
* element is overflowing a given clipping boundary on each side.
|
|
4990
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
4991
|
-
* - negative = how many pixels left before it will overflow
|
|
4992
|
-
* - 0 = lies flush with the boundary
|
|
4993
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
4994
|
-
*/
|
|
4995
|
-
async function detectOverflow(state, options) {
|
|
4996
|
-
var _await$platform$isEle;
|
|
4997
|
-
if (options === void 0) {
|
|
4998
|
-
options = {};
|
|
4999
|
-
}
|
|
5000
|
-
const {
|
|
5001
|
-
x,
|
|
5002
|
-
y,
|
|
5003
|
-
platform,
|
|
5004
|
-
rects,
|
|
5005
|
-
elements,
|
|
5006
|
-
strategy
|
|
5007
|
-
} = state;
|
|
5008
|
-
const {
|
|
5009
|
-
boundary = 'clippingAncestors',
|
|
5010
|
-
rootBoundary = 'viewport',
|
|
5011
|
-
elementContext = 'floating',
|
|
5012
|
-
altBoundary = false,
|
|
5013
|
-
padding = 0
|
|
5014
|
-
} = evaluate(options, state);
|
|
5015
|
-
const paddingObject = getPaddingObject(padding);
|
|
5016
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
5017
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
5018
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
5019
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
5020
|
-
boundary,
|
|
5021
|
-
rootBoundary,
|
|
5022
|
-
strategy
|
|
5023
|
-
}));
|
|
5024
|
-
const rect = elementContext === 'floating' ? {
|
|
5025
|
-
x,
|
|
5026
|
-
y,
|
|
5027
|
-
width: rects.floating.width,
|
|
5028
|
-
height: rects.floating.height
|
|
5029
|
-
} : rects.reference;
|
|
5030
|
-
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
5031
|
-
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
5032
|
-
x: 1,
|
|
5033
|
-
y: 1
|
|
5034
|
-
} : {
|
|
5035
|
-
x: 1,
|
|
5036
|
-
y: 1
|
|
5037
|
-
};
|
|
5038
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
5039
|
-
elements,
|
|
5040
|
-
rect,
|
|
5041
|
-
offsetParent,
|
|
5042
|
-
strategy
|
|
5043
|
-
}) : rect);
|
|
5044
|
-
return {
|
|
5045
|
-
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
5046
|
-
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
5047
|
-
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
5048
|
-
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
5049
|
-
};
|
|
5050
|
-
}
|
|
5051
|
-
|
|
5052
5056
|
/**
|
|
5053
5057
|
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
5054
5058
|
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
@@ -5099,7 +5103,7 @@ const flip$1 = function (options) {
|
|
|
5099
5103
|
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
5100
5104
|
}
|
|
5101
5105
|
const placements = [initialPlacement, ...fallbackPlacements];
|
|
5102
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
5106
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
5103
5107
|
const overflows = [];
|
|
5104
5108
|
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
5105
5109
|
if (checkMainAxis) {
|
|
@@ -5283,7 +5287,8 @@ const shift$1 = function (options) {
|
|
|
5283
5287
|
const {
|
|
5284
5288
|
x,
|
|
5285
5289
|
y,
|
|
5286
|
-
placement
|
|
5290
|
+
placement,
|
|
5291
|
+
platform
|
|
5287
5292
|
} = state;
|
|
5288
5293
|
const {
|
|
5289
5294
|
mainAxis: checkMainAxis = true,
|
|
@@ -5306,7 +5311,7 @@ const shift$1 = function (options) {
|
|
|
5306
5311
|
x,
|
|
5307
5312
|
y
|
|
5308
5313
|
};
|
|
5309
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
5314
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
5310
5315
|
const crossAxis = getSideAxis(getSide(placement));
|
|
5311
5316
|
const mainAxis = getOppositeAxis(crossAxis);
|
|
5312
5317
|
let mainAxisCoord = coords[mainAxis];
|
|
@@ -5370,7 +5375,7 @@ const size$1 = function (options) {
|
|
|
5370
5375
|
apply = () => {},
|
|
5371
5376
|
...detectOverflowOptions
|
|
5372
5377
|
} = evaluate(options, state);
|
|
5373
|
-
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
5378
|
+
const overflow = await platform.detectOverflow(state, detectOverflowOptions);
|
|
5374
5379
|
const side = getSide(placement);
|
|
5375
5380
|
const alignment = getAlignment(placement);
|
|
5376
5381
|
const isYAxis = getSideAxis(placement) === 'y';
|
|
@@ -9373,21 +9378,27 @@ const CatSelect = class {
|
|
|
9373
9378
|
options
|
|
9374
9379
|
});
|
|
9375
9380
|
});
|
|
9381
|
+
this.renderSubscription?.unsubscribe();
|
|
9382
|
+
if (connector.renderOptions$) {
|
|
9383
|
+
this.renderSubscription = connector.renderOptions$.subscribe(() => {
|
|
9384
|
+
this.rerenderOptions();
|
|
9385
|
+
});
|
|
9386
|
+
}
|
|
9376
9387
|
}
|
|
9377
9388
|
render() {
|
|
9378
9389
|
this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
|
|
9379
|
-
return (index.h(index.Host, { key: '
|
|
9390
|
+
return (index.h(index.Host, { key: '7489b4123c900ebefa06dcebde32b0a4ee52d4a3' }, index.h("div", { key: '9669441806e8bebc5f583957cc1a24330f06085a', class: {
|
|
9380
9391
|
'select-field': true,
|
|
9381
9392
|
'select-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false,
|
|
9382
9393
|
'select-multiple': this.multiple
|
|
9383
|
-
} }, index.h("div", { key: '
|
|
9394
|
+
} }, index.h("div", { key: 'a94a2217157c125e34802b140843d2fffd63283f', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (index.h("label", { key: '557e2754156cb4484972dcccca103451db00a01e', htmlFor: `select-${this.id}-input`, part: "label" }, index.h("span", { key: '8d229578a218717dbe78a63e416cba36cc300c37', class: "label-wrapper" }, (this.hasSlottedLabel && index.h("slot", { key: 'f1700687e21b73edce905bc8325479bed8c31962', name: "label" })) || this.label, index.h("div", { key: '109009794bab604eca5d3f690858145ac770ea81', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (index.h("span", { key: '5868ecd309ab485a60439fd6743be56947f9d43e', class: "label-optional", "aria-hidden": "true" }, "(", index$1.catI18nRegistry.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (index.h("span", { key: '8e61a17e1d1b9f3fc584c08824b243b5f0c07c0f', class: "label-optional", "aria-hidden": "true" }, "(", index$1.catI18nRegistry.t('input.required'), ")"))))))), index.h("div", { key: '9d211cd7674cda6f9bcfeebaf1252055239421ce', class: "select-container" }, index.h("div", { key: '878137436714dff589d4731ada14d11e443ab4a6', class: { 'select-wrapper': true, 'select-disabled': this.disabled, 'select-invalid': this.invalid }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, index.h("div", { key: '7a268001a9bc895aa5fd1157a57f89555ad9e868', class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (index.h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (index.h("span", { class: {
|
|
9384
9395
|
pill: true,
|
|
9385
9396
|
'select-no-open': true,
|
|
9386
9397
|
'select-option-active': this.state.activeSelectionIndex === i
|
|
9387
|
-
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, index.h("span", null, item.render.label), !this.disabled && (index.h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: index$1.catI18nRegistry.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1, "data-dropdown-no-close": true }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (index.h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, icon: this.state.selection[0].render.avatar.icon, initials: this.state.selection[0].render.avatar.initials ?? '' })) : null, index.h("input", { key: '
|
|
9398
|
+
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, index.h("span", null, item.render.label), !this.disabled && (index.h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: index$1.catI18nRegistry.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1, "data-dropdown-no-close": true }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (index.h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, icon: this.state.selection[0].render.avatar.icon, initials: this.state.selection[0].render.avatar.initials ?? '' })) : null, index.h("input", { key: 'dd9c6f767f5cfc9c2e3e0f37dd4bad075f1169c8', "data-test": this.testId, ...this.nativeAttributes, part: "input", id: `select-${this.id}-input`, class: "select-input", role: "combobox", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined, "aria-autocomplete": "list", onInput: this.onInput.bind(this), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })), this.state.isResolving && index.h("cat-spinner", { key: 'c3ed10971f8f29d352df71a5bb577ff3f4499ccd' }), this.invalid && (index.h("cat-icon", { key: 'c4788a44a097252f58c43769edec339c57ed74e4', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), (this.state.selection.length || this.state.term.length) &&
|
|
9388
9399
|
!this.disabled &&
|
|
9389
9400
|
!this.state.isResolving &&
|
|
9390
|
-
this.clearable ? (index.h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "$cat:input-close", variant: "text", size: "s", a11yLabel: index$1.catI18nRegistry.t('input.clear'), onCatClick: () => this.clearInput(), "data-dropdown-no-close": true })) : null, !this.state.isResolving && (index.h("cat-button", { key: '
|
|
9401
|
+
this.clearable ? (index.h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "$cat:input-close", variant: "text", size: "s", a11yLabel: index$1.catI18nRegistry.t('input.clear'), onCatClick: () => this.clearInput(), "data-dropdown-no-close": true })) : null, !this.state.isResolving && (index.h("cat-button", { key: 'a1ae4dfc03feec1a556f818ea08ba8a53b10f132', iconOnly: true, icon: "$cat:select-open", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? index$1.catI18nRegistry.t('select.close') : index$1.catI18nRegistry.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving, "data-dropdown-no-close": true }))), this.hasHint && (index.h(CatFormHint, { key: '2557e44ce584d96cc8497cee27d8e6e8f6464fd9', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && index.h("slot", { name: "hint" }), errorMap: this.errorMap })))), index.h("div", { key: '795de862359d06464591e32d3a410a8974a55028', class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (index.h("cat-scrollable", { key: 'b88fc1b204533e3714b8533c10b7a817fe2d4ef1', class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, index.h("ul", { key: 'f0fe6e0c398c7682363174ec6e9f04eaa8e25073', class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isFirstLoading
|
|
9391
9402
|
? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (index.h("li", { class: "select-option-loading" }, index.h("cat-skeleton", { variant: "body", lines: 1 }), index.h("cat-skeleton", { variant: "body", lines: 1 }))))
|
|
9392
9403
|
: !this.state.options.length &&
|
|
9393
9404
|
!this.tags && (index.h("li", { class: "select-option-empty" }, this.noItems ? this.noItems : index$1.catI18nRegistry.t('select.empty')))))))));
|
|
@@ -9411,7 +9422,7 @@ const CatSelect = class {
|
|
|
9411
9422
|
return (index.h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": isOptionSelected ? 'true' : 'false' }, this.multiple ? (index.h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: isOptionSelected, tabIndex: -1, labelLeft: true, onFocus: () => this.input?.focus(), onCatChange: e => {
|
|
9412
9423
|
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
9413
9424
|
e.stopPropagation();
|
|
9414
|
-
} }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, index.h("span", { class: "select-option-text" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
|
|
9425
|
+
} }, index.h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (index.h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, index.h("span", { class: "select-option-text", part: "option" }, index.h("span", { class: "select-option-label" }, getLabel()), index.h("span", { class: "select-option-description" }, item.render.description))))) : (index.h("div", { class: {
|
|
9415
9426
|
'select-option-inner': true,
|
|
9416
9427
|
'select-option-single': true,
|
|
9417
9428
|
'select-option-active': this.state.activeOptionIndex === i
|
|
@@ -9509,6 +9520,11 @@ const CatSelect = class {
|
|
|
9509
9520
|
});
|
|
9510
9521
|
}
|
|
9511
9522
|
}
|
|
9523
|
+
rerenderOptions() {
|
|
9524
|
+
const optionItems = this.state.options.map(o => o.item);
|
|
9525
|
+
const updatedOptions = this.toSelectItems(this.connector, optionItems);
|
|
9526
|
+
this.patchState({ options: updatedOptions });
|
|
9527
|
+
}
|
|
9512
9528
|
toggle(item) {
|
|
9513
9529
|
this.isSelected(item.item.id)
|
|
9514
9530
|
? this.deselect(item.item.id)
|
|
@@ -9530,6 +9546,8 @@ const CatSelect = class {
|
|
|
9530
9546
|
this.connector = connector ?? this.connector;
|
|
9531
9547
|
this.subscription?.unsubscribe();
|
|
9532
9548
|
this.subscription = undefined;
|
|
9549
|
+
this.renderSubscription?.unsubscribe();
|
|
9550
|
+
this.renderSubscription = undefined;
|
|
9533
9551
|
this.state = INIT_STATE;
|
|
9534
9552
|
}
|
|
9535
9553
|
onClick(event) {
|
|
@@ -343,21 +343,27 @@ export class CatSelect {
|
|
|
343
343
|
options
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
|
+
this.renderSubscription?.unsubscribe();
|
|
347
|
+
if (connector.renderOptions$) {
|
|
348
|
+
this.renderSubscription = connector.renderOptions$.subscribe(() => {
|
|
349
|
+
this.rerenderOptions();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
346
352
|
}
|
|
347
353
|
render() {
|
|
348
354
|
this.hostElement.tabIndex = Number(this.hostElement.getAttribute('tabindex')) || 0;
|
|
349
|
-
return (h(Host, { key: '
|
|
355
|
+
return (h(Host, { key: '7489b4123c900ebefa06dcebde32b0a4ee52d4a3' }, h("div", { key: '9669441806e8bebc5f583957cc1a24330f06085a', class: {
|
|
350
356
|
'select-field': true,
|
|
351
357
|
'select-horizontal': this.horizontal ?? this.fallbackHorizontal ?? false,
|
|
352
358
|
'select-multiple': this.multiple
|
|
353
|
-
} }, h("div", { key: '
|
|
359
|
+
} }, h("div", { key: 'a94a2217157c125e34802b140843d2fffd63283f', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { key: '557e2754156cb4484972dcccca103451db00a01e', htmlFor: `select-${this.id}-input`, part: "label" }, h("span", { key: '8d229578a218717dbe78a63e416cba36cc300c37', class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { key: 'f1700687e21b73edce905bc8325479bed8c31962', name: "label" })) || this.label, h("div", { key: '109009794bab604eca5d3f690858145ac770ea81', class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { key: '5868ecd309ab485a60439fd6743be56947f9d43e', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { key: '8e61a17e1d1b9f3fc584c08824b243b5f0c07c0f', class: "label-optional", "aria-hidden": "true" }, "(", i18n.t('input.required'), ")"))))))), h("div", { key: '9d211cd7674cda6f9bcfeebaf1252055239421ce', class: "select-container" }, h("div", { key: '878137436714dff589d4731ada14d11e443ab4a6', class: { 'select-wrapper': true, 'select-disabled': this.disabled, 'select-invalid': this.invalid }, ref: el => (this.trigger = el), id: this.id, role: "combobox", "aria-expanded": this.state.isOpen || this.isPillboxActive(), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-required": this.required ? 'true' : false, "aria-activedescendant": this.activeDescendant, onClick: e => this.onClick(e) }, h("div", { key: '7a268001a9bc895aa5fd1157a57f89555ad9e868', class: "select-wrapper-inner" }, this.multiple && this.state.selection.length ? (h("div", { id: `select-pillbox-${this.id}`, role: "listbox", "aria-orientation": "horizontal", class: "select-pills" }, this.state.selection.map((item, i) => (h("span", { class: {
|
|
354
360
|
pill: true,
|
|
355
361
|
'select-no-open': true,
|
|
356
362
|
'select-option-active': this.state.activeSelectionIndex === i
|
|
357
|
-
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", null, item.render.label), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1, "data-dropdown-no-close": true }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, icon: this.state.selection[0].render.avatar.icon, initials: this.state.selection[0].render.avatar.initials ?? '' })) : null, h("input", { key: '
|
|
363
|
+
}, role: "option", "aria-selected": "true", id: `select-${this.id}-selection-${i}` }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", null, item.render.label), !this.disabled && (h("cat-button", { size: "xs", variant: "text", icon: "$cat:select-clear", iconOnly: true, a11yLabel: i18n.t('select.deselect'), onClick: () => this.deselect(item.item.id), tabIndex: -1, "data-dropdown-no-close": true }))))))) : this.state.selection.length && this.state.selection[0].render.avatar ? (h("cat-avatar", { label: this.state.selection[0].render.label, round: this.state.selection[0].render.avatar.round, src: this.state.selection[0].render.avatar.src, icon: this.state.selection[0].render.avatar.icon, initials: this.state.selection[0].render.avatar.initials ?? '' })) : null, h("input", { key: 'dd9c6f767f5cfc9c2e3e0f37dd4bad075f1169c8', "data-test": this.testId, ...this.nativeAttributes, part: "input", id: `select-${this.id}-input`, class: "select-input", role: "combobox", ref: el => (this.input = el), "aria-controls": this.isPillboxActive() ? `select-pillbox-${this.id}` : `select-listbox-${this.id}`, "aria-activedescendant": this.activeDescendant, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined, "aria-autocomplete": "list", onInput: this.onInput.bind(this), value: !this.multiple ? this.state.term : undefined, placeholder: this.placeholder, disabled: this.disabled || this.state.isResolving })), this.state.isResolving && h("cat-spinner", { key: 'c3ed10971f8f29d352df71a5bb577ff3f4499ccd' }), this.invalid && (h("cat-icon", { key: 'c4788a44a097252f58c43769edec339c57ed74e4', icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), (this.state.selection.length || this.state.term.length) &&
|
|
358
364
|
!this.disabled &&
|
|
359
365
|
!this.state.isResolving &&
|
|
360
|
-
this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "$cat:input-close", variant: "text", size: "s", a11yLabel: i18n.t('input.clear'), onCatClick: () => this.clearInput(), "data-dropdown-no-close": true })) : null, !this.state.isResolving && (h("cat-button", { key: '
|
|
366
|
+
this.clearable ? (h("cat-button", { id: `select-clear-btn-${this.id}`, iconOnly: true, icon: "$cat:input-close", variant: "text", size: "s", a11yLabel: i18n.t('input.clear'), onCatClick: () => this.clearInput(), "data-dropdown-no-close": true })) : null, !this.state.isResolving && (h("cat-button", { key: 'a1ae4dfc03feec1a556f818ea08ba8a53b10f132', iconOnly: true, icon: "$cat:select-open", class: { 'select-btn': true, 'select-btn-open': this.state.isOpen }, variant: "text", size: "s", a11yLabel: this.state.isOpen ? i18n.t('select.close') : i18n.t('select.open'), "aria-controls": `select-listbox-${this.id}`, "aria-expanded": this.state.isOpen, tabIndex: -1, disabled: this.disabled || this.state.isResolving, "data-dropdown-no-close": true }))), this.hasHint && (h(CatFormHint, { key: '2557e44ce584d96cc8497cee27d8e6e8f6464fd9', id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))), h("div", { key: '795de862359d06464591e32d3a410a8974a55028', class: "select-dropdown", ref: el => (this.dropdown = el), style: { display: this.state.isOpen ? 'block' : undefined } }, this.state.isOpen && (h("cat-scrollable", { key: 'b88fc1b204533e3714b8533c10b7a817fe2d4ef1', class: "select-options-wrapper", scrolledBuffer: 56, noOverflowX: true, noOverscroll: true, noScrolledInit: true, onScrolledBottom: () => this.more$.next() }, h("ul", { key: 'f0fe6e0c398c7682363174ec6e9f04eaa8e25073', class: "select-options", role: "listbox", "aria-multiselectable": this.multiple, "aria-setsize": this.state.totalElements, id: `select-listbox-${this.id}` }, this.optionsList, this.state.isFirstLoading
|
|
361
367
|
? Array.from(Array(CatSelect.SKELETON_COUNT)).map(() => (h("li", { class: "select-option-loading" }, h("cat-skeleton", { variant: "body", lines: 1 }), h("cat-skeleton", { variant: "body", lines: 1 }))))
|
|
362
368
|
: !this.state.options.length &&
|
|
363
369
|
!this.tags && (h("li", { class: "select-option-empty" }, this.noItems ? this.noItems : i18n.t('select.empty')))))))));
|
|
@@ -381,7 +387,7 @@ export class CatSelect {
|
|
|
381
387
|
return (h("li", { role: "option", class: "select-option", id: `select-${this.id}-option-${i}`, "aria-selected": isOptionSelected ? 'true' : 'false' }, this.multiple ? (h("cat-checkbox", { class: { 'select-option-active': this.state.activeOptionIndex === i }, checked: isOptionSelected, tabIndex: -1, labelLeft: true, onFocus: () => this.input?.focus(), onCatChange: e => {
|
|
382
388
|
!isTagOption ? this.toggle(item) : this.toggleTag(item);
|
|
383
389
|
e.stopPropagation();
|
|
384
|
-
} }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", { class: "select-option-text" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
|
|
390
|
+
} }, h("span", { slot: "label", class: "select-option-inner" }, item.render.avatar ? (h("cat-avatar", { label: item.render.label, round: item.render.avatar.round, src: item.render.avatar.src, icon: item.render.avatar.icon, initials: item.render.avatar.initials ?? '' })) : null, h("span", { class: "select-option-text", part: "option" }, h("span", { class: "select-option-label" }, getLabel()), h("span", { class: "select-option-description" }, item.render.description))))) : (h("div", { class: {
|
|
385
391
|
'select-option-inner': true,
|
|
386
392
|
'select-option-single': true,
|
|
387
393
|
'select-option-active': this.state.activeOptionIndex === i
|
|
@@ -479,6 +485,11 @@ export class CatSelect {
|
|
|
479
485
|
});
|
|
480
486
|
}
|
|
481
487
|
}
|
|
488
|
+
rerenderOptions() {
|
|
489
|
+
const optionItems = this.state.options.map(o => o.item);
|
|
490
|
+
const updatedOptions = this.toSelectItems(this.connector, optionItems);
|
|
491
|
+
this.patchState({ options: updatedOptions });
|
|
492
|
+
}
|
|
482
493
|
toggle(item) {
|
|
483
494
|
this.isSelected(item.item.id)
|
|
484
495
|
? this.deselect(item.item.id)
|
|
@@ -500,6 +511,8 @@ export class CatSelect {
|
|
|
500
511
|
this.connector = connector ?? this.connector;
|
|
501
512
|
this.subscription?.unsubscribe();
|
|
502
513
|
this.subscription = undefined;
|
|
514
|
+
this.renderSubscription?.unsubscribe();
|
|
515
|
+
this.renderSubscription = undefined;
|
|
503
516
|
this.state = INIT_STATE;
|
|
504
517
|
}
|
|
505
518
|
onClick(event) {
|