ui-ingredients 0.4.3 → 0.4.4
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.
@@ -37,19 +37,6 @@ export function createField(props) {
|
|
37
37
|
}
|
38
38
|
return l.join(' ');
|
39
39
|
});
|
40
|
-
$effect(() => {
|
41
|
-
const rootNode = environment?.getRootNode() ?? document;
|
42
|
-
const doc = getDocument(rootNode);
|
43
|
-
const win = getWindow(rootNode);
|
44
|
-
function handler() {
|
45
|
-
hasErrorText = invalid && doc.getElementById(ids.errorText) !== null;
|
46
|
-
hasHelperText = doc.getElementById(ids.helperText) !== null;
|
47
|
-
}
|
48
|
-
handler();
|
49
|
-
const observer = new win.MutationObserver(handler);
|
50
|
-
observer.observe(rootNode, { childList: true, subtree: true });
|
51
|
-
return () => observer.disconnect();
|
52
|
-
});
|
53
40
|
function getRootProps() {
|
54
41
|
return {
|
55
42
|
...parts.root.attrs,
|
@@ -72,6 +59,16 @@ export function createField(props) {
|
|
72
59
|
'data-readonly': dataAttr(readOnly),
|
73
60
|
};
|
74
61
|
}
|
62
|
+
function getRequiredIndicatorProps() {
|
63
|
+
return {
|
64
|
+
...parts.requiredIndicator.attrs,
|
65
|
+
hidden: !required,
|
66
|
+
'aria-hidden': true,
|
67
|
+
'data-invalid': dataAttr(invalid),
|
68
|
+
'data-disabled': dataAttr(disabled),
|
69
|
+
'data-readonly': dataAttr(readOnly),
|
70
|
+
};
|
71
|
+
}
|
75
72
|
function getErrorTextProps() {
|
76
73
|
return {
|
77
74
|
...parts.errorText.attrs,
|
@@ -94,60 +91,55 @@ export function createField(props) {
|
|
94
91
|
'data-readonly': dataAttr(readOnly),
|
95
92
|
};
|
96
93
|
}
|
97
|
-
function
|
94
|
+
function getControlProps() {
|
98
95
|
return {
|
99
|
-
...parts.input.attrs,
|
100
96
|
id: ids.control,
|
101
97
|
disabled,
|
102
98
|
required,
|
103
|
-
readonly: readOnly,
|
104
|
-
'aria-invalid': ariaAttr(invalid),
|
105
99
|
'aria-describedby': ariaDescribedby,
|
100
|
+
'aria-invalid': ariaAttr(invalid),
|
101
|
+
'aria-disabled': ariaAttr(disabled),
|
102
|
+
'aria-required': ariaAttr(required),
|
103
|
+
'aria-readonly': ariaAttr(readOnly),
|
106
104
|
'data-invalid': dataAttr(invalid),
|
107
105
|
'data-disabled': dataAttr(disabled),
|
108
106
|
'data-required': dataAttr(required),
|
109
107
|
'data-readonly': dataAttr(readOnly),
|
110
108
|
};
|
111
109
|
}
|
112
|
-
function
|
110
|
+
function getInputProps() {
|
113
111
|
return {
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
required,
|
118
|
-
'aria-invalid': ariaAttr(invalid),
|
119
|
-
'aria-readonly': ariaAttr(readOnly),
|
120
|
-
'aria-describedby': ariaDescribedby,
|
121
|
-
'data-invalid': dataAttr(invalid),
|
122
|
-
'data-disabled': dataAttr(disabled),
|
123
|
-
'data-required': dataAttr(required),
|
124
|
-
'data-readonly': dataAttr(readOnly),
|
112
|
+
readonly: readOnly,
|
113
|
+
...getControlProps(),
|
114
|
+
...parts.input.attrs,
|
125
115
|
};
|
126
116
|
}
|
127
117
|
function getTextareaProps() {
|
128
118
|
return {
|
129
|
-
...parts.textarea.attrs,
|
130
|
-
id: ids.control,
|
131
|
-
disabled,
|
132
|
-
required,
|
133
119
|
readonly: readOnly,
|
134
|
-
|
135
|
-
|
136
|
-
'data-disabled': dataAttr(disabled),
|
137
|
-
'data-required': dataAttr(required),
|
138
|
-
'data-readonly': dataAttr(readOnly),
|
120
|
+
...getControlProps(),
|
121
|
+
...parts.textarea.attrs,
|
139
122
|
};
|
140
123
|
}
|
141
|
-
function
|
124
|
+
function getSelectProps() {
|
142
125
|
return {
|
143
|
-
...
|
144
|
-
|
145
|
-
'aria-hidden': true,
|
146
|
-
'data-invalid': dataAttr(invalid),
|
147
|
-
'data-disabled': dataAttr(disabled),
|
148
|
-
'data-readonly': dataAttr(readOnly),
|
126
|
+
...getControlProps(),
|
127
|
+
...parts.select.attrs,
|
149
128
|
};
|
150
129
|
}
|
130
|
+
$effect(() => {
|
131
|
+
const rootNode = environment?.getRootNode() ?? document;
|
132
|
+
const doc = getDocument(rootNode);
|
133
|
+
const win = getWindow(rootNode);
|
134
|
+
function handler() {
|
135
|
+
hasErrorText = invalid && doc.getElementById(ids.errorText) !== null;
|
136
|
+
hasHelperText = doc.getElementById(ids.helperText) !== null;
|
137
|
+
}
|
138
|
+
handler();
|
139
|
+
const observer = new win.MutationObserver(handler);
|
140
|
+
observer.observe(rootNode, { childList: true, subtree: true });
|
141
|
+
return () => observer.disconnect();
|
142
|
+
});
|
151
143
|
return reflect(() => ({
|
152
144
|
ids,
|
153
145
|
disabled,
|