uni-select-field 1.0.0 → 1.0.1
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/index.html +1 -9
- package/mjs/wc-uni-select-field.js +48 -16
- package/mjs/wc-uni-select-field.min.js +33 -18
- package/package.json +1 -1
package/index.html
CHANGED
|
@@ -38,17 +38,13 @@ body{position:relative;inline-size:100vw;block-size:100vh;margin:0;}
|
|
|
38
38
|
|
|
39
39
|
uni-select-field {
|
|
40
40
|
&::part(icon-subject) {
|
|
41
|
-
/*
|
|
41
|
+
/* style icon here */
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
&[data-hide-icon]::part(icon-subject) {
|
|
45
45
|
display: none;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
[inert] uni-select-field {
|
|
50
|
-
--interactivity: inert;
|
|
51
|
-
}
|
|
52
48
|
</style>
|
|
53
49
|
</head>
|
|
54
50
|
|
|
@@ -355,15 +351,11 @@ const handler = (evt) => {
|
|
|
355
351
|
|
|
356
352
|
case 'required': {
|
|
357
353
|
select.required = fd['required'] === 'y';
|
|
358
|
-
|
|
359
|
-
uniSelectField.refresh();
|
|
360
354
|
break;
|
|
361
355
|
}
|
|
362
356
|
|
|
363
357
|
case 'disabled': {
|
|
364
358
|
select.disabled = fd['disabled'] === 'y';
|
|
365
|
-
|
|
366
|
-
uniSelectField.refresh();
|
|
367
359
|
break;
|
|
368
360
|
}
|
|
369
361
|
|
|
@@ -78,15 +78,13 @@ ${_uniColorPalette}
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
:host {
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
color: var(--ct_icon_moderate_strong);
|
|
85
|
-
margin-inline-start: 4px;
|
|
81
|
+
@container style(--show-required-sign: 'true') {
|
|
82
|
+
.main {
|
|
83
|
+
--required-sign-display: inline;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
|
|
89
|
-
|
|
87
|
+
@container style(--is-select-inert: 'true') {
|
|
90
88
|
.main {
|
|
91
89
|
--text-color: var(--text-color-disabled);
|
|
92
90
|
--caret-color: var(--caret-color-disabled);
|
|
@@ -94,16 +92,7 @@ ${_uniColorPalette}
|
|
|
94
92
|
|
|
95
93
|
slot[name="select"] {
|
|
96
94
|
interactivity: inert;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@container style(--interactivity: inert) {
|
|
101
|
-
.main {
|
|
102
|
-
--text-color: var(--text-color-disabled);
|
|
103
|
-
}
|
|
104
95
|
|
|
105
|
-
slot[name="select"] {
|
|
106
|
-
interactivity: inert;
|
|
107
96
|
}
|
|
108
97
|
}
|
|
109
98
|
}
|
|
@@ -139,10 +128,12 @@ ${_uniColorPalette}
|
|
|
139
128
|
--subject-color: var(--uni-select-field-subject-color, var(--ct_text_main_subtle));
|
|
140
129
|
--caret-size: 20px;
|
|
141
130
|
|
|
131
|
+
--required-sign-display: none;
|
|
132
|
+
|
|
142
133
|
/* size */
|
|
143
134
|
--basis-padding: 12px;
|
|
144
135
|
--large-border-radius: 24px;
|
|
145
|
-
--large-padding-inline:
|
|
136
|
+
--large-padding-inline: 16px calc(var(--basis-padding) * 2 + var(--basis-padding));
|
|
146
137
|
--large-block-size: 56px;
|
|
147
138
|
--medium-border-radius: 44px;
|
|
148
139
|
--medium-padding-inline: var(--basis-padding) calc(var(--basis-padding) * 2 + var(--basis-padding));
|
|
@@ -171,6 +162,13 @@ ${_uniColorPalette}
|
|
|
171
162
|
font-size: 12px;
|
|
172
163
|
color: var(--subject-color);
|
|
173
164
|
line-height: 1.667;
|
|
165
|
+
|
|
166
|
+
&::after {
|
|
167
|
+
content: '*';
|
|
168
|
+
color: var(--ct_icon_moderate_strong);
|
|
169
|
+
margin-inline-start: 4px;
|
|
170
|
+
display: var(--required-sign-display);
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
em {
|
|
@@ -276,6 +274,40 @@ ${_uniColorPalette}
|
|
|
276
274
|
</div>
|
|
277
275
|
`;
|
|
278
276
|
|
|
277
|
+
/* style injection */
|
|
278
|
+
const styleInjection = `
|
|
279
|
+
uni-select-field {
|
|
280
|
+
--show-required-sign: 'false';
|
|
281
|
+
--is-select-inert: 'false';
|
|
282
|
+
|
|
283
|
+
&:has(select[required]) {
|
|
284
|
+
--show-required-sign: 'true';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
&:has(select:is([disabled],[inert])) {
|
|
288
|
+
--is-select-inert: 'true';
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
[inert] uni-select-field {
|
|
293
|
+
--is-select-inert: 'true';
|
|
294
|
+
}
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
const INJECT_KEY = Symbol.for('uni.select.field.ui.injected');
|
|
298
|
+
const uiInit = () => {
|
|
299
|
+
if (window[INJECT_KEY]) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const sheet = new CSSStyleSheet();
|
|
304
|
+
sheet.replaceSync(styleInjection);
|
|
305
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
|
306
|
+
|
|
307
|
+
window[INJECT_KEY] = true;
|
|
308
|
+
};
|
|
309
|
+
uiInit();
|
|
310
|
+
|
|
279
311
|
export class UniSelectField extends HTMLElement {
|
|
280
312
|
#data;
|
|
281
313
|
#nodes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_wcl}from"./common-lib.js";import{_wccss}from"./common-css.js";import{colorPalette as _uniColorPalette}from"https://unpkg.com/uni-input-field/mjs/uni-css.js";const defaults={subject:"",message:"",stat:"",appearance:"filled",size:"medium"},booleanAttrs=[],objectAttrs=[],custumEvents={},template=document.createElement("template")
|
|
1
|
+
import{_wcl}from"./common-lib.js";import{_wccss}from"./common-css.js";import{colorPalette as _uniColorPalette}from"https://unpkg.com/uni-input-field/mjs/uni-css.js";const defaults={subject:"",message:"",stat:"",appearance:"filled",size:"medium"},booleanAttrs=[],objectAttrs=[],custumEvents={},template=document.createElement("template"),styleInjection=(template.innerHTML=`
|
|
2
2
|
<style>
|
|
3
3
|
${_wccss}
|
|
4
4
|
${_uniColorPalette}
|
|
@@ -59,15 +59,13 @@ ${_uniColorPalette}
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
:host {
|
|
62
|
-
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
color: var(--ct_icon_moderate_strong);
|
|
66
|
-
margin-inline-start: 4px;
|
|
62
|
+
@container style(--show-required-sign: 'true') {
|
|
63
|
+
.main {
|
|
64
|
+
--required-sign-display: inline;
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
@container style(--is-select-inert: 'true') {
|
|
71
69
|
.main {
|
|
72
70
|
--text-color: var(--text-color-disabled);
|
|
73
71
|
--caret-color: var(--caret-color-disabled);
|
|
@@ -75,16 +73,7 @@ ${_uniColorPalette}
|
|
|
75
73
|
|
|
76
74
|
slot[name="select"] {
|
|
77
75
|
interactivity: inert;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@container style(--interactivity: inert) {
|
|
82
|
-
.main {
|
|
83
|
-
--text-color: var(--text-color-disabled);
|
|
84
|
-
}
|
|
85
76
|
|
|
86
|
-
slot[name="select"] {
|
|
87
|
-
interactivity: inert;
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
79
|
}
|
|
@@ -120,10 +109,12 @@ ${_uniColorPalette}
|
|
|
120
109
|
--subject-color: var(--uni-select-field-subject-color, var(--ct_text_main_subtle));
|
|
121
110
|
--caret-size: 20px;
|
|
122
111
|
|
|
112
|
+
--required-sign-display: none;
|
|
113
|
+
|
|
123
114
|
/* size */
|
|
124
115
|
--basis-padding: 12px;
|
|
125
116
|
--large-border-radius: 24px;
|
|
126
|
-
--large-padding-inline:
|
|
117
|
+
--large-padding-inline: 16px calc(var(--basis-padding) * 2 + var(--basis-padding));
|
|
127
118
|
--large-block-size: 56px;
|
|
128
119
|
--medium-border-radius: 44px;
|
|
129
120
|
--medium-padding-inline: var(--basis-padding) calc(var(--basis-padding) * 2 + var(--basis-padding));
|
|
@@ -152,6 +143,13 @@ ${_uniColorPalette}
|
|
|
152
143
|
font-size: 12px;
|
|
153
144
|
color: var(--subject-color);
|
|
154
145
|
line-height: 1.667;
|
|
146
|
+
|
|
147
|
+
&::after {
|
|
148
|
+
content: '*';
|
|
149
|
+
color: var(--ct_icon_moderate_strong);
|
|
150
|
+
margin-inline-start: 4px;
|
|
151
|
+
display: var(--required-sign-display);
|
|
152
|
+
}
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
em {
|
|
@@ -255,4 +253,21 @@ ${_uniColorPalette}
|
|
|
255
253
|
<p class="main__info__message"></p>
|
|
256
254
|
</div>
|
|
257
255
|
</div>
|
|
258
|
-
|
|
256
|
+
`,`
|
|
257
|
+
uni-select-field {
|
|
258
|
+
--show-required-sign: 'false';
|
|
259
|
+
--is-select-inert: 'false';
|
|
260
|
+
|
|
261
|
+
&:has(select[required]) {
|
|
262
|
+
--show-required-sign: 'true';
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&:has(select:is([disabled],[inert])) {
|
|
266
|
+
--is-select-inert: 'true';
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
[inert] uni-select-field {
|
|
271
|
+
--is-select-inert: 'true';
|
|
272
|
+
}
|
|
273
|
+
`),INJECT_KEY=Symbol.for("uni.select.field.ui.injected"),uiInit=()=>{var e;window[INJECT_KEY]||((e=new CSSStyleSheet).replaceSync(styleInjection),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e],window[INJECT_KEY]=!0)};uiInit();class UniSelectField extends HTMLElement{#data;#nodes;#config;constructor(e){super(),this.attachShadow({mode:"open",delegatesFocus:!0}),this.shadowRoot.appendChild(template.content.cloneNode(!0)),this.#data={controller:""},this.#nodes={styleSheet:this.shadowRoot.querySelector("style"),select:this.querySelector("[slot=select]"),subject:this.shadowRoot.querySelector(".main__subject__span"),message:this.shadowRoot.querySelector(".main__info__message"),counter:this.shadowRoot.querySelector(".main__info__counter")},this.#config={...defaults,...e}}async connectedCallback(){var{config:e,error:t}=await _wcl.getWCConfig(this);t?(console.warn(_wcl.classToTagName(this.constructor.name)+": "+t),this.remove()):(this.#config={...this.#config,...e},Object.keys(defaults).forEach(e=>this.#upgradeProperty(e)))}disconnectedCallback(){this.#data?.controller&&this.#data.controller.abort()}#format(e,t,i){if(null!==i)switch(e){case"subject":case"message":this.#config[e]=i;break;case"stat":this.#config[e]=["","valid","invalid"].includes(i)?i:defaults.state;break;case"appearance":this.#config[e]=["filled","outlined"].includes(i)?i:defaults.appearance;break;case"size":this.#config[e]=["large","medium","small"].includes(i)?i:defaults.size}else booleanAttrs.includes(e)?this.#config[e]=!1:this.#config[e]=defaults[e]}attributeChangedCallback(e,t,i){if(UniSelectField.observedAttributes.includes(e))switch(this.#format(e,t,i),e){case"subject":this.#nodes.subject.textContent=this.subject;break;case"message":this.#nodes.message.textContent=this.message}}static get observedAttributes(){return Object.keys(defaults)}static get supportedEvents(){return Object.keys(custumEvents).map(e=>custumEvents[e])}#upgradeProperty(e){let t;UniSelectField.observedAttributes.includes(e)&&(Object.prototype.hasOwnProperty.call(this,e)?(t=this[e],delete this[e]):t=booleanAttrs.includes(e)?!(!this.hasAttribute(e)&&!this.#config[e]):objectAttrs.includes(e)?this.hasAttribute(e)?this.getAttribute(e):JSON.stringify(this.#config[e]):this.hasAttribute(e)?this.getAttribute(e):this.#config[e],this[e]=t)}set subject(e){e?this.setAttribute("subject",e):this.removeAttribute("subject")}get subject(){return this.#config.subject}set message(e){e?this.setAttribute("message",e):this.removeAttribute("message")}get message(){return this.#config.message}set stat(e){e?this.setAttribute("stat",e):this.removeAttribute("stat")}get stat(){return this.#config.stat}set appearance(e){e?this.setAttribute("appearance",e):this.removeAttribute("appearance")}get appearance(){return this.#config.appearance}set size(e){e?this.setAttribute("size",e):this.removeAttribute("size")}get size(){return this.#config.size}refresh(){this.hidden=!0,this.offsetHeight,this.hidden=!1}}const S=_wcl.supports(),T=_wcl.classToTagName("UniSelectField");S.customElements&&S.shadowDOM&&S.template&&!window.customElements.get(T)&&window.customElements.define(_wcl.classToTagName("UniSelectField"),UniSelectField);export{UniSelectField};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uni-select-field",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "<uni-select-field /> is an encapsulated Web Component built upon the foundation of the uniopen design language. Implementation is straightforward: simply slot a standard select element inside <uni-select-field />. The component instantly applies a user interface that aligns seamlessly with the uniopen design language guidelines. Furthermore, its visual styles can be dynamically adapted via native HTML attributes or JavaScript properties.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web"
|