@proximus/lavender-phone-number 1.4.14-beta.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/PhoneNumber.d.ts +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +99 -0
- package/package.json +23 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PxElement } from '@proximus/lavender-common';
|
|
2
|
+
import '@proximus/lavender-layout';
|
|
3
|
+
import '@proximus/lavender-fieldset';
|
|
4
|
+
export declare class PhoneNumber extends PxElement<HTMLElement> {
|
|
5
|
+
static nativeName: string;
|
|
6
|
+
template: () => string;
|
|
7
|
+
private fieldStateObserver?;
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
static get observedAttributes(): string[];
|
|
12
|
+
attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
|
|
13
|
+
setupErrorState(): void;
|
|
14
|
+
projectSlot(field: HTMLElement, slotName: 'helper' | 'status-text', source: Element | null): void;
|
|
15
|
+
applyHiddenLabel(): void;
|
|
16
|
+
get $fieldset(): Element;
|
|
17
|
+
get $slottedHelper(): HTMLElement | null;
|
|
18
|
+
get $slotStateText(): HTMLSlotElement | null;
|
|
19
|
+
get $slotHelper(): HTMLSlotElement | null;
|
|
20
|
+
get $slotSelect(): HTMLSlotElement | null;
|
|
21
|
+
get $slotInput(): HTMLSlotElement | null;
|
|
22
|
+
get $slottedSelect(): HTMLElement | null;
|
|
23
|
+
get $slottedInput(): HTMLElement | null;
|
|
24
|
+
get $slottedSelectLabel(): HTMLElement | null;
|
|
25
|
+
get $slottedInputLabel(): HTMLElement | null;
|
|
26
|
+
get state(): string;
|
|
27
|
+
set state(value: string | null);
|
|
28
|
+
get inverted(): boolean;
|
|
29
|
+
set inverted(value: string | null);
|
|
30
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PhoneNumber';
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { PxElement as e, log as t } from "@proximus/lavender-common";
|
|
2
|
+
import "@proximus/lavender-layout";
|
|
3
|
+
import "@proximus/lavender-fieldset";
|
|
4
|
+
//#region src/phone-number.css?inline
|
|
5
|
+
var n = ":host{display:block}:host *{box-sizing:border-box}::slotted([slot=label]){font-family:var(--px-font-family);font-size:var(--px-text-size-label-m-mobile);font-weight:var(--px-font-weight-body);line-height:var(--px-line-height-ratio-l);text-align:left;color:var(--px-color-text-neutral-default);margin-bottom:var(--px-spacing-2xs-mobile);display:block}@media screen and (width>=48rem){::slotted([slot=label]){font-size:var(--px-text-size-label-m-tablet);margin-bottom:var(--px-spacing-2xs-tablet)}}@media screen and (width>=64.0625rem){::slotted([slot=label]){font-size:var(--px-text-size-label-m-laptop);margin-bottom:var(--px-spacing-2xs-laptop)}}@media screen and (width>=90.0625rem){::slotted([slot=label]){font-size:var(--px-text-size-label-m-desktop);margin-bottom:var(--px-spacing-2xs-desktop)}}", r = new CSSStyleSheet();
|
|
6
|
+
r.replaceSync(n);
|
|
7
|
+
var i = class extends e {
|
|
8
|
+
static {
|
|
9
|
+
this.nativeName = "div";
|
|
10
|
+
}
|
|
11
|
+
constructor() {
|
|
12
|
+
super(r), this.template = () => "<px-fieldset>\n <slot name=\"label\" slot=\"legend\"></slot>\n <slot name=\"helper\" slot=\"helper\"></slot>\n <slot name=\"state-text\" slot=\"error-text\"></slot>\n <px-hstack gap=\"xs\">\n <slot name=\"select\"></slot>\n <slot name=\"input\"></slot>\n </px-hstack>\n </px-fieldset>", this.shadowRoot.innerHTML = this.template();
|
|
13
|
+
}
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.$slotSelect?.addEventListener("slotchange", () => this.setupErrorState()), this.$slotInput?.addEventListener("slotchange", () => this.setupErrorState()), this.$slotHelper?.addEventListener("slotchange", () => this.setupErrorState()), this.fieldStateObserver = new MutationObserver(() => this.setupErrorState()), this.fieldStateObserver.observe(this, {
|
|
16
|
+
subtree: !0,
|
|
17
|
+
attributes: !0,
|
|
18
|
+
attributeFilter: ["state"]
|
|
19
|
+
}), this.setupErrorState();
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
this.fieldStateObserver?.disconnect();
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return [...super.observedAttributes, "state"];
|
|
26
|
+
}
|
|
27
|
+
attributeChangedCallback(e, t, n) {
|
|
28
|
+
if (t !== n) switch (e) {
|
|
29
|
+
case "state":
|
|
30
|
+
this.setupErrorState();
|
|
31
|
+
break;
|
|
32
|
+
default: super.attributeChangedCallback(e, t, n);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setupErrorState() {
|
|
36
|
+
this.applyHiddenLabel();
|
|
37
|
+
let e = this.$slotStateText?.assignedElements()[0] ?? null, n = this.state === "error" && !!e;
|
|
38
|
+
this.state === "error" && !e && t("<px-fieldset> with state=\"error\" requires a slot=\"error-text\" containing the error description."), n ? this.$fieldset.setAttribute("state", "error") : this.$fieldset.removeAttribute("state"), [this.$slottedSelect, this.$slottedInput].forEach((t) => {
|
|
39
|
+
if (!t) return;
|
|
40
|
+
this.projectSlot(t, "helper", this.$slottedHelper);
|
|
41
|
+
let r = n && t.getAttribute("state") === "error";
|
|
42
|
+
this.projectSlot(t, "status-text", r ? e : null);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
projectSlot(e, t, n) {
|
|
46
|
+
let r = `data-px-projected-${t}`;
|
|
47
|
+
if (e.querySelector(`[${r}]`)?.remove(), !n) return;
|
|
48
|
+
let i = n.cloneNode(!0);
|
|
49
|
+
i.setAttribute("slot", t), i.setAttribute("shown--sr", ""), i.setAttribute(r, ""), e.appendChild(i);
|
|
50
|
+
}
|
|
51
|
+
applyHiddenLabel() {
|
|
52
|
+
this.$slottedSelect?.setAttribute("hidden-label", ""), this.$slottedInput?.setAttribute("hidden-label", ""), this.$slottedSelectLabel?.setAttribute("shown--sr", ""), this.$slottedInputLabel?.setAttribute("shown--sr", "");
|
|
53
|
+
}
|
|
54
|
+
get $fieldset() {
|
|
55
|
+
return this.shadowRoot.querySelector("px-fieldset");
|
|
56
|
+
}
|
|
57
|
+
get $slottedHelper() {
|
|
58
|
+
return this.querySelector("[slot=\"helper\"]");
|
|
59
|
+
}
|
|
60
|
+
get $slotStateText() {
|
|
61
|
+
return this.shadowRoot.querySelector("slot[name=\"state-text\"]");
|
|
62
|
+
}
|
|
63
|
+
get $slotHelper() {
|
|
64
|
+
return this.shadowRoot.querySelector("slot[name=\"helper\"]");
|
|
65
|
+
}
|
|
66
|
+
get $slotSelect() {
|
|
67
|
+
return this.shadowRoot.querySelector("slot[name=\"select\"]");
|
|
68
|
+
}
|
|
69
|
+
get $slotInput() {
|
|
70
|
+
return this.shadowRoot.querySelector("slot[name=\"input\"]");
|
|
71
|
+
}
|
|
72
|
+
get $slottedSelect() {
|
|
73
|
+
return this.querySelector("[slot=\"select\"]");
|
|
74
|
+
}
|
|
75
|
+
get $slottedInput() {
|
|
76
|
+
return this.querySelector("[slot=\"input\"]");
|
|
77
|
+
}
|
|
78
|
+
get $slottedSelectLabel() {
|
|
79
|
+
return this.$slottedSelect?.querySelector("[slot=\"label\"]");
|
|
80
|
+
}
|
|
81
|
+
get $slottedInputLabel() {
|
|
82
|
+
return this.$slottedInput?.querySelector("[slot=\"label\"]");
|
|
83
|
+
}
|
|
84
|
+
get state() {
|
|
85
|
+
return this.getAttribute("state") || "";
|
|
86
|
+
}
|
|
87
|
+
set state(e) {
|
|
88
|
+
super._updateAttribute("state", e);
|
|
89
|
+
}
|
|
90
|
+
get inverted() {
|
|
91
|
+
return this.hasAttribute("inverted");
|
|
92
|
+
}
|
|
93
|
+
set inverted(e) {
|
|
94
|
+
super._updateAttribute("inverted", e);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
customElements.get("px-phone-number") || customElements.define("px-phone-number", i);
|
|
98
|
+
//#endregion
|
|
99
|
+
export { i as PhoneNumber };
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-phone-number",
|
|
3
|
+
"version": "1.4.14-beta.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.es.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
|
|
15
|
+
"test": "vitest run --coverage",
|
|
16
|
+
"wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"customElements": "dist/custom-elements.json",
|
|
22
|
+
"web-types": "./dist/web-types.json"
|
|
23
|
+
}
|