vira 26.10.1 → 26.11.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/README.md
CHANGED
|
@@ -6,7 +6,7 @@ import { ViraIcon } from './vira-icon.element.js';
|
|
|
6
6
|
*
|
|
7
7
|
* @category Internals
|
|
8
8
|
*/
|
|
9
|
-
export type ViraCheckboxInnerElements = 'label' | 'custom-checkbox' | typeof ViraIcon.tagName;
|
|
9
|
+
export type ViraCheckboxInnerElements = 'label' | 'custom-checkbox' | 'text' | typeof ViraIcon.tagName;
|
|
10
10
|
/**
|
|
11
11
|
* Inputs for {@link ViraCheckbox}.
|
|
12
12
|
*
|
|
@@ -16,6 +16,7 @@ export type ViraCheckboxInputs = PartialWithUndefined<{
|
|
|
16
16
|
stylePassthrough: Record<ViraCheckboxInnerElements, CSSResult>;
|
|
17
17
|
attributePassthrough: Record<ViraCheckboxInnerElements, AttributeValues>;
|
|
18
18
|
disabled: boolean;
|
|
19
|
+
label: string;
|
|
19
20
|
}> & {
|
|
20
21
|
value: boolean;
|
|
21
22
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attributes, classMap, css, defineElementEvent, html, ifDefined, listen, listenToActivate, } from 'element-vir';
|
|
1
|
+
import { attributes, classMap, css, defineElementEvent, html, ifDefined, listen, listenToActivate, nothing, } from 'element-vir';
|
|
2
2
|
import { Check24Icon, viraIconCssVars } from '../icons/index.js';
|
|
3
3
|
import { viraBorders } from '../styles/border.js';
|
|
4
4
|
import { viraDisabledStyles } from '../styles/disabled.js';
|
|
@@ -17,22 +17,32 @@ export const ViraCheckbox = defineViraElement()({
|
|
|
17
17
|
tagName: 'vira-checkbox',
|
|
18
18
|
styles: css `
|
|
19
19
|
:host {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.custom-checkbox {
|
|
20
24
|
height: 24px;
|
|
21
25
|
aspect-ratio: 1;
|
|
22
|
-
|
|
26
|
+
box-sizing: border-box;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
${ViraIcon}, .custom-checkbox {
|
|
27
|
-
height: 100%;
|
|
29
|
+
${ViraIcon} {
|
|
28
30
|
width: 100%;
|
|
31
|
+
height: 100%;
|
|
29
32
|
box-sizing: border-box;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
label {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
gap: 8px;
|
|
38
|
+
|
|
33
39
|
&.disabled {
|
|
34
40
|
cursor: not-allowed;
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
& .text::first-line {
|
|
44
|
+
line-height: 24px;
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
${ViraIcon} {
|
|
@@ -42,6 +52,7 @@ export const ViraCheckbox = defineViraElement()({
|
|
|
42
52
|
|
|
43
53
|
/* The visible custom box */
|
|
44
54
|
.custom-checkbox {
|
|
55
|
+
flex-shrink: 0;
|
|
45
56
|
border: 1px solid ${viraFormCssVars['vira-form-border-color'].value};
|
|
46
57
|
color: ${viraFormCssVars['vira-form-foreground-color'].value};
|
|
47
58
|
border-radius: ${viraBorders['vira-form-input-radius'].value};
|
|
@@ -81,6 +92,17 @@ export const ViraCheckbox = defineViraElement()({
|
|
|
81
92
|
dispatch(new events.valueChange(!inputs.value));
|
|
82
93
|
}
|
|
83
94
|
}
|
|
95
|
+
const textLabel = inputs.label
|
|
96
|
+
? html `
|
|
97
|
+
<span
|
|
98
|
+
class="text"
|
|
99
|
+
${attributes(inputs.attributePassthrough?.['text'])}
|
|
100
|
+
style=${ifDefined(inputs.stylePassthrough?.['text'])}
|
|
101
|
+
>
|
|
102
|
+
${inputs.label}
|
|
103
|
+
</span>
|
|
104
|
+
`
|
|
105
|
+
: nothing;
|
|
84
106
|
return html `
|
|
85
107
|
<label
|
|
86
108
|
class=${classMap({
|
|
@@ -111,6 +133,7 @@ export const ViraCheckbox = defineViraElement()({
|
|
|
111
133
|
style=${ifDefined(inputs.stylePassthrough?.[ViraIcon.tagName])}
|
|
112
134
|
></${ViraIcon}>
|
|
113
135
|
</span>
|
|
136
|
+
${textLabel}
|
|
114
137
|
</label>
|
|
115
138
|
`;
|
|
116
139
|
},
|