@allxsmith/bestax-bulma 5.8.2 → 5.8.3
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/index.cjs.js
CHANGED
|
@@ -7069,10 +7069,16 @@ Rate.displayName = 'Rate';
|
|
|
7069
7069
|
* onSelect={(item) => console.log(item)}
|
|
7070
7070
|
* />
|
|
7071
7071
|
*/
|
|
7072
|
-
const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, placeholder, field = 'label', clearable = false, openOnFocus = false, keepFirst = false, keepOpen = false, selectOnClickOutside = false, maxHeight = 200, loading = false, disabled = false, checkInfiniteScroll = false, infiniteScrollDistance = 50, color, size, onInput, onSelect, onActiveChange, onInfiniteScroll, itemTemplate, header, footer, empty, name, form, required,
|
|
7072
|
+
const Autocomplete = React.forwardRef(({ data = [], value: controlledValue, placeholder, field = 'label', clearable = false, openOnFocus = false, keepFirst = false, keepOpen = false, selectOnClickOutside = false, maxHeight = 200, loading = false, disabled = false, checkInfiniteScroll = false, infiniteScrollDistance = 50, color, size, onInput, onSelect, onActiveChange, onInfiniteScroll, itemTemplate, header, footer, empty, name, form, required, id,
|
|
7073
7073
|
// Field props
|
|
7074
7074
|
label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, className, ...props }, ref) => {
|
|
7075
7075
|
const insideField = useInsideField();
|
|
7076
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7077
|
+
label,
|
|
7078
|
+
id,
|
|
7079
|
+
labelProps,
|
|
7080
|
+
rendersLabel: !insideField,
|
|
7081
|
+
});
|
|
7076
7082
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
7077
7083
|
const { classPrefix } = useConfig();
|
|
7078
7084
|
const containerRef = React.useRef(null);
|
|
@@ -7268,7 +7274,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7268
7274
|
[`is-${messageColor}`]: !!messageColor,
|
|
7269
7275
|
});
|
|
7270
7276
|
const messageEl = message ? jsxRuntime.jsx("p", { className: helpClass, children: message }) : null;
|
|
7271
|
-
const autocompleteElement = (jsxRuntime.jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxRuntime.jsxs("div", { className: controlClasses, children: [jsxRuntime.jsx("input", { ref: combinedRef, type: "text", className: inputClasses, value: inputValue, placeholder: placeholder, disabled: disabled, name: name, form: form, required: required, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, role: "combobox", "aria-expanded": isActive, "aria-haspopup": "listbox", "aria-autocomplete": "list", autoComplete: "off" }), clearable && inputValue && !disabled && (jsxRuntime.jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "16", height: "16", children: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsxRuntime.jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
|
|
7277
|
+
const autocompleteElement = (jsxRuntime.jsxs("div", { ref: containerRef, className: combinedClasses, ...rest, children: [jsxRuntime.jsxs("div", { className: controlClasses, children: [jsxRuntime.jsx("input", { ref: combinedRef, type: "text", className: inputClasses, id: controlId, value: inputValue, placeholder: placeholder, disabled: disabled, name: name, form: form, required: required, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, role: "combobox", "aria-expanded": isActive, "aria-haspopup": "listbox", "aria-autocomplete": "list", autoComplete: "off" }), clearable && inputValue && !disabled && (jsxRuntime.jsx("span", { className: iconRightClickableClass, onClick: handleClear, role: "button", "aria-label": "Clear", children: jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "16", height: "16", children: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && (filteredData.length > 0 || empty) && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsxs("div", { ref: dropdownRef, className: dropdownContentClass, style: { maxHeight: `${maxHeight}px`, overflowY: 'auto' }, role: "listbox", onScroll: handleDropdownScroll, children: [header && jsxRuntime.jsx("div", { className: dropdownHeaderClass, children: header }), filteredData.length > 0 ? (filteredData.map((item, index) => {
|
|
7272
7278
|
const isDisabled = typeof item !== 'string' && item.disabled;
|
|
7273
7279
|
const isHighlighted = index === highlightedIndex;
|
|
7274
7280
|
const itemClasses = prefixedClassNames(classPrefix, 'dropdown-item', {
|
|
@@ -7280,7 +7286,7 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7280
7286
|
: getDisplayValue(item) }, index));
|
|
7281
7287
|
})) : (jsxRuntime.jsx("div", { className: emptyItemClasses, children: empty })), footer && jsxRuntime.jsx("div", { className: dropdownFooterClass, children: footer })] }) }))] }));
|
|
7282
7288
|
if (!insideField) {
|
|
7283
|
-
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7289
|
+
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [autocompleteElement, messageEl] }));
|
|
7284
7290
|
}
|
|
7285
7291
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [autocompleteElement, messageEl] }));
|
|
7286
7292
|
});
|
|
@@ -7311,7 +7317,7 @@ Autocomplete.displayName = 'Autocomplete';
|
|
|
7311
7317
|
*/
|
|
7312
7318
|
const Taginput = React.forwardRef(({
|
|
7313
7319
|
// Field props
|
|
7314
|
-
label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue = [], data = [], placeholder, field = 'label', allowNew = true, allowDuplicates = false, openOnFocus = false, removeOnKeys = true, confirmKeys = ['Enter', ','], closable = true, attached = false, maxTags, maxlength, disabled = false, readonly = false, rounded = false, ellipsis = false, hasCounter = true, onPasteSeparators = [','], beforeAdding, createTag, keepFirst = false, keepOpen = true, loading = false, ariaCloseLabel, icon, iconLibrary: iconLibraryProp, iconVariant, iconFeatures, color, tagColor, size, onChange, onAdd, onRemove, onTyping, tagTemplate, name, form, className, ...props }, ref) => {
|
|
7320
|
+
label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName, value: controlledValue, defaultValue = [], data = [], placeholder, field = 'label', allowNew = true, allowDuplicates = false, openOnFocus = false, removeOnKeys = true, confirmKeys = ['Enter', ','], closable = true, attached = false, maxTags, maxlength, disabled = false, readonly = false, rounded = false, ellipsis = false, hasCounter = true, onPasteSeparators = [','], beforeAdding, createTag, keepFirst = false, keepOpen = true, loading = false, ariaCloseLabel, icon, iconLibrary: iconLibraryProp, iconVariant, iconFeatures, color, tagColor, size, onChange, onAdd, onRemove, onTyping, tagTemplate, name, form, id, className, ...props }, ref) => {
|
|
7315
7321
|
const insideField = useInsideField();
|
|
7316
7322
|
const { bulmaHelperClasses, rest } = useBulmaClasses(props);
|
|
7317
7323
|
const { classPrefix } = useConfig();
|
|
@@ -7327,6 +7333,15 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7327
7333
|
const [highlightedIndex, setHighlightedIndex] = React.useState(-1);
|
|
7328
7334
|
// Use controlled or internal tags
|
|
7329
7335
|
const tags = controlledValue !== undefined ? controlledValue : internalTags;
|
|
7336
|
+
const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
|
|
7337
|
+
// At the tag limit the text input is not rendered, so there is nothing to
|
|
7338
|
+
// wire the label to.
|
|
7339
|
+
const { controlId, fieldLabelProps } = useAutoLabelId({
|
|
7340
|
+
label,
|
|
7341
|
+
id,
|
|
7342
|
+
labelProps,
|
|
7343
|
+
rendersLabel: !insideField && !isMaxReached,
|
|
7344
|
+
});
|
|
7330
7345
|
// Get display value from tag
|
|
7331
7346
|
const getDisplayValue = (tag) => {
|
|
7332
7347
|
if (typeof tag === 'string')
|
|
@@ -7569,7 +7584,6 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7569
7584
|
[`is-${size}`]: !!size,
|
|
7570
7585
|
});
|
|
7571
7586
|
const combinedClasses = classNames(taginputClasses, bulmaHelperClasses, className);
|
|
7572
|
-
const isMaxReached = maxTags !== undefined && tags.length >= maxTags;
|
|
7573
7587
|
// Counter text
|
|
7574
7588
|
const showCounter = hasCounter && (maxTags !== undefined || maxlength !== undefined);
|
|
7575
7589
|
const counterText = maxTags !== undefined
|
|
@@ -7593,12 +7607,14 @@ label, labelSize, labelProps, horizontal, message, messageColor, fieldClassName,
|
|
|
7593
7607
|
e.stopPropagation();
|
|
7594
7608
|
removeTag(index);
|
|
7595
7609
|
}, "aria-label": ariaCloseLabel || `Remove ${displayVal}` }))] }, index));
|
|
7596
|
-
}), !isMaxReached && (jsxRuntime.jsx("input", { ref: combinedRef, type: "text", className: inputClasses, value: inputValue, placeholder: tags.length === 0 ? placeholder : undefined, disabled: disabled, readOnly: readonly, maxLength: maxlength, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, onPaste: handlePaste, "aria-label":
|
|
7610
|
+
}), !isMaxReached && (jsxRuntime.jsx("input", { ref: combinedRef, type: "text", className: inputClasses, id: controlId, value: inputValue, placeholder: tags.length === 0 ? placeholder : undefined, disabled: disabled, readOnly: readonly, maxLength: maxlength, onChange: handleInputChange, onFocus: handleFocus, onKeyDown: handleKeyDown, onPaste: handlePaste, "aria-label": controlId && fieldLabelProps?.htmlFor === controlId
|
|
7611
|
+
? undefined
|
|
7612
|
+
: 'Add tag' }))] }), loading && (jsxRuntime.jsx("span", { className: iconRightClass, children: jsxRuntime.jsx("span", { className: loaderClass }) }))] }), isActive && filteredData.length > 0 && (jsxRuntime.jsx("div", { className: dropdownMenuClasses, children: jsxRuntime.jsx("div", { ref: dropdownRef, className: dropdownContentClasses, role: "listbox", children: filteredData.map((item, index) => (jsxRuntime.jsx("a", { className: pcn('dropdown-item', {
|
|
7597
7613
|
'is-active': index === highlightedIndex,
|
|
7598
7614
|
}), onClick: () => addTag(item), onMouseEnter: () => setHighlightedIndex(index), role: "option", "aria-selected": index === highlightedIndex, children: item }, index))) }) })), showCounter && jsxRuntime.jsx("small", { className: counterClasses, children: counterText }), name &&
|
|
7599
7615
|
tags.map((tag, i) => (jsxRuntime.jsx("input", { type: "hidden", name: name, value: getDisplayValue(tag), form: form }, `tag-input-${i}`)))] }));
|
|
7600
7616
|
if (!insideField) {
|
|
7601
|
-
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps:
|
|
7617
|
+
return (jsxRuntime.jsxs(Field, { label: label, labelSize: labelSize, labelProps: fieldLabelProps, horizontal: horizontal, className: fieldClassName, children: [taginputElement, messageEl] }));
|
|
7602
7618
|
}
|
|
7603
7619
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [taginputElement, messageEl] }));
|
|
7604
7620
|
});
|