@jsswift/ui 1.0.48 → 1.0.49
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/min-ui.js +3 -3
- package/dist/ui.js +26 -0
- package/dist/ui.min.js +3 -3
- package/package.json +2 -2
- package/src/10-primitives-layout.js +26 -0
package/dist/ui.js
CHANGED
|
@@ -2541,6 +2541,30 @@ const unitCover = (v, name = 'size') => {
|
|
|
2541
2541
|
return el;
|
|
2542
2542
|
};
|
|
2543
2543
|
|
|
2544
|
+
// Public field attributes belong to the interactive control, not its wrapper.
|
|
2545
|
+
function uiConfigureFieldControl(field, control, props, native = false) {
|
|
2546
|
+
field.focus = (options) => control.focus(options);
|
|
2547
|
+
const set = (name, value) => {
|
|
2548
|
+
if (value == null || value === false) control.removeAttribute(name);
|
|
2549
|
+
else control.setAttribute(name, String(value));
|
|
2550
|
+
};
|
|
2551
|
+
JSswift.reactive.effect(() => {
|
|
2552
|
+
const label = uiUnwrap(props.ariaLabel) ?? (typeof props.label === "string" ? props.label : null);
|
|
2553
|
+
set("aria-label", label);
|
|
2554
|
+
set("aria-labelledby", uiUnwrap(props.ariaLabelledBy));
|
|
2555
|
+
set("aria-describedby", uiUnwrap(props.ariaDescribedBy));
|
|
2556
|
+
const invalid = props.ariaInvalid == null ? !!uiUnwrap(props.error) : !!uiUnwrap(props.ariaInvalid);
|
|
2557
|
+
control.setAttribute("aria-invalid", String(invalid));
|
|
2558
|
+
const required = !!uiUnwrap(props.required);
|
|
2559
|
+
control.setAttribute("aria-required", String(required));
|
|
2560
|
+
if (native) {
|
|
2561
|
+
control.required = required;
|
|
2562
|
+
for (const name of ["min", "max", "step", "pattern", "minLength", "maxLength"])
|
|
2563
|
+
set(name.toLowerCase(), uiUnwrap(props[name]));
|
|
2564
|
+
}
|
|
2565
|
+
}, "UI.Field:controlAttributes");
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2544
2568
|
UI.Input = (props = {}) => {
|
|
2545
2569
|
const slots = props.slots || {};
|
|
2546
2570
|
const fieldProps = {
|
|
@@ -2702,6 +2726,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
2702
2726
|
|
|
2703
2727
|
// expose reference
|
|
2704
2728
|
field._input = input;
|
|
2729
|
+
uiConfigureFieldControl(field, input, props, true);
|
|
2705
2730
|
uiRegisterShortcode(input, props, {
|
|
2706
2731
|
isEnabled: () => !input.disabled,
|
|
2707
2732
|
action: () => uiFocusShortcutTarget(input, { selectText: !!props.selectOnShortcode })
|
|
@@ -4099,6 +4124,7 @@ const unitCover = (v, name = 'size') => {
|
|
|
4099
4124
|
// refresh has-value when value changes
|
|
4100
4125
|
JSswift.reactive.effect(() => { field._refresh?.(); }, "UI.Select:fieldRefresh");
|
|
4101
4126
|
|
|
4127
|
+
uiConfigureFieldControl(field, root, props);
|
|
4102
4128
|
field._select = root;
|
|
4103
4129
|
field._dispose = root._dispose;
|
|
4104
4130
|
JSswift._registerCleanup?.(field, field._dispose);
|