@warp-ds/elements 2.2.0-next.1 → 2.2.0-next.3
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/index.js +3441 -453
- package/dist/index.js.map +4 -4
- package/dist/packages/affix/index.d.ts +1 -1
- package/dist/packages/affix/index.js +6 -6
- package/dist/packages/affix/index.js.map +2 -2
- package/dist/packages/alert/index.d.ts +3 -4
- package/dist/packages/alert/index.js +8 -8
- package/dist/packages/alert/index.js.map +1 -1
- package/dist/packages/attention/index.d.ts +1 -1
- package/dist/packages/attention/index.js +4 -4
- package/dist/packages/attention/index.js.map +2 -2
- package/dist/packages/badge/index.d.ts +3 -2
- package/dist/packages/badge/index.js +1 -1
- package/dist/packages/badge/index.js.map +1 -1
- package/dist/packages/box/index.d.ts +5 -3
- package/dist/packages/box/index.js +1 -1
- package/dist/packages/box/index.js.map +1 -1
- package/dist/packages/breadcrumbs/index.d.ts +1 -1
- package/dist/packages/breadcrumbs/index.js +3 -3
- package/dist/packages/breadcrumbs/index.js.map +2 -2
- package/dist/packages/button/button.test.d.ts +1 -0
- package/dist/packages/button/index.d.ts +28 -52
- package/dist/packages/button/index.js +302 -6
- package/dist/packages/button/index.js.map +4 -4
- package/dist/packages/card/index.d.ts +3 -2
- package/dist/packages/card/index.js +3 -3
- package/dist/packages/card/index.js.map +1 -1
- package/dist/packages/expandable/index.d.ts +1 -1
- package/dist/packages/expandable/index.js +6 -6
- package/dist/packages/expandable/index.js.map +2 -2
- package/dist/packages/modal/index.d.ts +3 -3
- package/dist/packages/modal/index.js +314 -357
- package/dist/packages/modal/index.js.map +4 -4
- package/dist/packages/modal/modal-footer.d.ts +2 -2
- package/dist/packages/modal/modal-header.d.ts +12 -20
- package/dist/packages/modal/modal-main.d.ts +14 -24
- package/dist/packages/pill/index.d.ts +1 -1
- package/dist/packages/pill/index.js +5 -5
- package/dist/packages/pill/index.js.map +2 -2
- package/dist/packages/select/index.d.ts +12 -2
- package/dist/packages/select/index.js +304 -7
- package/dist/packages/select/index.js.map +4 -4
- package/dist/packages/styles.d.ts +2 -0
- package/dist/packages/textfield/index.d.ts +5 -5
- package/dist/packages/textfield/index.js +289 -3
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/toast/index.d.ts +3 -0
- package/dist/packages/toast/index.js +7 -7
- package/dist/packages/toast/index.js.map +1 -1
- package/dist/packages/toast/toast-container.d.ts +3 -4
- package/dist/packages/toast/toast.d.ts +4 -6
- package/dist/packages/utils/expand-transition.d.ts +3 -2
- package/dist/packages/utils/index.d.ts +1 -1
- package/dist/packages/utils/unstyled-heading.d.ts +4 -3
- package/package.json +10 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index.js";
|
|
@@ -1,61 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
import { PropertyValues } from "lit";
|
|
2
|
+
type ButtonVariant = "primary" | "secondary" | "negative" | "utility" | "pill" | "link";
|
|
3
|
+
type ButtonType = "button" | "submit" | "reset";
|
|
4
|
+
declare const WarpButton_base: import("@open-wc/form-control").Constructor<import("@open-wc/form-control").FormControlInterface> & {
|
|
2
5
|
new (): {
|
|
3
6
|
[x: string]: any;
|
|
4
7
|
};
|
|
5
8
|
[x: string]: any;
|
|
6
9
|
createProperty(name: any, options: any): void;
|
|
7
10
|
};
|
|
8
|
-
|
|
9
|
-
static shadowRootOptions:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
autofocus: {
|
|
16
|
-
type: BooleanConstructor;
|
|
17
|
-
reflect: boolean;
|
|
18
|
-
};
|
|
19
|
-
variant: {
|
|
20
|
-
type: StringConstructor;
|
|
21
|
-
reflect: boolean;
|
|
22
|
-
};
|
|
23
|
-
quiet: {
|
|
24
|
-
type: BooleanConstructor;
|
|
25
|
-
reflect: boolean;
|
|
26
|
-
};
|
|
27
|
-
small: {
|
|
28
|
-
type: BooleanConstructor;
|
|
29
|
-
reflect: boolean;
|
|
30
|
-
};
|
|
31
|
-
loading: {
|
|
32
|
-
type: BooleanConstructor;
|
|
33
|
-
reflect: boolean;
|
|
34
|
-
};
|
|
35
|
-
href: {
|
|
36
|
-
type: StringConstructor;
|
|
37
|
-
reflect: boolean;
|
|
38
|
-
};
|
|
39
|
-
target: {
|
|
40
|
-
type: StringConstructor;
|
|
41
|
-
reflect: boolean;
|
|
42
|
-
};
|
|
43
|
-
rel: {
|
|
44
|
-
type: StringConstructor;
|
|
45
|
-
reflect: boolean;
|
|
46
|
-
};
|
|
47
|
-
fullWidth: {
|
|
48
|
-
type: BooleanConstructor;
|
|
49
|
-
reflect: boolean;
|
|
50
|
-
};
|
|
51
|
-
buttonClass: {
|
|
52
|
-
type: StringConstructor;
|
|
53
|
-
reflect: boolean;
|
|
54
|
-
};
|
|
11
|
+
declare class WarpButton extends WarpButton_base {
|
|
12
|
+
static shadowRootOptions: {
|
|
13
|
+
delegatesFocus: boolean;
|
|
14
|
+
mode: ShadowRootMode;
|
|
15
|
+
serializable?: boolean;
|
|
16
|
+
slotAssignment?: SlotAssignmentMode;
|
|
55
17
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
18
|
+
type: ButtonType;
|
|
19
|
+
autofocus: boolean;
|
|
20
|
+
variant: ButtonVariant;
|
|
21
|
+
quiet: boolean;
|
|
22
|
+
small: boolean;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
href: string;
|
|
25
|
+
target: string;
|
|
26
|
+
rel: string;
|
|
27
|
+
fullWidth: boolean;
|
|
28
|
+
buttonClass: string;
|
|
29
|
+
name: string;
|
|
30
|
+
value: string;
|
|
31
|
+
static styles: import("lit").CSSResult[];
|
|
32
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
33
|
+
constructor();
|
|
59
34
|
connectedCallback(): void;
|
|
60
35
|
firstUpdated(): void;
|
|
61
36
|
get _primaryClasses(): string[];
|
|
@@ -65,6 +40,7 @@ export class WarpButton extends WarpButton_base {
|
|
|
65
40
|
get _pillClasses(): string[];
|
|
66
41
|
get _linkClasses(): string[];
|
|
67
42
|
get _classes(): string;
|
|
43
|
+
_handleButtonClick(): void;
|
|
68
44
|
render(): import("lit").TemplateResult<1>;
|
|
69
45
|
}
|
|
70
|
-
export {};
|
|
46
|
+
export { WarpButton };
|
|
@@ -1029,7 +1029,7 @@ var r = function() {
|
|
|
1029
1029
|
}, []).join(" ");
|
|
1030
1030
|
};
|
|
1031
1031
|
|
|
1032
|
-
// node_modules/.pnpm/@lingui+core@5.2.0_@lingui+babel-plugin-lingui-macro@5.2.0_babel-plugin-macros@3.1.
|
|
1032
|
+
// node_modules/.pnpm/@lingui+core@5.2.0_@lingui+babel-plugin-lingui-macro@5.2.0_babel-plugin-macros@3.1.0_ty_33a2537ce57a59324989ce8020998d0e/node_modules/@lingui/core/dist/index.mjs
|
|
1033
1033
|
var import_unraw = __toESM(require_dist(), 1);
|
|
1034
1034
|
|
|
1035
1035
|
// node_modules/.pnpm/@lingui+message-utils@5.2.0/node_modules/@lingui/message-utils/dist/compileMessage.mjs
|
|
@@ -1351,7 +1351,7 @@ Message: ${message}`);
|
|
|
1351
1351
|
}
|
|
1352
1352
|
}
|
|
1353
1353
|
|
|
1354
|
-
// node_modules/.pnpm/@lingui+core@5.2.0_@lingui+babel-plugin-lingui-macro@5.2.0_babel-plugin-macros@3.1.
|
|
1354
|
+
// node_modules/.pnpm/@lingui+core@5.2.0_@lingui+babel-plugin-lingui-macro@5.2.0_babel-plugin-macros@3.1.0_ty_33a2537ce57a59324989ce8020998d0e/node_modules/@lingui/core/dist/index.mjs
|
|
1355
1355
|
var isString = (s) => typeof s === "string";
|
|
1356
1356
|
var isFunction = (f) => typeof f === "function";
|
|
1357
1357
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -1759,7 +1759,292 @@ function setupI18n(params = {}) {
|
|
|
1759
1759
|
}
|
|
1760
1760
|
var i18n = setupI18n();
|
|
1761
1761
|
|
|
1762
|
-
// node_modules/.pnpm/@
|
|
1762
|
+
// node_modules/.pnpm/@open-wc+form-control@1.0.0/node_modules/@open-wc/form-control/src/FormControlMixin.js
|
|
1763
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
1764
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1765
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1766
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1767
|
+
};
|
|
1768
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
1769
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1770
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1771
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1772
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1773
|
+
};
|
|
1774
|
+
function FormControlMixin(SuperClass) {
|
|
1775
|
+
var _FormControl_instances, _FormControl_focused, _FormControl_forceError, _FormControl_touched, _FormControl_abortController, _FormControl_previousAbortController, _FormControl_awaitingValidationTarget, _FormControl_formValidationGroup_get, _FormControl_value, _FormControl_onFocus, _FormControl_onBlur, _FormControl_onInvalid, _FormControl_validationCompleteResolver, _FormControl_isValidationPending, _FormControl_validationComplete, _FormControl_shouldShowError, _FormControl_runValidators, _FormControl_setValidityWithOptionalTarget, _FormControl_getValidatorMessageForValue;
|
|
1776
|
+
class FormControl extends SuperClass {
|
|
1777
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1778
|
+
constructor(...args) {
|
|
1779
|
+
var _a, _b, _c;
|
|
1780
|
+
super(...args);
|
|
1781
|
+
_FormControl_instances.add(this);
|
|
1782
|
+
this.internals = this.attachInternals();
|
|
1783
|
+
_FormControl_focused.set(this, false);
|
|
1784
|
+
_FormControl_forceError.set(this, false);
|
|
1785
|
+
_FormControl_touched.set(this, false);
|
|
1786
|
+
_FormControl_abortController.set(this, void 0);
|
|
1787
|
+
_FormControl_previousAbortController.set(this, void 0);
|
|
1788
|
+
_FormControl_awaitingValidationTarget.set(this, true);
|
|
1789
|
+
_FormControl_value.set(this, "");
|
|
1790
|
+
_FormControl_onFocus.set(this, () => {
|
|
1791
|
+
__classPrivateFieldSet(this, _FormControl_touched, true, "f");
|
|
1792
|
+
__classPrivateFieldSet(this, _FormControl_focused, true, "f");
|
|
1793
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1794
|
+
});
|
|
1795
|
+
_FormControl_onBlur.set(this, () => {
|
|
1796
|
+
__classPrivateFieldSet(this, _FormControl_focused, false, "f");
|
|
1797
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_runValidators).call(this, this.shouldFormValueUpdate() ? __classPrivateFieldGet(this, _FormControl_value, "f") : "");
|
|
1798
|
+
if (!this.validity.valid && __classPrivateFieldGet(this, _FormControl_touched, "f")) {
|
|
1799
|
+
__classPrivateFieldSet(this, _FormControl_forceError, true, "f");
|
|
1800
|
+
}
|
|
1801
|
+
const showError = __classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1802
|
+
if (this.validationMessageCallback) {
|
|
1803
|
+
this.validationMessageCallback(showError ? this.internals.validationMessage : "");
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
_FormControl_onInvalid.set(this, () => {
|
|
1807
|
+
var _a2;
|
|
1808
|
+
if (__classPrivateFieldGet(this, _FormControl_awaitingValidationTarget, "f") && this.validationTarget) {
|
|
1809
|
+
this.internals.setValidity(this.validity, this.validationMessage, this.validationTarget);
|
|
1810
|
+
__classPrivateFieldSet(this, _FormControl_awaitingValidationTarget, false, "f");
|
|
1811
|
+
}
|
|
1812
|
+
__classPrivateFieldSet(this, _FormControl_touched, true, "f");
|
|
1813
|
+
__classPrivateFieldSet(this, _FormControl_forceError, true, "f");
|
|
1814
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1815
|
+
(_a2 = this === null || this === void 0 ? void 0 : this.validationMessageCallback) === null || _a2 === void 0 ? void 0 : _a2.call(this, this.showError ? this.internals.validationMessage : "");
|
|
1816
|
+
});
|
|
1817
|
+
_FormControl_validationCompleteResolver.set(this, void 0);
|
|
1818
|
+
_FormControl_isValidationPending.set(this, false);
|
|
1819
|
+
_FormControl_validationComplete.set(this, Promise.resolve());
|
|
1820
|
+
(_a = this.addEventListener) === null || _a === void 0 ? void 0 : _a.call(this, "focus", __classPrivateFieldGet(this, _FormControl_onFocus, "f"));
|
|
1821
|
+
(_b = this.addEventListener) === null || _b === void 0 ? void 0 : _b.call(this, "blur", __classPrivateFieldGet(this, _FormControl_onBlur, "f"));
|
|
1822
|
+
(_c = this.addEventListener) === null || _c === void 0 ? void 0 : _c.call(this, "invalid", __classPrivateFieldGet(this, _FormControl_onInvalid, "f"));
|
|
1823
|
+
this.setValue(null);
|
|
1824
|
+
}
|
|
1825
|
+
/** Wires up control instances to be form associated */
|
|
1826
|
+
static get formAssociated() {
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1829
|
+
static get validators() {
|
|
1830
|
+
return this.formControlValidators || [];
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Allows the FormControl instance to respond to Validator attributes.
|
|
1834
|
+
* For instance, if a given Validator has a `required` attribute, that
|
|
1835
|
+
* validator will be evaluated whenever the host's required attribute
|
|
1836
|
+
* is updated.
|
|
1837
|
+
*/
|
|
1838
|
+
static get observedAttributes() {
|
|
1839
|
+
const validatorAttributes = this.validators.map((validator) => validator.attribute).flat();
|
|
1840
|
+
const observedAttributes = super.observedAttributes || [];
|
|
1841
|
+
const attributeSet = /* @__PURE__ */ new Set([...observedAttributes, ...validatorAttributes]);
|
|
1842
|
+
return [...attributeSet];
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Return the validator associated with a given attribute. If no
|
|
1846
|
+
* Validator is associated with the attribute, it will return null.
|
|
1847
|
+
*/
|
|
1848
|
+
static getValidator(attribute) {
|
|
1849
|
+
return this.validators.find((validator) => validator.attribute === attribute) || null;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Get all validators that are set to react to a given attribute
|
|
1853
|
+
* @param {string} attribute - The attribute that has changed
|
|
1854
|
+
* @returns {Validator[]}
|
|
1855
|
+
*/
|
|
1856
|
+
static getValidators(attribute) {
|
|
1857
|
+
return this.validators.filter((validator) => {
|
|
1858
|
+
var _a;
|
|
1859
|
+
if (validator.attribute === attribute || ((_a = validator.attribute) === null || _a === void 0 ? void 0 : _a.includes(attribute))) {
|
|
1860
|
+
return true;
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
/** Return a reference to the control's form */
|
|
1865
|
+
get form() {
|
|
1866
|
+
return this.internals.form;
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Will return true if it is recommended that the control shows an internal
|
|
1870
|
+
* error. If using this property, it is wise to listen for 'invalid' events
|
|
1871
|
+
* on the element host and call preventDefault on the event. Doing this will
|
|
1872
|
+
* prevent browsers from showing a validation popup.
|
|
1873
|
+
*/
|
|
1874
|
+
get showError() {
|
|
1875
|
+
return __classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Forward the internals checkValidity method
|
|
1879
|
+
* will return the valid state of the control.
|
|
1880
|
+
*/
|
|
1881
|
+
checkValidity() {
|
|
1882
|
+
return this.internals.checkValidity();
|
|
1883
|
+
}
|
|
1884
|
+
/** The element's validity state */
|
|
1885
|
+
get validity() {
|
|
1886
|
+
return this.internals.validity;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* The validation message shown by a given Validator object. If the control
|
|
1890
|
+
* is in a valid state this should be falsy.
|
|
1891
|
+
*/
|
|
1892
|
+
get validationMessage() {
|
|
1893
|
+
return this.internals.validationMessage;
|
|
1894
|
+
}
|
|
1895
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
1896
|
+
var _a;
|
|
1897
|
+
(_a = super.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.call(this, name, oldValue, newValue);
|
|
1898
|
+
const proto = this.constructor;
|
|
1899
|
+
const validators = proto.getValidators(name);
|
|
1900
|
+
if ((validators === null || validators === void 0 ? void 0 : validators.length) && this.validationTarget) {
|
|
1901
|
+
this.setValue(__classPrivateFieldGet(this, _FormControl_value, "f"));
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
/** PUBLIC LIFECYCLE METHODS */
|
|
1905
|
+
/**
|
|
1906
|
+
* Sets the control's form value if the call to `shouldFormValueUpdate`
|
|
1907
|
+
* returns `true`.
|
|
1908
|
+
* @param value {FormValue} - The value to pass to the form
|
|
1909
|
+
*/
|
|
1910
|
+
setValue(value) {
|
|
1911
|
+
var _a;
|
|
1912
|
+
__classPrivateFieldSet(this, _FormControl_forceError, false, "f");
|
|
1913
|
+
(_a = this.validationMessageCallback) === null || _a === void 0 ? void 0 : _a.call(this, "");
|
|
1914
|
+
__classPrivateFieldSet(this, _FormControl_value, value, "f");
|
|
1915
|
+
const valueShouldUpdate = this.shouldFormValueUpdate();
|
|
1916
|
+
const valueToUpdate = valueShouldUpdate ? value : null;
|
|
1917
|
+
this.internals.setFormValue(valueToUpdate);
|
|
1918
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_runValidators).call(this, valueToUpdate);
|
|
1919
|
+
if (this.valueChangedCallback) {
|
|
1920
|
+
this.valueChangedCallback(valueToUpdate);
|
|
1921
|
+
}
|
|
1922
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1923
|
+
}
|
|
1924
|
+
/**
|
|
1925
|
+
* This method can be overridden to determine if the control's form value
|
|
1926
|
+
* should be set on a call to `setValue`. An example of when a user might want
|
|
1927
|
+
* to skip this step is when implementing checkbox-like behavior, first checking
|
|
1928
|
+
* to see if `this.checked` is set to a truthy value. By default this returns
|
|
1929
|
+
* `true`.
|
|
1930
|
+
*/
|
|
1931
|
+
shouldFormValueUpdate() {
|
|
1932
|
+
return true;
|
|
1933
|
+
}
|
|
1934
|
+
/** A promise that will resolve when all pending validations are complete */
|
|
1935
|
+
get validationComplete() {
|
|
1936
|
+
return new Promise((resolve) => resolve(__classPrivateFieldGet(this, _FormControl_validationComplete, "f")));
|
|
1937
|
+
}
|
|
1938
|
+
/** Reset control state when the form is reset */
|
|
1939
|
+
formResetCallback() {
|
|
1940
|
+
var _a, _b;
|
|
1941
|
+
__classPrivateFieldSet(this, _FormControl_touched, false, "f");
|
|
1942
|
+
__classPrivateFieldSet(this, _FormControl_forceError, false, "f");
|
|
1943
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this);
|
|
1944
|
+
(_a = this.resetFormControl) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1945
|
+
(_b = this.validationMessageCallback) === null || _b === void 0 ? void 0 : _b.call(this, __classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_shouldShowError).call(this) ? this.validationMessage : "");
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
_FormControl_focused = /* @__PURE__ */ new WeakMap(), _FormControl_forceError = /* @__PURE__ */ new WeakMap(), _FormControl_touched = /* @__PURE__ */ new WeakMap(), _FormControl_abortController = /* @__PURE__ */ new WeakMap(), _FormControl_previousAbortController = /* @__PURE__ */ new WeakMap(), _FormControl_awaitingValidationTarget = /* @__PURE__ */ new WeakMap(), _FormControl_value = /* @__PURE__ */ new WeakMap(), _FormControl_onFocus = /* @__PURE__ */ new WeakMap(), _FormControl_onBlur = /* @__PURE__ */ new WeakMap(), _FormControl_onInvalid = /* @__PURE__ */ new WeakMap(), _FormControl_validationCompleteResolver = /* @__PURE__ */ new WeakMap(), _FormControl_isValidationPending = /* @__PURE__ */ new WeakMap(), _FormControl_validationComplete = /* @__PURE__ */ new WeakMap(), _FormControl_instances = /* @__PURE__ */ new WeakSet(), _FormControl_formValidationGroup_get = function _FormControl_formValidationGroup_get2() {
|
|
1949
|
+
const rootNode = this.getRootNode();
|
|
1950
|
+
const selector = `${this.localName}[name="${this.getAttribute("name")}"]`;
|
|
1951
|
+
return rootNode.querySelectorAll(selector);
|
|
1952
|
+
}, _FormControl_shouldShowError = function _FormControl_shouldShowError2() {
|
|
1953
|
+
if (this.hasAttribute("disabled")) {
|
|
1954
|
+
return false;
|
|
1955
|
+
}
|
|
1956
|
+
const showError = __classPrivateFieldGet(this, _FormControl_forceError, "f") || __classPrivateFieldGet(this, _FormControl_touched, "f") && !this.validity.valid && !__classPrivateFieldGet(this, _FormControl_focused, "f");
|
|
1957
|
+
if (showError && this.internals.states) {
|
|
1958
|
+
this.internals.states.add("--show-error");
|
|
1959
|
+
} else if (this.internals.states) {
|
|
1960
|
+
this.internals.states.delete("--show-error");
|
|
1961
|
+
}
|
|
1962
|
+
return showError;
|
|
1963
|
+
}, _FormControl_runValidators = function _FormControl_runValidators2(value) {
|
|
1964
|
+
const proto = this.constructor;
|
|
1965
|
+
const validity = {};
|
|
1966
|
+
const validators = proto.validators;
|
|
1967
|
+
const asyncValidators = [];
|
|
1968
|
+
const hasAsyncValidators = validators.some((validator) => validator.isValid instanceof Promise);
|
|
1969
|
+
if (!__classPrivateFieldGet(this, _FormControl_isValidationPending, "f")) {
|
|
1970
|
+
__classPrivateFieldSet(this, _FormControl_validationComplete, new Promise((resolve) => {
|
|
1971
|
+
__classPrivateFieldSet(this, _FormControl_validationCompleteResolver, resolve, "f");
|
|
1972
|
+
}), "f");
|
|
1973
|
+
__classPrivateFieldSet(this, _FormControl_isValidationPending, true, "f");
|
|
1974
|
+
}
|
|
1975
|
+
if (__classPrivateFieldGet(this, _FormControl_abortController, "f")) {
|
|
1976
|
+
__classPrivateFieldGet(this, _FormControl_abortController, "f").abort();
|
|
1977
|
+
__classPrivateFieldSet(this, _FormControl_previousAbortController, __classPrivateFieldGet(this, _FormControl_abortController, "f"), "f");
|
|
1978
|
+
}
|
|
1979
|
+
const abortController = new AbortController();
|
|
1980
|
+
__classPrivateFieldSet(this, _FormControl_abortController, abortController, "f");
|
|
1981
|
+
let validationMessage = void 0;
|
|
1982
|
+
let hasChange = false;
|
|
1983
|
+
if (!validators.length) {
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
validators.forEach((validator) => {
|
|
1987
|
+
const key = validator.key || "customError";
|
|
1988
|
+
const isValid = validator.isValid(this, value, abortController.signal);
|
|
1989
|
+
const isAsyncValidator = isValid instanceof Promise;
|
|
1990
|
+
if (isAsyncValidator) {
|
|
1991
|
+
asyncValidators.push(isValid);
|
|
1992
|
+
isValid.then((isValidatorValid) => {
|
|
1993
|
+
if (isValidatorValid === void 0 || isValidatorValid === null) {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
validity[key] = !isValidatorValid;
|
|
1997
|
+
validationMessage = __classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_getValidatorMessageForValue).call(this, validator, value);
|
|
1998
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_setValidityWithOptionalTarget).call(this, validity, validationMessage);
|
|
1999
|
+
});
|
|
2000
|
+
} else {
|
|
2001
|
+
validity[key] = !isValid;
|
|
2002
|
+
if (this.validity[key] !== !isValid) {
|
|
2003
|
+
hasChange = true;
|
|
2004
|
+
}
|
|
2005
|
+
if (!isValid && !validationMessage) {
|
|
2006
|
+
validationMessage = __classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_getValidatorMessageForValue).call(this, validator, value);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
Promise.allSettled(asyncValidators).then(() => {
|
|
2011
|
+
var _a;
|
|
2012
|
+
if (!(abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted)) {
|
|
2013
|
+
__classPrivateFieldSet(this, _FormControl_isValidationPending, false, "f");
|
|
2014
|
+
(_a = __classPrivateFieldGet(this, _FormControl_validationCompleteResolver, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2015
|
+
}
|
|
2016
|
+
});
|
|
2017
|
+
if (hasChange || !hasAsyncValidators) {
|
|
2018
|
+
__classPrivateFieldGet(this, _FormControl_instances, "m", _FormControl_setValidityWithOptionalTarget).call(this, validity, validationMessage);
|
|
2019
|
+
}
|
|
2020
|
+
}, _FormControl_setValidityWithOptionalTarget = function _FormControl_setValidityWithOptionalTarget2(validity, validationMessage) {
|
|
2021
|
+
if (this.validationTarget) {
|
|
2022
|
+
this.internals.setValidity(validity, validationMessage, this.validationTarget);
|
|
2023
|
+
__classPrivateFieldSet(this, _FormControl_awaitingValidationTarget, false, "f");
|
|
2024
|
+
} else {
|
|
2025
|
+
this.internals.setValidity(validity, validationMessage);
|
|
2026
|
+
if (this.internals.validity.valid) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
__classPrivateFieldSet(this, _FormControl_awaitingValidationTarget, true, "f");
|
|
2030
|
+
}
|
|
2031
|
+
}, _FormControl_getValidatorMessageForValue = function _FormControl_getValidatorMessageForValue2(validator, value) {
|
|
2032
|
+
if (this.validityCallback) {
|
|
2033
|
+
const message = this.validityCallback(validator.key || "customError");
|
|
2034
|
+
if (message) {
|
|
2035
|
+
return message;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if (validator.message instanceof Function) {
|
|
2039
|
+
return validator.message(this, value);
|
|
2040
|
+
} else {
|
|
2041
|
+
return validator.message;
|
|
2042
|
+
}
|
|
2043
|
+
};
|
|
2044
|
+
return FormControl;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
// node_modules/.pnpm/@warp-ds+css@2.1.1_@warp-ds+uno@2.1.0_unocss@0.62.0_postcss@8.5.1_rollup@4.32.1_vite@5._43dfacbc4a7d78ad84ef685a7085e344/node_modules/@warp-ds/css/component-classes/index.js
|
|
1763
2048
|
var buttonDefaultStyling = "font-bold focusable justify-center transition-colors ease-in-out";
|
|
1764
2049
|
var buttonColors = {
|
|
1765
2050
|
primary: "s-text-inverted bg-[--w-color-button-primary-background] hover:bg-[--w-color-button-primary-background-hover] active:bg-[--w-color-button-primary-background-active]",
|
|
@@ -2060,7 +2345,12 @@ var messages5 = JSON.parse('{"button.aria.loading":["Laddar ..."]}');
|
|
|
2060
2345
|
|
|
2061
2346
|
// packages/button/index.js
|
|
2062
2347
|
var buttonTypes2 = ["primary", "secondary", "negative", "utility", "pill", "link"];
|
|
2063
|
-
var WarpButton = class extends kebabCaseAttributes(WarpElement) {
|
|
2348
|
+
var WarpButton = class extends FormControlMixin(kebabCaseAttributes(WarpElement)) {
|
|
2349
|
+
updated(changedProperties) {
|
|
2350
|
+
if (changedProperties.has("value")) {
|
|
2351
|
+
this.setValue(this.value);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2064
2354
|
constructor() {
|
|
2065
2355
|
super();
|
|
2066
2356
|
activateI18n(messages2, messages4, messages3, messages, messages5);
|
|
@@ -2144,6 +2434,10 @@ ${buttonTypes2.join(", ")}.`);
|
|
|
2144
2434
|
this.fullWidth ? button.fullWidth : button.contentWidth
|
|
2145
2435
|
]);
|
|
2146
2436
|
}
|
|
2437
|
+
_handleButtonClick() {
|
|
2438
|
+
if (this.type === "submit") this.internals.form.requestSubmit();
|
|
2439
|
+
else if (this.type === "reset") this.internals.form.reset();
|
|
2440
|
+
}
|
|
2147
2441
|
render() {
|
|
2148
2442
|
return html` ${this.href ? html`<a
|
|
2149
2443
|
href=${this.href}
|
|
@@ -2151,7 +2445,7 @@ ${buttonTypes2.join(", ")}.`);
|
|
|
2151
2445
|
rel=${this.target === "_blank" ? this.rel || "noopener" : void 0}
|
|
2152
2446
|
class=${this._classes}>
|
|
2153
2447
|
<slot></slot>
|
|
2154
|
-
</a>` : html`<button type=${this.type || "button"} class=${this._classes}>
|
|
2448
|
+
</a>` : html`<button type=${this.type || "button"} class=${this._classes} @click="${this._handleButtonClick}">
|
|
2155
2449
|
<slot></slot>
|
|
2156
2450
|
</button>`}
|
|
2157
2451
|
${this.loading ? html`<span class="sr-only" role="progressbar" aria-valuenow="{0}" aria-valuetext=${this.ariaValueTextLoading}></span>` : null}`;
|
|
@@ -2171,7 +2465,9 @@ __publicField(WarpButton, "properties", {
|
|
|
2171
2465
|
target: { type: String, reflect: true },
|
|
2172
2466
|
rel: { type: String, reflect: true },
|
|
2173
2467
|
fullWidth: { type: Boolean, reflect: true },
|
|
2174
|
-
buttonClass: { type: String, reflect: true }
|
|
2468
|
+
buttonClass: { type: String, reflect: true },
|
|
2469
|
+
name: { type: String, reflect: true },
|
|
2470
|
+
value: { type: String, reflect: true }
|
|
2175
2471
|
});
|
|
2176
2472
|
__publicField(WarpButton, "styles", [WarpElement.styles]);
|
|
2177
2473
|
if (!customElements.get("w-button")) {
|