@six-group/ui-library 0.0.0-insider.7c3e3d8 → 0.0.0-insider.a358260
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/cjs/six-checkbox.cjs.entry.js +57 -46
- package/dist/cjs/six-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/six-input.cjs.entry.js +8 -10
- package/dist/cjs/six-input.cjs.entry.js.map +1 -1
- package/dist/cjs/six-radio.cjs.entry.js +56 -51
- package/dist/cjs/six-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/six-range.cjs.entry.js +114 -75
- package/dist/cjs/six-range.cjs.entry.js.map +1 -1
- package/dist/cjs/six-select.cjs.entry.js +298 -239
- package/dist/cjs/six-select.cjs.entry.js.map +1 -1
- package/dist/cjs/six-textarea.cjs.entry.js +97 -74
- package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
- package/dist/collection/components/six-checkbox/six-checkbox.js +62 -49
- package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
- package/dist/collection/components/six-input/six-input.js +8 -10
- package/dist/collection/components/six-input/six-input.js.map +1 -1
- package/dist/collection/components/six-radio/six-radio.js +60 -53
- package/dist/collection/components/six-radio/six-radio.js.map +1 -1
- package/dist/collection/components/six-range/six-range.js +121 -76
- package/dist/collection/components/six-range/six-range.js.map +1 -1
- package/dist/collection/components/six-select/six-select.js +248 -240
- package/dist/collection/components/six-select/six-select.js.map +1 -1
- package/dist/collection/components/six-select/util.js +52 -0
- package/dist/collection/components/six-select/util.js.map +1 -0
- package/dist/collection/components/six-textarea/six-textarea.js +115 -105
- package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
- package/dist/components/six-checkbox.js +57 -46
- package/dist/components/six-checkbox.js.map +1 -1
- package/dist/components/six-input2.js +8 -10
- package/dist/components/six-input2.js.map +1 -1
- package/dist/components/six-radio.js +56 -51
- package/dist/components/six-radio.js.map +1 -1
- package/dist/components/six-range.js +114 -75
- package/dist/components/six-range.js.map +1 -1
- package/dist/components/six-select.js +299 -240
- package/dist/components/six-select.js.map +1 -1
- package/dist/components/six-textarea.js +97 -74
- package/dist/components/six-textarea.js.map +1 -1
- package/dist/components.json +30 -22
- package/dist/esm/six-checkbox.entry.js +57 -46
- package/dist/esm/six-checkbox.entry.js.map +1 -1
- package/dist/esm/six-input.entry.js +8 -10
- package/dist/esm/six-input.entry.js.map +1 -1
- package/dist/esm/six-radio.entry.js +56 -51
- package/dist/esm/six-radio.entry.js.map +1 -1
- package/dist/esm/six-range.entry.js +114 -75
- package/dist/esm/six-range.entry.js.map +1 -1
- package/dist/esm/six-select.entry.js +299 -240
- package/dist/esm/six-select.entry.js.map +1 -1
- package/dist/esm/six-textarea.entry.js +97 -74
- package/dist/esm/six-textarea.entry.js.map +1 -1
- package/dist/types/components/six-checkbox/six-checkbox.d.ts +21 -17
- package/dist/types/components/six-input/six-input.d.ts +1 -1
- package/dist/types/components/six-radio/six-radio.d.ts +10 -11
- package/dist/types/components/six-range/six-range.d.ts +24 -20
- package/dist/types/components/six-select/six-select.d.ts +35 -40
- package/dist/types/components/six-select/util.d.ts +7 -0
- package/dist/types/components/six-textarea/six-textarea.d.ts +22 -31
- package/dist/types/components.d.ts +9 -13
- package/dist/ui-library/p-163f2bb0.entry.js +2 -0
- package/dist/ui-library/p-163f2bb0.entry.js.map +1 -0
- package/dist/ui-library/{p-e9e930d2.entry.js → p-394a2a12.entry.js} +2 -2
- package/dist/ui-library/{p-e9e930d2.entry.js.map → p-394a2a12.entry.js.map} +1 -1
- package/dist/ui-library/{p-7e0cc4ae.entry.js → p-3c635d0a.entry.js} +2 -2
- package/dist/ui-library/p-3c635d0a.entry.js.map +1 -0
- package/dist/ui-library/p-5a25d6fb.entry.js +2 -0
- package/dist/ui-library/p-5a25d6fb.entry.js.map +1 -0
- package/dist/ui-library/{p-90dc6af4.entry.js → p-97cc839c.entry.js} +2 -2
- package/dist/ui-library/p-97cc839c.entry.js.map +1 -0
- package/dist/ui-library/p-f604e067.entry.js +2 -0
- package/dist/ui-library/p-f604e067.entry.js.map +1 -0
- package/dist/ui-library/ui-library.esm.js +1 -1
- package/package.json +1 -1
- package/dist/ui-library/p-0d79b0c6.entry.js +0 -2
- package/dist/ui-library/p-0d79b0c6.entry.js.map +0 -1
- package/dist/ui-library/p-7e0cc4ae.entry.js.map +0 -1
- package/dist/ui-library/p-835c3ff7.entry.js +0 -2
- package/dist/ui-library/p-835c3ff7.entry.js.map +0 -1
- package/dist/ui-library/p-90dc6af4.entry.js.map +0 -1
- package/dist/ui-library/p-edc96efc.entry.js +0 -2
- package/dist/ui-library/p-edc96efc.entry.js.map +0 -1
|
@@ -15,9 +15,43 @@ const SixRadio$1 = /*@__PURE__*/ proxyCustomElement(class SixRadio extends HTMLE
|
|
|
15
15
|
this.labelId = `radio-label-${id}`;
|
|
16
16
|
/** default state whether the radio button should be checked or not when resetting */
|
|
17
17
|
this.defaultState = false;
|
|
18
|
+
this.handleClick = () => {
|
|
19
|
+
if (this.nativeInput != null) {
|
|
20
|
+
this.checked = this.nativeInput.checked;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.handleBlur = () => {
|
|
24
|
+
this.hasFocus = false;
|
|
25
|
+
this.sixBlur.emit();
|
|
26
|
+
};
|
|
27
|
+
this.handleFocus = () => {
|
|
28
|
+
this.hasFocus = true;
|
|
29
|
+
this.sixFocus.emit();
|
|
30
|
+
};
|
|
31
|
+
this.handleKeyDown = (event) => {
|
|
32
|
+
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
33
|
+
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
34
|
+
const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;
|
|
35
|
+
let index = radios.indexOf(this.host) + incr;
|
|
36
|
+
if (index < 0)
|
|
37
|
+
index = radios.length - 1;
|
|
38
|
+
if (index > radios.length - 1)
|
|
39
|
+
index = 0;
|
|
40
|
+
this.getAllRadios().map((radio) => (radio.checked = false));
|
|
41
|
+
radios[index].setFocus();
|
|
42
|
+
radios[index].checked = true;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
this.handleMouseDown = (event) => {
|
|
47
|
+
var _a;
|
|
48
|
+
// Prevent clicks on the label from briefly blurring the input
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus();
|
|
51
|
+
};
|
|
18
52
|
this.hasFocus = false;
|
|
19
|
-
this.name =
|
|
20
|
-
this.value =
|
|
53
|
+
this.name = '';
|
|
54
|
+
this.value = 'on';
|
|
21
55
|
this.disabled = false;
|
|
22
56
|
this.checked = false;
|
|
23
57
|
this.invalid = false;
|
|
@@ -26,95 +60,66 @@ const SixRadio$1 = /*@__PURE__*/ proxyCustomElement(class SixRadio extends HTMLE
|
|
|
26
60
|
if (this.checked) {
|
|
27
61
|
this.getSiblingRadios().map((radio) => (radio.checked = false));
|
|
28
62
|
}
|
|
29
|
-
if (this.
|
|
30
|
-
this.
|
|
63
|
+
if (this.nativeInput != null) {
|
|
64
|
+
this.nativeInput.checked = this.checked;
|
|
31
65
|
this.sixChange.emit();
|
|
32
66
|
}
|
|
33
67
|
}
|
|
34
|
-
connectedCallback() {
|
|
35
|
-
this.handleClick = this.handleClick.bind(this);
|
|
36
|
-
this.handleBlur = this.handleBlur.bind(this);
|
|
37
|
-
this.handleFocus = this.handleFocus.bind(this);
|
|
38
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
39
|
-
this.handleMouseDown = this.handleMouseDown.bind(this);
|
|
40
|
-
}
|
|
41
68
|
componentWillLoad() {
|
|
42
69
|
this.defaultState = this.checked;
|
|
43
70
|
}
|
|
44
71
|
/** Sets focus on the radio. */
|
|
45
72
|
async setFocus(options) {
|
|
46
|
-
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
|
|
47
75
|
}
|
|
48
76
|
/** Removes focus from the radio. */
|
|
49
77
|
async removeFocus() {
|
|
50
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
|
|
51
80
|
}
|
|
52
81
|
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
53
82
|
async reportValidity() {
|
|
54
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
return (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.reportValidity();
|
|
55
85
|
}
|
|
56
86
|
/** Checks for validity. */
|
|
57
87
|
async checkValidity() {
|
|
58
|
-
|
|
88
|
+
if (this.nativeInput == null) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return this.nativeInput.validity.valid;
|
|
59
92
|
}
|
|
60
93
|
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
|
61
94
|
async setCustomValidity(message) {
|
|
62
|
-
this.
|
|
63
|
-
|
|
95
|
+
if (this.nativeInput != null) {
|
|
96
|
+
this.nativeInput.setCustomValidity(message);
|
|
97
|
+
this.invalid = !this.nativeInput.checkValidity();
|
|
98
|
+
}
|
|
64
99
|
}
|
|
65
100
|
/** Resets the formcontrol */
|
|
66
101
|
async reset() {
|
|
102
|
+
var _a;
|
|
67
103
|
this.checked = this.defaultState;
|
|
68
|
-
this.
|
|
104
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
|
|
69
105
|
this.invalid = false;
|
|
70
106
|
}
|
|
71
107
|
getAllRadios() {
|
|
72
108
|
const form = this.host.closest('six-form, form') || document.body;
|
|
73
|
-
if (
|
|
109
|
+
if (this.name === '')
|
|
74
110
|
return [];
|
|
75
111
|
return [...form.querySelectorAll('six-radio')].filter((radio) => radio.name === this.name);
|
|
76
112
|
}
|
|
77
113
|
getSiblingRadios() {
|
|
78
114
|
return this.getAllRadios().filter((radio) => radio !== this.host);
|
|
79
115
|
}
|
|
80
|
-
handleClick() {
|
|
81
|
-
this.checked = this.input.checked;
|
|
82
|
-
}
|
|
83
|
-
handleBlur() {
|
|
84
|
-
this.hasFocus = false;
|
|
85
|
-
this.sixBlur.emit();
|
|
86
|
-
}
|
|
87
|
-
handleFocus() {
|
|
88
|
-
this.hasFocus = true;
|
|
89
|
-
this.sixFocus.emit();
|
|
90
|
-
}
|
|
91
|
-
handleKeyDown(event) {
|
|
92
|
-
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
|
93
|
-
const radios = this.getAllRadios().filter((radio) => !radio.disabled);
|
|
94
|
-
const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;
|
|
95
|
-
let index = radios.indexOf(this.host) + incr;
|
|
96
|
-
if (index < 0)
|
|
97
|
-
index = radios.length - 1;
|
|
98
|
-
if (index > radios.length - 1)
|
|
99
|
-
index = 0;
|
|
100
|
-
this.getAllRadios().map((radio) => (radio.checked = false));
|
|
101
|
-
radios[index].setFocus();
|
|
102
|
-
radios[index].checked = true;
|
|
103
|
-
event.preventDefault();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
handleMouseDown(event) {
|
|
107
|
-
// Prevent clicks on the label from briefly blurring the input
|
|
108
|
-
event.preventDefault();
|
|
109
|
-
this.input.focus();
|
|
110
|
-
}
|
|
111
116
|
render() {
|
|
112
117
|
return (h("label", { part: "base", class: {
|
|
113
118
|
radio: true,
|
|
114
119
|
'radio--checked': this.checked,
|
|
115
120
|
'radio--disabled': this.disabled,
|
|
116
121
|
'radio--focused': this.hasFocus,
|
|
117
|
-
}, htmlFor: this.inputId, onKeyDown: this.handleKeyDown, onMouseDown: this.handleMouseDown }, h("span", { part: "control", class: "radio__control" }, h("span", { part: "checked-icon", class: "radio__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd" }, h("g", { fill: "currentColor" }, h("circle", { cx: "8", cy: "8", r: "5" }))))), h("input", { ref: (el) => (this.
|
|
122
|
+
}, htmlFor: this.inputId, onKeyDown: this.handleKeyDown, onMouseDown: this.handleMouseDown }, h("span", { part: "control", class: "radio__control" }, h("span", { part: "checked-icon", class: "radio__icon" }, h("svg", { viewBox: "0 0 16 16" }, h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd" }, h("g", { fill: "currentColor" }, h("circle", { cx: "8", cy: "8", r: "5" }))))), h("input", { ref: (el) => (this.nativeInput = el), id: this.inputId, type: "radio", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled, role: "radio", "aria-checked": this.checked ? 'true' : 'false', "aria-labelledby": this.labelId, onClick: this.handleClick, onBlur: this.handleBlur, onFocus: this.handleFocus })), h("span", { part: "label", id: this.labelId, class: "radio__label" }, h("slot", null))));
|
|
118
123
|
}
|
|
119
124
|
get host() { return this; }
|
|
120
125
|
static get watchers() { return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"six-radio.js","mappings":";;AAAA,MAAM,WAAW,GAAG,g3DAAg3D;;ACGp4D,IAAI,EAAE,GAAG,CAAC,CAAC;MAqBEA,UAAQ;;;;;;;;IACnB,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;;IA8CtB,iBAAY,GAAG,KAAK,CAAC;oBAzCT,KAAK;;;oBASN,KAAK;mBAG0B,KAAK;mBAML,KAAK;;EAGvD,mBAAmB;IACjB,IAAI,IAAI,CAAC,OAAO,EAAE;MAChB,IAAI,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,MAAM,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;KACjE;IACD,IAAI,IAAI,CAAC,KAAK,EAAE;MACd,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;MAClC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,C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AAC,GAAG,GAAU,CACnC,CACF,CACA,CACD,EAEP,aACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,EAAE,EAAE,IAAI,CAAC,OAAO,EAChB,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,OAAO,kBACE,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,qBAC5B,IAAI,CAAC,OAAO,EAC7B,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,EACvB,OAAO,EAAE,IAAI,CAAC,WAAW,GACzB,CACG,EAEP,YAAM,IAAI,EAAC,OAAO,EAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,cAAc,IACvD,eAAQ,CACH,CACD,EACR;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixRadio"],"sources":["./src/components/six-radio/six-radio.scss?tag=six-radio&encapsulation=shadow","./src/components/six-radio/six-radio.tsx"],"sourcesContent":["@import 'src/global/component';\n\n:host {\n display: inline-block;\n}\n\n.radio {\n display: inline-flex;\n align-items: center;\n font-family: var(--six-font-family);\n font-size: var(--six-input-font-size-medium);\n font-weight: var(--six-input-font-weight);\n color: var(--six-input-color);\n vertical-align: middle;\n cursor: pointer;\n}\n\n.radio__icon {\n display: inline-flex;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n\n svg {\n width: 100%;\n height: 100%;\n }\n}\n\n.radio__control {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n border: solid var(--six-border-width) var(--six-input-border-color);\n border-radius: 50%;\n background-color: var(--six-input-background-color);\n color: transparent;\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow;\n\n input[type='radio'] {\n position: absolute;\n opacity: 0;\n padding: 0;\n margin: 0;\n pointer-events: none;\n }\n}\n\n// Hover\n.radio:not(.radio--checked):not(.radio--disabled) .radio__control:hover {\n border-color: var(--six-input-border-color-hover);\n}\n\n// Checked\n.radio--checked .radio__control {\n color: var(--six-selection-control-color);\n border-color: var(--six-selection-control-color);\n}\n\n// Checked + hover\n.radio.radio--checked:not(.radio--disabled) .radio__control:hover {\n color: var(--six-input-border-color-focus);\n border-color: var(--six-input-border-color-focus);\n}\n\n// Disabled\n.radio--disabled {\n cursor: not-allowed;\n color: var(--six-input-color-disabled);\n\n .radio__control {\n border-color: var(--six-input-border-color-disabled);\n }\n\n &.radio--checked .radio__control {\n color: var(--six-selection-control-color-disabled);\n }\n}\n\n.radio__label {\n line-height: var(--six-selection-control-toggle-size);\n margin-left: 0.5em;\n user-select: none;\n}\n","import { Component, Element, Event, EventEmitter, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { EmptyPayload } from '../../utils/types';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot - The radio's label.\n *\n * @part base - The component's base wrapper.\n * @part control - The radio control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part label - The radio label.\n */\n\n@Component({\n tag: 'six-radio',\n styleUrl: 'six-radio.scss',\n shadow: true,\n})\nexport class SixRadio {\n inputId = `radio-${++id}`;\n labelId = `radio-label-${id}`;\n input: HTMLInputElement;\n\n @Element() host: HTMLSixRadioElement;\n\n @State() hasFocus = false;\n\n /** The radio's name attribute. */\n @Prop() name: string;\n\n /** The radio's value attribute. */\n @Prop() value: string;\n\n /** Set to true to disable the radio. */\n @Prop() disabled = false;\n\n /** Set to true to draw the radio in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n @Watch('checked')\n handleCheckedChange() {\n if (this.checked) {\n this.getSiblingRadios().map((radio) => (radio.checked = false));\n }\n if (this.input) {\n this.input.checked = this.checked;\n this.sixChange.emit();\n }\n }\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-radio-blur' }) sixBlur: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-radio-change' }) sixChange: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-radio-focus' }) sixFocus: EventEmitter<EmptyPayload>;\n\n /** default state whether the radio button should be checked or not when resetting */\n private defaultState = false;\n\n connectedCallback() {\n this.handleClick = this.handleClick.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMouseDown = this.handleMouseDown.bind(this);\n }\n\n componentWillLoad() {\n this.defaultState = this.checked;\n }\n\n /** Sets focus on the radio. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the radio. */\n @Method()\n async removeFocus() {\n this.input.blur();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n @Method()\n async reportValidity() {\n return this.input.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n return this.input.validity.valid;\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.input.setCustomValidity(message);\n this.invalid = !this.input.checkValidity();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.checked = this.defaultState;\n this.input.setCustomValidity('');\n this.invalid = false;\n }\n\n getAllRadios() {\n const form = this.host.closest('six-form, form') || document.body;\n\n if (!this.name) return [];\n\n return [...form.querySelectorAll('six-radio')].filter(\n (radio: HTMLSixRadioElement) => radio.name === this.name\n ) as HTMLSixRadioElement[];\n }\n\n getSiblingRadios() {\n return this.getAllRadios().filter((radio) => radio !== this.host) as HTMLSixRadioElement[];\n }\n\n handleClick() {\n this.checked = this.input.checked;\n }\n\n handleBlur() {\n this.hasFocus = false;\n this.sixBlur.emit();\n }\n\n handleFocus() {\n this.hasFocus = true;\n this.sixFocus.emit();\n }\n\n handleKeyDown(event: KeyboardEvent) {\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;\n let index = radios.indexOf(this.host) + incr;\n if (index < 0) index = radios.length - 1;\n if (index > radios.length - 1) index = 0;\n\n this.getAllRadios().map((radio) => (radio.checked = false));\n radios[index].setFocus();\n radios[index].checked = true;\n\n event.preventDefault();\n }\n }\n\n handleMouseDown(event: MouseEvent) {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.input.focus();\n }\n\n render() {\n return (\n <label\n part=\"base\"\n class={{\n radio: true,\n 'radio--checked': this.checked,\n 'radio--disabled': this.disabled,\n 'radio--focused': this.hasFocus,\n }}\n htmlFor={this.inputId}\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"radio__control\">\n <span part=\"checked-icon\" class=\"radio__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"5\"></circle>\n </g>\n </g>\n </svg>\n </span>\n\n <input\n ref={(el) => (this.input = el)}\n id={this.inputId}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onClick={this.handleClick}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n />\n </span>\n\n <span part=\"label\" id={this.labelId} class=\"radio__label\">\n <slot />\n </span>\n </label>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"six-radio.js","mappings":";;AAAA,MAAM,WAAW,GAAG,g3DAAg3D;;ACGp4D,IAAI,EAAE,GAAG,CAAC,CAAC;MAqBEA,UAAQ;;;;;;;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;;IA8C9B,iBAAY,GAAG,KAAK,CAAC;IAgErB,gBAAW,GAAG;MACpB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;OACzC;KACF,CAAC;IAEM,eAAU,GAAG;MACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;MACtB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;KACrB,CAAC;IAEM,gBAAW,GAAG;MACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;MACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;KACtB,CAAC;IAEM,kBAAa,GAAG,CAAC,KAAoB;MAC3C,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtE,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnE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CAAC,WAAW,GACzB,CACG,EAEP,YAAM,IAAI,EAAC,OAAO,EAAC,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAC,cAAc,IACvD,eAAQ,CACH,CACD,EACR;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixRadio"],"sources":["./src/components/six-radio/six-radio.scss?tag=six-radio&encapsulation=shadow","./src/components/six-radio/six-radio.tsx"],"sourcesContent":["@import 'src/global/component';\n\n:host {\n display: inline-block;\n}\n\n.radio {\n display: inline-flex;\n align-items: center;\n font-family: var(--six-font-family);\n font-size: var(--six-input-font-size-medium);\n font-weight: var(--six-input-font-weight);\n color: var(--six-input-color);\n vertical-align: middle;\n cursor: pointer;\n}\n\n.radio__icon {\n display: inline-flex;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n\n svg {\n width: 100%;\n height: 100%;\n }\n}\n\n.radio__control {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--six-selection-control-toggle-size);\n height: var(--six-selection-control-toggle-size);\n border: solid var(--six-border-width) var(--six-input-border-color);\n border-radius: 50%;\n background-color: var(--six-input-background-color);\n color: transparent;\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow;\n\n input[type='radio'] {\n position: absolute;\n opacity: 0;\n padding: 0;\n margin: 0;\n pointer-events: none;\n }\n}\n\n// Hover\n.radio:not(.radio--checked):not(.radio--disabled) .radio__control:hover {\n border-color: var(--six-input-border-color-hover);\n}\n\n// Checked\n.radio--checked .radio__control {\n color: var(--six-selection-control-color);\n border-color: var(--six-selection-control-color);\n}\n\n// Checked + hover\n.radio.radio--checked:not(.radio--disabled) .radio__control:hover {\n color: var(--six-input-border-color-focus);\n border-color: var(--six-input-border-color-focus);\n}\n\n// Disabled\n.radio--disabled {\n cursor: not-allowed;\n color: var(--six-input-color-disabled);\n\n .radio__control {\n border-color: var(--six-input-border-color-disabled);\n }\n\n &.radio--checked .radio__control {\n color: var(--six-selection-control-color-disabled);\n }\n}\n\n.radio__label {\n line-height: var(--six-selection-control-toggle-size);\n margin-left: 0.5em;\n user-select: none;\n}\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport { EmptyPayload } from '../../utils/types';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot - The radio's label.\n *\n * @part base - The component's base wrapper.\n * @part control - The radio control.\n * @part checked-icon - The container the wraps the checked icon.\n * @part label - The radio label.\n */\n\n@Component({\n tag: 'six-radio',\n styleUrl: 'six-radio.scss',\n shadow: true,\n})\nexport class SixRadio {\n private inputId = `radio-${++id}`;\n private labelId = `radio-label-${id}`;\n private nativeInput?: HTMLInputElement;\n\n @Element() host!: HTMLSixRadioElement;\n\n @State() hasFocus = false;\n\n /** The radio's name attribute. */\n @Prop() name = '';\n\n /** The radio's value attribute. */\n @Prop() value = 'on';\n\n /** Set to true to disable the radio. */\n @Prop() disabled = false;\n\n /** Set to true to draw the radio in a checked state. */\n @Prop({ mutable: true, reflect: true }) checked = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n @Watch('checked')\n handleCheckedChange() {\n if (this.checked) {\n this.getSiblingRadios().map((radio) => (radio.checked = false));\n }\n if (this.nativeInput != null) {\n this.nativeInput.checked = this.checked;\n this.sixChange.emit();\n }\n }\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-radio-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control's checked state changes. */\n @Event({ eventName: 'six-radio-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-radio-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** default state whether the radio button should be checked or not when resetting */\n private defaultState = false;\n\n componentWillLoad() {\n this.defaultState = this.checked;\n }\n\n /** Sets focus on the radio. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the radio. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Checks for validity and shows the browser's validation message if the control is invalid. */\n @Method()\n async reportValidity() {\n return this.nativeInput?.reportValidity();\n }\n\n /** Checks for validity. */\n @Method()\n async checkValidity() {\n if (this.nativeInput == null) {\n return true;\n }\n return this.nativeInput.validity.valid;\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n if (this.nativeInput != null) {\n this.nativeInput.setCustomValidity(message);\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.checked = this.defaultState;\n this.nativeInput?.setCustomValidity('');\n this.invalid = false;\n }\n\n private getAllRadios() {\n const form = this.host.closest('six-form, form') || document.body;\n\n if (this.name === '') return [];\n\n return [...form.querySelectorAll('six-radio')].filter(\n (radio: HTMLSixRadioElement) => radio.name === this.name\n ) as HTMLSixRadioElement[];\n }\n\n private getSiblingRadios() {\n return this.getAllRadios().filter((radio) => radio !== this.host) as HTMLSixRadioElement[];\n }\n\n private handleClick = () => {\n if (this.nativeInput != null) {\n this.checked = this.nativeInput.checked;\n }\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.sixBlur.emit();\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.sixFocus.emit();\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {\n const radios = this.getAllRadios().filter((radio) => !radio.disabled);\n const incr = ['ArrowUp', 'ArrowLeft'].includes(event.key) ? -1 : 1;\n let index = radios.indexOf(this.host) + incr;\n if (index < 0) index = radios.length - 1;\n if (index > radios.length - 1) index = 0;\n\n this.getAllRadios().map((radio) => (radio.checked = false));\n radios[index].setFocus();\n radios[index].checked = true;\n\n event.preventDefault();\n }\n };\n\n private handleMouseDown = (event: MouseEvent) => {\n // Prevent clicks on the label from briefly blurring the input\n event.preventDefault();\n this.nativeInput?.focus();\n };\n\n render() {\n return (\n <label\n part=\"base\"\n class={{\n radio: true,\n 'radio--checked': this.checked,\n 'radio--disabled': this.disabled,\n 'radio--focused': this.hasFocus,\n }}\n htmlFor={this.inputId}\n onKeyDown={this.handleKeyDown}\n onMouseDown={this.handleMouseDown}\n >\n <span part=\"control\" class=\"radio__control\">\n <span part=\"checked-icon\" class=\"radio__icon\">\n <svg viewBox=\"0 0 16 16\">\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g fill=\"currentColor\">\n <circle cx=\"8\" cy=\"8\" r=\"5\"></circle>\n </g>\n </g>\n </svg>\n </span>\n\n <input\n ref={(el) => (this.nativeInput = el)}\n id={this.inputId}\n type=\"radio\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n disabled={this.disabled}\n role=\"radio\"\n aria-checked={this.checked ? 'true' : 'false'}\n aria-labelledby={this.labelId}\n onClick={this.handleClick}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n />\n </span>\n\n <span part=\"label\" id={this.labelId} class=\"radio__label\">\n <slot />\n </span>\n </label>\n );\n }\n}\n"],"version":3}
|
|
@@ -17,20 +17,54 @@ const SixRange$1 = /*@__PURE__*/ proxyCustomElement(class SixRange extends HTMLE
|
|
|
17
17
|
this.inputId = `input-${++id}`;
|
|
18
18
|
this.labelId = `input-label-${id}`;
|
|
19
19
|
this.helpTextId = `input-help-text-${id}`;
|
|
20
|
-
this.errorTextId = `input-error-text-${id}`;
|
|
21
20
|
this.customErrorText = '';
|
|
22
21
|
this.customValidation = false;
|
|
22
|
+
this.errorTextId = `input-error-text-${id}`;
|
|
23
23
|
this.eventListeners = new EventListeners();
|
|
24
24
|
/** default value the slider will be reverted to when reset is executed */
|
|
25
25
|
this.defaultValue = 0;
|
|
26
|
+
this.handleInput = () => {
|
|
27
|
+
if (this.nativeInput != null) {
|
|
28
|
+
this.update(parseFloat(this.nativeInput.value));
|
|
29
|
+
}
|
|
30
|
+
requestAnimationFrame(() => {
|
|
31
|
+
this.sixChange.emit();
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
this.handleBlur = () => {
|
|
35
|
+
var _a;
|
|
36
|
+
this.hasFocus = false;
|
|
37
|
+
this.hasTooltip = false;
|
|
38
|
+
this.sixBlur.emit();
|
|
39
|
+
if (this.nativeInput != null) {
|
|
40
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.nativeInput);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
this.handleFocus = () => {
|
|
44
|
+
var _a;
|
|
45
|
+
this.hasFocus = true;
|
|
46
|
+
this.hasTooltip = true;
|
|
47
|
+
this.sixFocus.emit();
|
|
48
|
+
if (this.nativeInput != null) {
|
|
49
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.nativeInput);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.handleSlotChange = () => {
|
|
53
|
+
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
54
|
+
this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
|
|
55
|
+
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
56
|
+
};
|
|
57
|
+
this.handleTouchStart = () => {
|
|
58
|
+
this.setFocus();
|
|
59
|
+
};
|
|
26
60
|
this.hasFocus = false;
|
|
27
61
|
this.hasHelpTextSlot = false;
|
|
28
62
|
this.hasLabelSlot = false;
|
|
29
63
|
this.hasErrorTextSlot = false;
|
|
30
64
|
this.hasTooltip = false;
|
|
31
65
|
this.name = '';
|
|
32
|
-
this.value =
|
|
33
|
-
this.required =
|
|
66
|
+
this.value = 0;
|
|
67
|
+
this.required = false;
|
|
34
68
|
this.label = '';
|
|
35
69
|
this.helpText = '';
|
|
36
70
|
this.errorText = '';
|
|
@@ -47,119 +81,125 @@ const SixRange$1 = /*@__PURE__*/ proxyCustomElement(class SixRange extends HTMLE
|
|
|
47
81
|
this.handleSlotChange();
|
|
48
82
|
}
|
|
49
83
|
handleValueChange() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.
|
|
84
|
+
this.update();
|
|
85
|
+
if (this.nativeInput != null) {
|
|
86
|
+
this.invalid = !this.nativeInput.checkValidity();
|
|
53
87
|
}
|
|
54
|
-
// In rare cases, the watcher may be called before render so we need to make sure the input exists
|
|
55
|
-
this.invalid = this.input ? !this.input.checkValidity() : false;
|
|
56
88
|
}
|
|
57
89
|
connectedCallback() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.handleFocus = this.handleFocus.bind(this);
|
|
61
|
-
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
62
|
-
this.handleTouchStart = this.handleTouchStart.bind(this);
|
|
63
|
-
this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
|
|
64
92
|
}
|
|
65
93
|
componentWillLoad() {
|
|
66
|
-
|
|
67
|
-
this.value = this.min;
|
|
68
|
-
if (this.value < this.min)
|
|
69
|
-
this.value = this.min;
|
|
70
|
-
if (this.value > this.max)
|
|
71
|
-
this.value = this.max;
|
|
94
|
+
this.update();
|
|
72
95
|
this.defaultValue = this.value;
|
|
73
96
|
this.handleSlotChange();
|
|
74
97
|
}
|
|
75
98
|
componentDidLoad() {
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
99
|
+
const nativeInput = this.nativeInput;
|
|
100
|
+
if (nativeInput == null) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.update();
|
|
104
|
+
this.resizeObserver = new ResizeObserver(() => this.update());
|
|
105
|
+
this.eventListeners.add(nativeInput, 'invalid', (event) => {
|
|
106
|
+
if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
|
|
107
|
+
this.customErrorText = nativeInput.validationMessage;
|
|
82
108
|
}
|
|
83
109
|
event.preventDefault();
|
|
84
110
|
});
|
|
85
111
|
}
|
|
86
112
|
disconnectedCallback() {
|
|
87
|
-
|
|
113
|
+
var _a;
|
|
114
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
|
|
88
115
|
this.eventListeners.removeAll();
|
|
89
116
|
}
|
|
90
117
|
/** Sets focus on the input. */
|
|
91
118
|
async setFocus(options) {
|
|
92
|
-
|
|
119
|
+
var _a;
|
|
120
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
|
|
93
121
|
}
|
|
94
122
|
/** Removes focus from the input. */
|
|
95
123
|
async removeFocus() {
|
|
96
|
-
|
|
124
|
+
var _a;
|
|
125
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
|
|
97
126
|
}
|
|
98
127
|
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
|
99
128
|
async setCustomValidity(message) {
|
|
100
129
|
this.customErrorText = '';
|
|
101
130
|
this.customValidation = message !== '';
|
|
102
|
-
this.
|
|
103
|
-
|
|
131
|
+
if (this.nativeInput != null) {
|
|
132
|
+
this.nativeInput.setCustomValidity(message);
|
|
133
|
+
this.invalid = !this.nativeInput.checkValidity();
|
|
134
|
+
}
|
|
104
135
|
}
|
|
105
136
|
/** Resets the formcontrol */
|
|
106
137
|
async reset() {
|
|
138
|
+
var _a;
|
|
107
139
|
this.value = this.defaultValue;
|
|
108
140
|
this.customErrorText = '';
|
|
109
141
|
this.customValidation = false;
|
|
110
|
-
this.
|
|
142
|
+
(_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
|
|
111
143
|
this.invalid = false;
|
|
112
144
|
}
|
|
113
|
-
handleInput() {
|
|
114
|
-
this.value = Number(this.input.value);
|
|
115
|
-
this.sixChange.emit();
|
|
116
|
-
requestAnimationFrame(() => this.syncTooltip());
|
|
117
|
-
requestAnimationFrame(() => this.calculateColorRunnableTrack());
|
|
118
|
-
}
|
|
119
|
-
handleBlur() {
|
|
120
|
-
this.hasFocus = false;
|
|
121
|
-
this.hasTooltip = false;
|
|
122
|
-
this.sixBlur.emit();
|
|
123
|
-
this.resizeObserver.unobserve(this.input);
|
|
124
|
-
}
|
|
125
|
-
handleFocus() {
|
|
126
|
-
this.hasFocus = true;
|
|
127
|
-
this.hasTooltip = true;
|
|
128
|
-
this.sixFocus.emit();
|
|
129
|
-
this.resizeObserver.observe(this.input);
|
|
130
|
-
}
|
|
131
|
-
handleSlotChange() {
|
|
132
|
-
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
133
|
-
this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
|
|
134
|
-
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
135
|
-
}
|
|
136
|
-
handleTouchStart() {
|
|
137
|
-
this.setFocus();
|
|
138
|
-
}
|
|
139
145
|
displayError() {
|
|
140
146
|
return this.invalid && (!this.errorOnBlur || !this.hasFocus);
|
|
141
147
|
}
|
|
142
|
-
syncTooltip() {
|
|
143
|
-
if (this.tooltip !== 'none') {
|
|
144
|
-
const percent = Math.max(0, (
|
|
145
|
-
const inputWidth = this.
|
|
148
|
+
syncTooltip(min, max, value) {
|
|
149
|
+
if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {
|
|
150
|
+
const percent = Math.max(0, (value - min) / (max - min));
|
|
151
|
+
const inputWidth = this.nativeInput.offsetWidth;
|
|
146
152
|
const tooltipWidth = this.output.offsetWidth;
|
|
147
|
-
const thumbSize = getComputedStyle(this.
|
|
153
|
+
const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');
|
|
148
154
|
const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;
|
|
149
155
|
this.output.style.transform = `translateX(${x})`;
|
|
150
156
|
this.output.style.marginLeft = `-${tooltipWidth / 2}px`;
|
|
151
157
|
}
|
|
152
158
|
}
|
|
159
|
+
isFirefox() {
|
|
160
|
+
return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
161
|
+
}
|
|
162
|
+
update(updateValue) {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
if (updateValue != null) {
|
|
165
|
+
this.value = updateValue;
|
|
166
|
+
}
|
|
167
|
+
const min = (_a = Number(this.min)) !== null && _a !== void 0 ? _a : 0;
|
|
168
|
+
const max = (_b = Number(this.max)) !== null && _b !== void 0 ? _b : 0;
|
|
169
|
+
let value;
|
|
170
|
+
const parsedValue = parseFloat(this.value);
|
|
171
|
+
if (isNaN(parsedValue)) {
|
|
172
|
+
value = this.getDefaultValue(min, max);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
value = parsedValue;
|
|
176
|
+
}
|
|
177
|
+
if (this.nativeInput != null) {
|
|
178
|
+
// The value may have constraints, so we set the native control's
|
|
179
|
+
// value and sync it back to ensure it adheres to min, max, and step
|
|
180
|
+
// properly.
|
|
181
|
+
this.nativeInput.value = value.toString();
|
|
182
|
+
this.value = parseFloat(this.nativeInput.value);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.value = value;
|
|
186
|
+
}
|
|
187
|
+
this.calculateColorRunnableTrack(min, max, this.value);
|
|
188
|
+
this.syncTooltip(min, max, this.value);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value
|
|
192
|
+
*/
|
|
193
|
+
getDefaultValue(min, max) {
|
|
194
|
+
return max < min ? min : min + (max - min) / 2;
|
|
195
|
+
}
|
|
153
196
|
/**
|
|
154
197
|
* For Firefox this functionality is not needed because it is supported by standard CSS.
|
|
155
198
|
*/
|
|
156
|
-
calculateColorRunnableTrack() {
|
|
157
|
-
if (!this.isFirefox()) {
|
|
158
|
-
const value = parseInt(this.input.value, 10);
|
|
159
|
-
const min = parseInt(this.input.min, 10);
|
|
160
|
-
const max = parseInt(this.input.max, 10);
|
|
199
|
+
calculateColorRunnableTrack(min, max, value) {
|
|
200
|
+
if (!this.isFirefox() && this.nativeInput != null) {
|
|
161
201
|
const percent = Math.ceil(((value - min) / (max - min)) * 100);
|
|
162
|
-
this.
|
|
202
|
+
this.nativeInput.style.background =
|
|
163
203
|
'-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +
|
|
164
204
|
percent +
|
|
165
205
|
'%, var(--six-color-web-rock-300) ' +
|
|
@@ -167,11 +207,8 @@ const SixRange$1 = /*@__PURE__*/ proxyCustomElement(class SixRange extends HTMLE
|
|
|
167
207
|
'%)';
|
|
168
208
|
}
|
|
169
209
|
}
|
|
170
|
-
isFirefox() {
|
|
171
|
-
return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
172
|
-
}
|
|
173
210
|
render() {
|
|
174
|
-
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.customErrorText ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("div", { part: "base", class: {
|
|
211
|
+
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.customErrorText != null ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("div", { part: "base", class: {
|
|
175
212
|
range: true,
|
|
176
213
|
// States
|
|
177
214
|
'range--disabled': this.disabled,
|
|
@@ -179,14 +216,16 @@ const SixRange$1 = /*@__PURE__*/ proxyCustomElement(class SixRange extends HTMLE
|
|
|
179
216
|
'range--tooltip-visible': this.hasTooltip,
|
|
180
217
|
'range--tooltip-top': this.tooltip === 'top',
|
|
181
218
|
'range--tooltip-bottom': this.tooltip === 'bottom',
|
|
182
|
-
}, onTouchStart: this.handleTouchStart }, h("input", { part: "input", ref: (el) => (this.
|
|
219
|
+
}, onTouchStart: this.handleTouchStart }, h("input", { part: "input", ref: (el) => (this.nativeInput = el), type: "range", class: "range__control", name: this.name, disabled: this.disabled, min: this.min, max: this.max, step: this.step, value: this.value, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur }), this.tooltip !== 'none' && (h("output", { part: "tooltip", ref: (el) => (this.output = el), class: "range__tooltip" }, this.tooltipFormatter(this.value))))));
|
|
183
220
|
}
|
|
184
221
|
get host() { return this; }
|
|
185
222
|
static get watchers() { return {
|
|
186
223
|
"label": ["handleLabelChange"],
|
|
187
224
|
"errorText": ["handleLabelChange"],
|
|
188
225
|
"helpText": ["handleLabelChange"],
|
|
189
|
-
"value": ["handleValueChange"]
|
|
226
|
+
"value": ["handleValueChange"],
|
|
227
|
+
"min": ["handleValueChange"],
|
|
228
|
+
"max": ["handleValueChange"]
|
|
190
229
|
}; }
|
|
191
230
|
static get style() { return sixRangeCss; }
|
|
192
231
|
}, [1, "six-range", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"six-range.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,89MAA89M;;ACMl/M,IAAI,EAAE,GAAG,CAAC,CAAC;MAqBEA,UAAQ;;;;;;;;IACnB,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAC9B,eAAU,GAAG,mBAAmB,E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AC,EAAE,MAAM,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,gBAAgB,IAC3E,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC3B,CACV,CACG,CACM,EACd;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixRange"],"sources":["./src/components/six-range/six-range.scss?tag=six-range&encapsulation=shadow","./src/components/six-range/six-range.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n --thumb-size: 14px;\n --tooltip-offset-y: 10px;\n --track-color: var(--six-color-web-rock-900);\n --thumb-color: var(--six-color-web-rock-900);\n --track-height: 3px;\n\n display: block;\n}\n\n.range {\n position: relative;\n\n .range__control {\n -webkit-appearance: none;\n width: 100%;\n height: var(--six-input-height-medium);\n background: transparent;\n line-height: var(--six-input-height-medium);\n vertical-align: middle;\n\n &::-webkit-slider-runnable-track {\n width: 100%;\n height: var(--track-height);\n border-radius: 3px;\n border: none;\n }\n\n &::-webkit-slider-thumb {\n border: none;\n width: var(--thumb-size);\n height: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n -webkit-appearance: none;\n margin-top: calc(var(--thumb-size) / -2 + var(--track-height) / 2);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-webkit-slider-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-webkit-slider-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-webkit-slider-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // Firefox\n &::-moz-focus-outer {\n border: 0;\n }\n\n &::-moz-range-track {\n width: 100%;\n height: var(--track-height);\n background-color: var(--six-progress-track-color);\n border-radius: 3px;\n border: none;\n }\n\n &::-moz-range-progress {\n height: var(--track-height);\n border-radius: 3px;\n background-color: var(--track-color);\n border: none;\n }\n\n &::-moz-range-thumb {\n border: none;\n height: var(--thumb-size);\n width: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-moz-range-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-moz-range-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-moz-range-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // States\n &:focus {\n outline: none;\n }\n\n &:disabled {\n &::-webkit-slider-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n\n &::-moz-range-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n }\n }\n}\n\n// Tooltip\n.range__tooltip {\n position: absolute;\n z-index: var(--six-z-index-tooltip);\n left: 1px;\n border-radius: var(--six-border-radius-medium);\n background-color: var(--six-color-web-rock-900);\n font-family: var(--six-font-family);\n font-size: var(--six-tooltip-font-size);\n font-weight: var(--six-tooltip-font-weight);\n line-height: var(--six-tooltip-line-height);\n color: var(--six-color-white);\n opacity: 0;\n padding: var(--six-spacing-xxx-small) var(--six-spacing-xx-small);\n transition: var(--six-transition-fast) opacity;\n pointer-events: none;\n\n &::after {\n content: '';\n position: absolute;\n width: 0;\n height: 0;\n left: 50%;\n margin-left: calc(-1 * var(--six-tooltip-arrow-size));\n }\n}\n\n.range--tooltip-visible .range__tooltip {\n opacity: 1;\n}\n\n// Tooltip on top\n.range--tooltip-top .range__tooltip {\n top: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-top: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n top: 100%;\n }\n}\n\n// Tooltip on bottom\n.range--tooltip-bottom .range__tooltip {\n bottom: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-bottom: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n bottom: 100%;\n }\n}\n","import { Component, Element, Event, EventEmitter, Method, Prop, State, Watch, h } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n inputId = `input-${++id}`;\n labelId = `input-label-${id}`;\n helpTextId = `input-help-text-${id}`;\n errorTextId = `input-error-text-${id}`;\n resizeObserver: ResizeObserver;\n\n output: HTMLElement;\n input: HTMLInputElement;\n customErrorText = '';\n customValidation = false;\n\n readonly eventListeners = new EventListeners();\n\n @Element() host: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value: number;\n\n /** Set to true to make the input a required field. */\n @Prop({ reflect: true }) required: boolean;\n\n /** The range's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus: EventEmitter<EmptyPayload>;\n\n /** default value the slider will be reverted to when reset is executed */\n private defaultValue = 0;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n handleValueChange() {\n if (this.input) {\n this.input.value = this.value as any;\n this.calculateColorRunnableTrack();\n }\n // In rare cases, the watcher may be called before render so we need to make sure the input exists\n this.invalid = this.input ? !this.input.checkValidity() : false;\n }\n\n connectedCallback() {\n this.handleInput = this.handleInput.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleSlotChange = this.handleSlotChange.bind(this);\n this.handleTouchStart = this.handleTouchStart.bind(this);\n\n this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n if (this.value === undefined || this.value === null) this.value = this.min;\n if (this.value < this.min) this.value = this.min;\n if (this.value > this.max) this.value = this.max;\n this.defaultValue = this.value;\n\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n this.syncTooltip();\n this.calculateColorRunnableTrack();\n this.resizeObserver = new ResizeObserver(() => this.syncTooltip());\n this.eventListeners.add(this.input, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {\n this.customErrorText = this.input.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.input.blur();\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n this.input.setCustomValidity(message);\n this.invalid = !this.input.checkValidity();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.input.setCustomValidity('');\n this.invalid = false;\n }\n\n handleInput() {\n this.value = Number(this.input.value);\n this.sixChange.emit();\n\n requestAnimationFrame(() => this.syncTooltip());\n requestAnimationFrame(() => this.calculateColorRunnableTrack());\n }\n\n handleBlur() {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n this.resizeObserver.unobserve(this.input);\n }\n\n handleFocus() {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n this.resizeObserver.observe(this.input);\n }\n\n handleSlotChange() {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n }\n\n handleTouchStart() {\n this.setFocus();\n }\n\n displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n syncTooltip() {\n if (this.tooltip !== 'none') {\n const percent = Math.max(0, (this.value - this.min) / (this.max - this.min));\n const inputWidth = this.input.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.input).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n calculateColorRunnableTrack() {\n if (!this.isFirefox()) {\n const value = parseInt(this.input.value, 10);\n const min = parseInt(this.input.min, 10);\n const max = parseInt(this.input.max, 10);\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.input.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.customErrorText ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.input = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=\"range__tooltip\">\n {this.tooltipFormatter(this.value)}\n </output>\n )}\n </div>\n </FormControl>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"six-range.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,89MAA89M;;ACMl/M,IAAI,EAAE,GAAG,CAAC,CAAC;MAqBEA,UAAQ;;;;;;;;IACX,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAC9B,eAAU,GAAG,mBAAmB,EAAE,EAAE,CAAC;IACrC,oBAAe,GAAG,EAAE,CAAC;IACrB,qBAAgB,GAAG,KAAK,CAAC;IACzB,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IACvC,mBAAc,GAAG,IAAI,cAAc,EAAE,CAAC;;IAqEtC,iBAAY,GAAG,CAAC,CAAC;IAkFjB,gBAAW,GAAG;MACpB,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,EAAE;QAC5B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;OACjD;MACD,qBAAqB,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;OACvB,CAAC,CAAC;KACJ,CAAC;IAEM,eAAU,GAAG;;MACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;MACtB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;MACx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B,IAC3E,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC3B,CACV,CACG,CACM,EACd;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SixRange"],"sources":["./src/components/six-range/six-range.scss?tag=six-range&encapsulation=shadow","./src/components/six-range/six-range.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n --thumb-size: 14px;\n --tooltip-offset-y: 10px;\n --track-color: var(--six-color-web-rock-900);\n --thumb-color: var(--six-color-web-rock-900);\n --track-height: 3px;\n\n display: block;\n}\n\n.range {\n position: relative;\n\n .range__control {\n -webkit-appearance: none;\n width: 100%;\n height: var(--six-input-height-medium);\n background: transparent;\n line-height: var(--six-input-height-medium);\n vertical-align: middle;\n\n &::-webkit-slider-runnable-track {\n width: 100%;\n height: var(--track-height);\n border-radius: 3px;\n border: none;\n }\n\n &::-webkit-slider-thumb {\n border: none;\n width: var(--thumb-size);\n height: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n -webkit-appearance: none;\n margin-top: calc(var(--thumb-size) / -2 + var(--track-height) / 2);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-webkit-slider-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-webkit-slider-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-webkit-slider-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // Firefox\n &::-moz-focus-outer {\n border: 0;\n }\n\n &::-moz-range-track {\n width: 100%;\n height: var(--track-height);\n background-color: var(--six-progress-track-color);\n border-radius: 3px;\n border: none;\n }\n\n &::-moz-range-progress {\n height: var(--track-height);\n border-radius: 3px;\n background-color: var(--track-color);\n border: none;\n }\n\n &::-moz-range-thumb {\n border: none;\n height: var(--thumb-size);\n width: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-moz-range-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-moz-range-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-moz-range-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // States\n &:focus {\n outline: none;\n }\n\n &:disabled {\n &::-webkit-slider-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n\n &::-moz-range-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n }\n }\n}\n\n// Tooltip\n.range__tooltip {\n position: absolute;\n z-index: var(--six-z-index-tooltip);\n left: 1px;\n border-radius: var(--six-border-radius-medium);\n background-color: var(--six-color-web-rock-900);\n font-family: var(--six-font-family);\n font-size: var(--six-tooltip-font-size);\n font-weight: var(--six-tooltip-font-weight);\n line-height: var(--six-tooltip-line-height);\n color: var(--six-color-white);\n opacity: 0;\n padding: var(--six-spacing-xxx-small) var(--six-spacing-xx-small);\n transition: var(--six-transition-fast) opacity;\n pointer-events: none;\n\n &::after {\n content: '';\n position: absolute;\n width: 0;\n height: 0;\n left: 50%;\n margin-left: calc(-1 * var(--six-tooltip-arrow-size));\n }\n}\n\n.range--tooltip-visible .range__tooltip {\n opacity: 1;\n}\n\n// Tooltip on top\n.range--tooltip-top .range__tooltip {\n top: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-top: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n top: 100%;\n }\n}\n\n// Tooltip on bottom\n.range--tooltip-bottom .range__tooltip {\n bottom: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-bottom: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n bottom: 100%;\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private customErrorText = '';\n private customValidation = false;\n private errorTextId = `input-error-text-${id}`;\n private eventListeners = new EventListeners();\n private resizeObserver?: ResizeObserver;\n\n private output?: HTMLElement;\n private nativeInput?: HTMLInputElement;\n\n @Element() host!: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value = 0;\n\n /** Set to true to make the input a required field. */\n @Prop({ reflect: true }) required = false;\n\n /** The range's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** default value the slider will be reverted to when reset is executed */\n private defaultValue = 0;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n @Watch('min')\n @Watch('max')\n handleValueChange() {\n this.update();\n if (this.nativeInput != null) {\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.update();\n this.defaultValue = this.value;\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeInput = this.nativeInput;\n if (nativeInput == null) {\n return;\n }\n this.update();\n this.resizeObserver = new ResizeObserver(() => this.update());\n this.eventListeners.add(nativeInput, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {\n this.customErrorText = nativeInput.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n if (this.nativeInput != null) {\n this.nativeInput.setCustomValidity(message);\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.nativeInput?.setCustomValidity('');\n this.invalid = false;\n }\n\n private handleInput = () => {\n if (this.nativeInput != null) {\n this.update(parseFloat(this.nativeInput.value));\n }\n requestAnimationFrame(() => {\n this.sixChange.emit();\n });\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.unobserve(this.nativeInput);\n }\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.observe(this.nativeInput);\n }\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n };\n\n private handleTouchStart = () => {\n this.setFocus();\n };\n\n private displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n private syncTooltip(min: number, max: number, value: number) {\n if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {\n const percent = Math.max(0, (value - min) / (max - min));\n const inputWidth = this.nativeInput.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n private isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n private update(updateValue?: number) {\n if (updateValue != null) {\n this.value = updateValue;\n }\n\n const min = Number(this.min) ?? 0;\n const max = Number(this.max) ?? 0;\n let value;\n const parsedValue = parseFloat(this.value as never);\n if (isNaN(parsedValue)) {\n value = this.getDefaultValue(min, max);\n } else {\n value = parsedValue;\n }\n\n if (this.nativeInput != null) {\n // The value may have constraints, so we set the native control's\n // value and sync it back to ensure it adheres to min, max, and step\n // properly.\n this.nativeInput.value = value.toString();\n this.value = parseFloat(this.nativeInput.value);\n } else {\n this.value = value;\n }\n this.calculateColorRunnableTrack(min, max, this.value);\n this.syncTooltip(min, max, this.value);\n }\n\n /**\n * from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value\n */\n private getDefaultValue(min: number, max: number): number {\n return max < min ? min : min + (max - min) / 2;\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n private calculateColorRunnableTrack(min: number, max: number, value: number) {\n if (!this.isFirefox() && this.nativeInput != null) {\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.nativeInput.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.customErrorText != null ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=\"range__tooltip\">\n {this.tooltipFormatter(this.value)}\n </output>\n )}\n </div>\n </FormControl>\n );\n }\n}\n"],"version":3}
|