@solid-design-system/components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/README.md +15 -0
- package/dist/components/es/button.js +125 -0
- package/dist/components/es/classix.js +1 -0
- package/dist/components/es/component.styles.js +1 -0
- package/dist/components/es/icon.js +17 -0
- package/dist/components/es/if-defined.js +11 -0
- package/dist/components/es/include.js +1 -0
- package/dist/components/es/include.styles.js +1 -0
- package/dist/components/es/library.js +1 -0
- package/dist/components/es/library.system.js +1 -0
- package/dist/components/es/link.js +1 -0
- package/dist/components/es/lit-element.js +23 -0
- package/dist/components/es/request.js +1 -0
- package/dist/components/es/request2.js +1 -0
- package/dist/components/es/solid-components.js +1 -0
- package/dist/components/es/solid-element.js +21 -0
- package/dist/components/es/spinner.js +1 -0
- package/dist/components/es/state.js +6 -0
- package/dist/components/es/watch.js +1 -0
- package/dist/components/umd/solid-components.js +200 -0
- package/dist/custom-elements.json +1 -0
- package/dist/package/components/button/button.d.ts +48 -0
- package/dist/package/components/button/button.js +391 -0
- package/dist/package/components/icon/icon.d.ts +22 -0
- package/dist/package/components/icon/icon.js +129 -0
- package/dist/package/components/icon/library.d.ts +16 -0
- package/dist/package/components/icon/library.js +17 -0
- package/dist/package/components/icon/library.system.d.ts +7 -0
- package/dist/package/components/icon/library.system.js +26 -0
- package/dist/package/components/icon/request.d.ts +11 -0
- package/dist/package/components/icon/request.js +24 -0
- package/dist/package/components/include/include.d.ts +16 -0
- package/dist/package/components/include/include.js +72 -0
- package/dist/package/components/include/include.styles.d.ts +2 -0
- package/dist/package/components/include/include.styles.js +6 -0
- package/dist/package/components/include/request.d.ts +7 -0
- package/dist/package/components/include/request.js +18 -0
- package/dist/package/components/link/link.d.ts +22 -0
- package/dist/package/components/link/link.js +107 -0
- package/dist/package/components/spinner/spinner.d.ts +12 -0
- package/dist/package/components/spinner/spinner.js +46 -0
- package/dist/package/internal/form.d.ts +35 -0
- package/dist/package/internal/form.js +212 -0
- package/dist/package/internal/slot.d.ts +14 -0
- package/dist/package/internal/slot.js +47 -0
- package/dist/package/internal/solid-element.d.ts +26 -0
- package/dist/package/internal/solid-element.js +38 -0
- package/dist/package/internal/watch.d.ts +11 -0
- package/dist/package/internal/watch.js +28 -0
- package/dist/package/node_modules/.pnpm/@shoelace-style_localize@3.1.0/node_modules/@shoelace-style/localize/dist/index.js +103 -0
- package/dist/package/solid-components.d.ts +6 -0
- package/dist/package/solid-components.js +14 -0
- package/dist/package/styles/component.styles.d.ts +2 -0
- package/dist/package/styles/component.styles.js +5 -0
- package/dist/package/styles/tailwind.css.js +4 -0
- package/dist/package/translations/en.d.ts +3 -0
- package/dist/package/translations/en.js +31 -0
- package/dist/package/utilities/localize.d.ts +25 -0
- package/dist/package/utilities/localize.js +7 -0
- package/dist/versioned-components/es/button.js +125 -0
- package/dist/versioned-components/es/classix.js +1 -0
- package/dist/versioned-components/es/component.styles.js +1 -0
- package/dist/versioned-components/es/icon.js +17 -0
- package/dist/versioned-components/es/if-defined.js +11 -0
- package/dist/versioned-components/es/include.js +1 -0
- package/dist/versioned-components/es/include.styles.js +1 -0
- package/dist/versioned-components/es/library.js +1 -0
- package/dist/versioned-components/es/library.system.js +1 -0
- package/dist/versioned-components/es/link.js +1 -0
- package/dist/versioned-components/es/lit-element.js +23 -0
- package/dist/versioned-components/es/request.js +1 -0
- package/dist/versioned-components/es/request2.js +1 -0
- package/dist/versioned-components/es/solid-components.js +1 -0
- package/dist/versioned-components/es/solid-element.js +21 -0
- package/dist/versioned-components/es/spinner.js +1 -0
- package/dist/versioned-components/es/state.js +6 -0
- package/dist/versioned-components/es/watch.js +1 -0
- package/dist/versioned-package/components/button/button.d.ts +48 -0
- package/dist/versioned-package/components/button/button.js +391 -0
- package/dist/versioned-package/components/icon/icon.d.ts +22 -0
- package/dist/versioned-package/components/icon/icon.js +129 -0
- package/dist/versioned-package/components/icon/library.d.ts +16 -0
- package/dist/versioned-package/components/icon/library.js +17 -0
- package/dist/versioned-package/components/icon/library.system.d.ts +7 -0
- package/dist/versioned-package/components/icon/library.system.js +26 -0
- package/dist/versioned-package/components/icon/request.d.ts +11 -0
- package/dist/versioned-package/components/icon/request.js +24 -0
- package/dist/versioned-package/components/include/include.d.ts +16 -0
- package/dist/versioned-package/components/include/include.js +72 -0
- package/dist/versioned-package/components/include/include.styles.d.ts +2 -0
- package/dist/versioned-package/components/include/include.styles.js +6 -0
- package/dist/versioned-package/components/include/request.d.ts +7 -0
- package/dist/versioned-package/components/include/request.js +18 -0
- package/dist/versioned-package/components/link/link.d.ts +22 -0
- package/dist/versioned-package/components/link/link.js +107 -0
- package/dist/versioned-package/components/spinner/spinner.d.ts +12 -0
- package/dist/versioned-package/components/spinner/spinner.js +46 -0
- package/dist/versioned-package/internal/form.d.ts +35 -0
- package/dist/versioned-package/internal/form.js +212 -0
- package/dist/versioned-package/internal/slot.d.ts +14 -0
- package/dist/versioned-package/internal/slot.js +47 -0
- package/dist/versioned-package/internal/solid-element.d.ts +26 -0
- package/dist/versioned-package/internal/solid-element.js +38 -0
- package/dist/versioned-package/internal/watch.d.ts +11 -0
- package/dist/versioned-package/internal/watch.js +28 -0
- package/dist/versioned-package/node_modules/.pnpm/@shoelace-style_localize@3.1.0/node_modules/@shoelace-style/localize/dist/index.js +103 -0
- package/dist/versioned-package/solid-components.d.ts +6 -0
- package/dist/versioned-package/solid-components.js +14 -0
- package/dist/versioned-package/styles/component.styles.d.ts +2 -0
- package/dist/versioned-package/styles/component.styles.js +5 -0
- package/dist/versioned-package/styles/tailwind.css.js +4 -0
- package/dist/versioned-package/translations/en.d.ts +3 -0
- package/dist/versioned-package/translations/en.js +31 -0
- package/dist/versioned-package/utilities/localize.d.ts +25 -0
- package/dist/versioned-package/utilities/localize.js +7 -0
- package/dist/vscode.html-custom-data.json +661 -0
- package/dist/web-types.json +1449 -0
- package/package.json +185 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type SdIcon from '../icon/icon';
|
|
2
|
+
export type IconLibraryResolver = (name: string) => string;
|
|
3
|
+
export type IconLibraryMutator = (svg: SVGElement) => void;
|
|
4
|
+
export interface IconLibrary {
|
|
5
|
+
name: string;
|
|
6
|
+
resolver: IconLibraryResolver;
|
|
7
|
+
mutator?: IconLibraryMutator;
|
|
8
|
+
}
|
|
9
|
+
export declare function watchIcon(icon: SdIcon): void;
|
|
10
|
+
export declare function unwatchIcon(icon: SdIcon): void;
|
|
11
|
+
export declare function getIconLibrary(name?: string): IconLibrary | undefined;
|
|
12
|
+
export declare function registerIconLibrary(name: string, options: {
|
|
13
|
+
resolver: IconLibraryResolver;
|
|
14
|
+
mutator?: IconLibraryMutator;
|
|
15
|
+
}): void;
|
|
16
|
+
export declare function unregisterIconLibrary(name: string): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import systemLibrary from "./library.system.js";
|
|
2
|
+
let registry = [systemLibrary];
|
|
3
|
+
let watchedIcons = [];
|
|
4
|
+
function watchIcon(icon) {
|
|
5
|
+
watchedIcons.push(icon);
|
|
6
|
+
}
|
|
7
|
+
function unwatchIcon(icon) {
|
|
8
|
+
watchedIcons = watchedIcons.filter((el) => el !== icon);
|
|
9
|
+
}
|
|
10
|
+
function getIconLibrary(name) {
|
|
11
|
+
return registry.find((lib) => lib.name === name);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
getIconLibrary,
|
|
15
|
+
unwatchIcon,
|
|
16
|
+
watchIcon
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const icons = {
|
|
2
|
+
"chevron-down": `
|
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
4
|
+
<path d="M20.257 6.333l-8.257 9.173-8.257-9.173c-0.181-0.181-0.431-0.292-0.707-0.292-0.552 0-1 0.448-1 1 0 0.238 0.083 0.456 0.222 0.628l-0.001-0.002 9 10c0.184 0.204 0.449 0.331 0.743 0.331s0.56-0.127 0.743-0.33l0.001-0.001 9-10c0.137-0.17 0.22-0.388 0.22-0.626 0-0.552-0.448-1-1-1-0.276 0-0.526 0.112-0.707 0.293v0z"></path>
|
|
5
|
+
</svg>
|
|
6
|
+
`,
|
|
7
|
+
"chevron-up": `
|
|
8
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
9
|
+
<path d="M12.743 6.333c-0.188-0.195-0.452-0.316-0.743-0.316s-0.555 0.121-0.743 0.315l-0 0-9 10c-0.137 0.17-0.22 0.388-0.22 0.626 0 0.552 0.448 1 1 1 0.276 0 0.526-0.112 0.707-0.293v0l8.257-9.173 8.257 9.173c0.181 0.181 0.431 0.292 0.707 0.292 0.552 0 1-0.448 1-1 0-0.238-0.083-0.456-0.222-0.628l0.001 0.002z"></path>
|
|
10
|
+
</svg>
|
|
11
|
+
`
|
|
12
|
+
};
|
|
13
|
+
const systemLibrary = {
|
|
14
|
+
name: "system",
|
|
15
|
+
resolver: (name) => {
|
|
16
|
+
if (name in icons) {
|
|
17
|
+
return `data:image/svg+xml,${encodeURIComponent(icons[name])}`;
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
},
|
|
21
|
+
mutator: (svg) => svg.setAttribute("fill", "currentColor")
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
systemLibrary as default,
|
|
25
|
+
icons
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { requestInclude } from "../include/request.js";
|
|
2
|
+
const iconFiles = /* @__PURE__ */ new Map();
|
|
3
|
+
async function requestIcon(url) {
|
|
4
|
+
if (iconFiles.has(url)) {
|
|
5
|
+
return iconFiles.get(url);
|
|
6
|
+
}
|
|
7
|
+
const fileData = await requestInclude(url);
|
|
8
|
+
const iconFileData = {
|
|
9
|
+
ok: fileData.ok,
|
|
10
|
+
status: fileData.status,
|
|
11
|
+
svg: null
|
|
12
|
+
};
|
|
13
|
+
if (fileData.ok) {
|
|
14
|
+
const div = document.createElement("div");
|
|
15
|
+
div.innerHTML = fileData.html;
|
|
16
|
+
const svg = div.firstElementChild;
|
|
17
|
+
iconFileData.svg = (svg == null ? void 0 : svg.tagName.toLowerCase()) === "svg" ? svg.outerHTML : "";
|
|
18
|
+
}
|
|
19
|
+
iconFiles.set(url, iconFileData);
|
|
20
|
+
return iconFileData;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
requestIcon
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
import type { CSSResultGroup } from 'lit';
|
|
3
|
+
export default class SdInclude extends SolidElement {
|
|
4
|
+
static styles: CSSResultGroup;
|
|
5
|
+
src: string;
|
|
6
|
+
mode: 'cors' | 'no-cors' | 'same-origin';
|
|
7
|
+
allowScripts: boolean;
|
|
8
|
+
private executeScript;
|
|
9
|
+
handleSrcChange(): Promise<void>;
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'sd-1-0-0-include': SdInclude;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { property, customElement } from "lit/decorators.js";
|
|
2
|
+
import { html } from "lit";
|
|
3
|
+
import { requestInclude } from "./request.js";
|
|
4
|
+
import { watch } from "../../internal/watch.js";
|
|
5
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
6
|
+
import styles from "./include.styles.js";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result)
|
|
15
|
+
__defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
let SdInclude = class extends SolidElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.mode = "cors";
|
|
22
|
+
this.allowScripts = false;
|
|
23
|
+
}
|
|
24
|
+
executeScript(script) {
|
|
25
|
+
const newScript = document.createElement("script");
|
|
26
|
+
[...script.attributes].forEach((attr) => newScript.setAttribute(attr.name, attr.value));
|
|
27
|
+
newScript.textContent = script.textContent;
|
|
28
|
+
script.parentNode.replaceChild(newScript, script);
|
|
29
|
+
}
|
|
30
|
+
async handleSrcChange() {
|
|
31
|
+
try {
|
|
32
|
+
const src = this.src;
|
|
33
|
+
const file = await requestInclude(src, this.mode);
|
|
34
|
+
if (src !== this.src) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!file.ok) {
|
|
38
|
+
this.emit("sd-error", { detail: { status: file.status } });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.innerHTML = file.html;
|
|
42
|
+
if (this.allowScripts) {
|
|
43
|
+
[...this.querySelectorAll("script")].forEach((script) => this.executeScript(script));
|
|
44
|
+
}
|
|
45
|
+
this.emit("sd-load");
|
|
46
|
+
} catch {
|
|
47
|
+
this.emit("sd-error", { detail: { status: -1 } });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
return html`<slot></slot>`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
SdInclude.styles = styles;
|
|
55
|
+
__decorateClass([
|
|
56
|
+
property()
|
|
57
|
+
], SdInclude.prototype, "src", 2);
|
|
58
|
+
__decorateClass([
|
|
59
|
+
property()
|
|
60
|
+
], SdInclude.prototype, "mode", 2);
|
|
61
|
+
__decorateClass([
|
|
62
|
+
property({ attribute: "allow-scripts", type: Boolean })
|
|
63
|
+
], SdInclude.prototype, "allowScripts", 2);
|
|
64
|
+
__decorateClass([
|
|
65
|
+
watch("src")
|
|
66
|
+
], SdInclude.prototype, "handleSrcChange", 1);
|
|
67
|
+
SdInclude = __decorateClass([
|
|
68
|
+
customElement("sd-1-0-0-include")
|
|
69
|
+
], SdInclude);
|
|
70
|
+
export {
|
|
71
|
+
SdInclude as default
|
|
72
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const includeFiles = /* @__PURE__ */ new Map();
|
|
2
|
+
function requestInclude(src, mode = "cors") {
|
|
3
|
+
if (includeFiles.has(src)) {
|
|
4
|
+
return includeFiles.get(src);
|
|
5
|
+
}
|
|
6
|
+
const fileDataPromise = fetch(src, { mode }).then(async (response) => {
|
|
7
|
+
return {
|
|
8
|
+
ok: response.ok,
|
|
9
|
+
status: response.status,
|
|
10
|
+
html: await response.text()
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
includeFiles.set(src, fileDataPromise);
|
|
14
|
+
return fileDataPromise;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
requestInclude
|
|
18
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
export default class SdLink extends SolidElement {
|
|
3
|
+
private readonly hasSlotController;
|
|
4
|
+
button: HTMLButtonElement | HTMLLinkElement;
|
|
5
|
+
size: 'inherit' | 'lg' | 'sm';
|
|
6
|
+
inverted: boolean;
|
|
7
|
+
standalone: boolean;
|
|
8
|
+
href: string;
|
|
9
|
+
target: '_blank' | '_parent' | '_self' | '_top';
|
|
10
|
+
download?: string;
|
|
11
|
+
private handleBlur;
|
|
12
|
+
private handleFocus;
|
|
13
|
+
focus(options?: FocusOptions): void;
|
|
14
|
+
blur(): void;
|
|
15
|
+
render(): import("lit").TemplateResult<1>;
|
|
16
|
+
static styles: import("lit").CSSResultGroup[];
|
|
17
|
+
}
|
|
18
|
+
declare global {
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'sd-1-0-0-link': SdLink;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { query, property, customElement } from "lit/decorators.js";
|
|
3
|
+
import { HasSlotController } from "../../internal/slot.js";
|
|
4
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
5
|
+
import cx from "classix";
|
|
6
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result)
|
|
15
|
+
__defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
let SdLink = class extends SolidElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.hasSlotController = new HasSlotController(this, "[default]", "icon-left", "icon-right");
|
|
22
|
+
this.size = "inherit";
|
|
23
|
+
this.inverted = false;
|
|
24
|
+
this.standalone = false;
|
|
25
|
+
this.href = "";
|
|
26
|
+
}
|
|
27
|
+
handleBlur() {
|
|
28
|
+
this.emit("sd-blur");
|
|
29
|
+
}
|
|
30
|
+
handleFocus() {
|
|
31
|
+
this.emit("sd-focus");
|
|
32
|
+
}
|
|
33
|
+
/** Sets focus on the button. */
|
|
34
|
+
focus(options) {
|
|
35
|
+
this.button.focus(options);
|
|
36
|
+
}
|
|
37
|
+
/** Removes focus from the button. */
|
|
38
|
+
blur() {
|
|
39
|
+
this.button.blur();
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const slots = {
|
|
43
|
+
label: this.hasSlotController.test("[default]"),
|
|
44
|
+
"icon-left": this.hasSlotController.test("icon-left"),
|
|
45
|
+
"icon-right": this.hasSlotController.test("icon-right")
|
|
46
|
+
};
|
|
47
|
+
return html`<a part="base" class="${cx(
|
|
48
|
+
"inline",
|
|
49
|
+
this.href ? "cursor-pointer" : "",
|
|
50
|
+
{
|
|
51
|
+
sm: "text-sm",
|
|
52
|
+
lg: "text-base",
|
|
53
|
+
inherit: ""
|
|
54
|
+
}[this.size],
|
|
55
|
+
{
|
|
56
|
+
disabled: !this.inverted ? "text-neutral-500" : "text-neutral-600",
|
|
57
|
+
enabled: !this.inverted ? ` text-primary hover:text-primary-500 active:text-primary-800 focus-visible:focus-outline` : `text-white hover:text-primary-200 active:text-primary-400 focus-visible:focus-outline-inverted`
|
|
58
|
+
}[this.href ? "enabled" : "disabled"],
|
|
59
|
+
this.standalone && "flex items-start"
|
|
60
|
+
)}" href="${ifDefined(this.href || void 0)}" target="${ifDefined(this.target || void 0)}" download="${ifDefined(this.download || void 0)}" rel="${ifDefined(this.target ? "noreferrer noopener" : void 0)}" aria-disabled="${!this.href ? "true" : "false"}" tabindex="${!this.href ? "-1" : "0"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"><slot name="icon-left" part="icon-left" class="${cx(
|
|
61
|
+
"inline",
|
|
62
|
+
slots["icon-left"] && (!this.standalone ? "mr-[0.25em]" : {
|
|
63
|
+
sm: "mr-1",
|
|
64
|
+
lg: "mr-2",
|
|
65
|
+
inherit: "mr-[0.5em]"
|
|
66
|
+
}[this.size])
|
|
67
|
+
)}"></slot><span part="label" class="inline underline underline-offset-2"><slot></slot></span><slot name="icon-right" part="icon-right" class="${cx(
|
|
68
|
+
"inline",
|
|
69
|
+
slots["icon-right"] && (!this.standalone ? "ml-[0.25em]" : {
|
|
70
|
+
sm: "ml-1",
|
|
71
|
+
lg: "ml-2",
|
|
72
|
+
inherit: "ml-[0.5em]"
|
|
73
|
+
}[this.size])
|
|
74
|
+
)}"></slot></a>`;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
SdLink.styles = [
|
|
78
|
+
SolidElement.styles,
|
|
79
|
+
css`::slotted(sd-1-0-0-icon){font-size:1.25em;margin-bottom:-.25em}:host([size=sm][standalone]) ::slotted(sd-1-0-0-icon){font-size:1rem}:host([size=lg][standalone]) ::slotted(sd-1-0-0-icon){font-size:1.5rem}`
|
|
80
|
+
];
|
|
81
|
+
__decorateClass([
|
|
82
|
+
query("a")
|
|
83
|
+
], SdLink.prototype, "button", 2);
|
|
84
|
+
__decorateClass([
|
|
85
|
+
property({ reflect: true })
|
|
86
|
+
], SdLink.prototype, "size", 2);
|
|
87
|
+
__decorateClass([
|
|
88
|
+
property({ type: Boolean, reflect: true })
|
|
89
|
+
], SdLink.prototype, "inverted", 2);
|
|
90
|
+
__decorateClass([
|
|
91
|
+
property({ type: Boolean, reflect: true })
|
|
92
|
+
], SdLink.prototype, "standalone", 2);
|
|
93
|
+
__decorateClass([
|
|
94
|
+
property()
|
|
95
|
+
], SdLink.prototype, "href", 2);
|
|
96
|
+
__decorateClass([
|
|
97
|
+
property()
|
|
98
|
+
], SdLink.prototype, "target", 2);
|
|
99
|
+
__decorateClass([
|
|
100
|
+
property()
|
|
101
|
+
], SdLink.prototype, "download", 2);
|
|
102
|
+
SdLink = __decorateClass([
|
|
103
|
+
customElement("sd-1-0-0-link")
|
|
104
|
+
], SdLink);
|
|
105
|
+
export {
|
|
106
|
+
SdLink as default
|
|
107
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
export default class SdSpinner extends SolidElement {
|
|
3
|
+
color: 'primary' | 'white' | 'currentColor';
|
|
4
|
+
private readonly localize;
|
|
5
|
+
render(): import("lit").TemplateResult<1>;
|
|
6
|
+
static styles: import("lit").CSSResultGroup[];
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'sd-1-0-0-spinner': SdSpinner;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { property, customElement } from "lit/decorators.js";
|
|
3
|
+
import { LocalizeController } from "../../utilities/localize.js";
|
|
4
|
+
import cx from "classix";
|
|
5
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
9
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
10
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
11
|
+
if (decorator = decorators[i])
|
|
12
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
13
|
+
if (kind && result)
|
|
14
|
+
__defProp(target, key, result);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
let SdSpinner = class extends SolidElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.color = "currentColor";
|
|
21
|
+
this.localize = new LocalizeController(this);
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return html`<svg role="progressbar" viewBox="0 0 24 24" class="${cx(
|
|
25
|
+
"animate-spin",
|
|
26
|
+
{
|
|
27
|
+
primary: "text-primary",
|
|
28
|
+
white: "text-white",
|
|
29
|
+
currentColor: ""
|
|
30
|
+
}[this.color]
|
|
31
|
+
)}" aria-valuetext="${this.localize.term("loading")}"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22ZM24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z" class="opacity-20" fill="currentColor"/><mask id="mask0_5273_25391" style="mask-type:alpha" maskUnits="userSpaceOnUse"><path d="M24 12C24 5.37258 18.6274 0 12 0V12H24Z" fill="currentColor"/></mask><g mask="url(#mask0_5273_25391)"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22ZM24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12Z" fill="currentColor"/></g></svg>`;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
SdSpinner.styles = [
|
|
35
|
+
SolidElement.styles,
|
|
36
|
+
css`:host{display:inline-block;width:1em;height:1em}`
|
|
37
|
+
];
|
|
38
|
+
__decorateClass([
|
|
39
|
+
property({ reflect: true })
|
|
40
|
+
], SdSpinner.prototype, "color", 2);
|
|
41
|
+
SdSpinner = __decorateClass([
|
|
42
|
+
customElement("sd-1-0-0-spinner")
|
|
43
|
+
], SdSpinner);
|
|
44
|
+
export {
|
|
45
|
+
SdSpinner as default
|
|
46
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import type { SolidFormControl } from '../internal/solid-element';
|
|
3
|
+
import type SdButton from '../components/button/button';
|
|
4
|
+
export declare const formCollections: WeakMap<HTMLFormElement, Set<SolidFormControl>>;
|
|
5
|
+
export interface FormControlControllerOptions {
|
|
6
|
+
form: (input: SolidFormControl) => HTMLFormElement | null;
|
|
7
|
+
name: (input: SolidFormControl) => string;
|
|
8
|
+
value: (input: SolidFormControl) => unknown | unknown[];
|
|
9
|
+
defaultValue: (input: SolidFormControl) => unknown | unknown[];
|
|
10
|
+
disabled: (input: SolidFormControl) => boolean;
|
|
11
|
+
reportValidity: (input: SolidFormControl) => boolean;
|
|
12
|
+
setValue: (input: SolidFormControl, value: unknown) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class FormControlController implements ReactiveController {
|
|
15
|
+
host: SolidFormControl & ReactiveControllerHost;
|
|
16
|
+
form?: HTMLFormElement | null;
|
|
17
|
+
options: FormControlControllerOptions;
|
|
18
|
+
constructor(host: ReactiveControllerHost & SolidFormControl, options?: Partial<FormControlControllerOptions>);
|
|
19
|
+
hostConnected(): void;
|
|
20
|
+
hostDisconnected(): void;
|
|
21
|
+
hostUpdated(): void;
|
|
22
|
+
private attachForm;
|
|
23
|
+
private detachForm;
|
|
24
|
+
private handleFormData;
|
|
25
|
+
private handleFormSubmit;
|
|
26
|
+
private handleFormReset;
|
|
27
|
+
private handleUserInput;
|
|
28
|
+
private reportFormValidity;
|
|
29
|
+
private setUserInteracted;
|
|
30
|
+
private doAction;
|
|
31
|
+
reset(invoker?: HTMLInputElement | SdButton): void;
|
|
32
|
+
submit(invoker?: HTMLInputElement | SdButton): void;
|
|
33
|
+
setValidity(isValid: boolean): void;
|
|
34
|
+
updateValidity(): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const formCollections = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
const userInteractedControls = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
const reportValidityOverloads = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
class FormControlController {
|
|
5
|
+
constructor(host, options) {
|
|
6
|
+
(this.host = host).addController(this);
|
|
7
|
+
this.options = {
|
|
8
|
+
form: (input) => {
|
|
9
|
+
if (input.hasAttribute("form") && input.getAttribute("form") !== "") {
|
|
10
|
+
const root = input.getRootNode();
|
|
11
|
+
const formId = input.getAttribute("form");
|
|
12
|
+
if (formId) {
|
|
13
|
+
return root.getElementById(formId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return input.closest("form");
|
|
17
|
+
},
|
|
18
|
+
name: (input) => input.name,
|
|
19
|
+
value: (input) => input.value,
|
|
20
|
+
defaultValue: (input) => input.defaultValue,
|
|
21
|
+
disabled: (input) => input.disabled ?? false,
|
|
22
|
+
reportValidity: (input) => typeof input.reportValidity === "function" ? input.reportValidity() : true,
|
|
23
|
+
setValue: (input, value) => input.value = value,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
this.handleFormData = this.handleFormData.bind(this);
|
|
27
|
+
this.handleFormSubmit = this.handleFormSubmit.bind(this);
|
|
28
|
+
this.handleFormReset = this.handleFormReset.bind(this);
|
|
29
|
+
this.reportFormValidity = this.reportFormValidity.bind(this);
|
|
30
|
+
this.handleUserInput = this.handleUserInput.bind(this);
|
|
31
|
+
}
|
|
32
|
+
hostConnected() {
|
|
33
|
+
const form = this.options.form(this.host);
|
|
34
|
+
if (form) {
|
|
35
|
+
this.attachForm(form);
|
|
36
|
+
}
|
|
37
|
+
this.host.addEventListener("sd-input", this.handleUserInput);
|
|
38
|
+
}
|
|
39
|
+
hostDisconnected() {
|
|
40
|
+
this.detachForm();
|
|
41
|
+
this.host.removeEventListener("sd-input", this.handleUserInput);
|
|
42
|
+
}
|
|
43
|
+
hostUpdated() {
|
|
44
|
+
const form = this.options.form(this.host);
|
|
45
|
+
if (!form) {
|
|
46
|
+
this.detachForm();
|
|
47
|
+
}
|
|
48
|
+
if (form && this.form !== form) {
|
|
49
|
+
this.detachForm();
|
|
50
|
+
this.attachForm(form);
|
|
51
|
+
}
|
|
52
|
+
if (this.host.hasUpdated) {
|
|
53
|
+
this.setValidity(this.host.checkValidity());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
attachForm(form) {
|
|
57
|
+
if (form) {
|
|
58
|
+
this.form = form;
|
|
59
|
+
if (formCollections.has(this.form)) {
|
|
60
|
+
formCollections.get(this.form).add(this.host);
|
|
61
|
+
} else {
|
|
62
|
+
formCollections.set(this.form, /* @__PURE__ */ new Set([this.host]));
|
|
63
|
+
}
|
|
64
|
+
this.form.addEventListener("formdata", this.handleFormData);
|
|
65
|
+
this.form.addEventListener("submit", this.handleFormSubmit);
|
|
66
|
+
this.form.addEventListener("reset", this.handleFormReset);
|
|
67
|
+
if (!reportValidityOverloads.has(this.form)) {
|
|
68
|
+
reportValidityOverloads.set(this.form, this.form.reportValidity);
|
|
69
|
+
this.form.reportValidity = () => this.reportFormValidity();
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
this.form = void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
detachForm() {
|
|
76
|
+
var _a;
|
|
77
|
+
if (this.form) {
|
|
78
|
+
(_a = formCollections.get(this.form)) == null ? void 0 : _a.delete(this.host);
|
|
79
|
+
this.form.removeEventListener("formdata", this.handleFormData);
|
|
80
|
+
this.form.removeEventListener("submit", this.handleFormSubmit);
|
|
81
|
+
this.form.removeEventListener("reset", this.handleFormReset);
|
|
82
|
+
if (reportValidityOverloads.has(this.form)) {
|
|
83
|
+
this.form.reportValidity = reportValidityOverloads.get(this.form);
|
|
84
|
+
reportValidityOverloads.delete(this.form);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.form = void 0;
|
|
88
|
+
}
|
|
89
|
+
handleFormData(event) {
|
|
90
|
+
const disabled = this.options.disabled(this.host);
|
|
91
|
+
const name = this.options.name(this.host);
|
|
92
|
+
const value = this.options.value(this.host);
|
|
93
|
+
const isButton = this.host.tagName.toLowerCase() === "sd-1-0-0-button";
|
|
94
|
+
if (!disabled && !isButton && typeof name === "string" && name.length > 0 && typeof value !== "undefined") {
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
value.forEach((val) => {
|
|
97
|
+
event.formData.append(name, val.toString());
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
event.formData.append(name, value.toString());
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
handleFormSubmit(event) {
|
|
105
|
+
var _a;
|
|
106
|
+
const disabled = this.options.disabled(this.host);
|
|
107
|
+
const reportValidity = this.options.reportValidity;
|
|
108
|
+
if (this.form && !this.form.noValidate) {
|
|
109
|
+
(_a = formCollections.get(this.form)) == null ? void 0 : _a.forEach((control) => {
|
|
110
|
+
this.setUserInteracted(control, true);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (this.form && !this.form.noValidate && !disabled && !reportValidity(this.host)) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
event.stopImmediatePropagation();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
handleFormReset() {
|
|
119
|
+
this.options.setValue(this.host, this.options.defaultValue(this.host));
|
|
120
|
+
this.setUserInteracted(this.host, false);
|
|
121
|
+
}
|
|
122
|
+
async handleUserInput() {
|
|
123
|
+
await this.host.updateComplete;
|
|
124
|
+
this.setUserInteracted(this.host, true);
|
|
125
|
+
}
|
|
126
|
+
reportFormValidity() {
|
|
127
|
+
if (this.form && !this.form.noValidate) {
|
|
128
|
+
const elements = this.form.querySelectorAll("*");
|
|
129
|
+
for (const element of elements) {
|
|
130
|
+
if (typeof element.reportValidity === "function") {
|
|
131
|
+
if (!element.reportValidity()) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
setUserInteracted(el, hasInteracted) {
|
|
140
|
+
userInteractedControls.set(el, hasInteracted);
|
|
141
|
+
el.requestUpdate();
|
|
142
|
+
}
|
|
143
|
+
doAction(type, invoker) {
|
|
144
|
+
if (this.form) {
|
|
145
|
+
const button = document.createElement("button");
|
|
146
|
+
button.type = type;
|
|
147
|
+
button.style.position = "absolute";
|
|
148
|
+
button.style.width = "0";
|
|
149
|
+
button.style.height = "0";
|
|
150
|
+
button.style.clipPath = "inset(50%)";
|
|
151
|
+
button.style.overflow = "hidden";
|
|
152
|
+
button.style.whiteSpace = "nowrap";
|
|
153
|
+
if (invoker) {
|
|
154
|
+
button.name = invoker.name;
|
|
155
|
+
button.value = invoker.value;
|
|
156
|
+
["formaction", "formenctype", "formmethod", "formnovalidate", "formtarget"].forEach((attr) => {
|
|
157
|
+
if (invoker.hasAttribute(attr)) {
|
|
158
|
+
button.setAttribute(attr, invoker.getAttribute(attr));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
this.form.append(button);
|
|
163
|
+
button.click();
|
|
164
|
+
button.remove();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/** Resets the form, restoring all the control to their default value */
|
|
168
|
+
reset(invoker) {
|
|
169
|
+
this.doAction("reset", invoker);
|
|
170
|
+
}
|
|
171
|
+
/** Submits the form, triggering validation and form data injection. */
|
|
172
|
+
submit(invoker) {
|
|
173
|
+
this.doAction("submit", invoker);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Synchronously sets the form control's validity. Call this when you know the future validity but need to update
|
|
177
|
+
* the host element immediately, i.e. before Lit updates the component in the next update.
|
|
178
|
+
*/
|
|
179
|
+
setValidity(isValid) {
|
|
180
|
+
var _a;
|
|
181
|
+
const host = this.host;
|
|
182
|
+
const hasInteracted = Boolean(userInteractedControls.get(host));
|
|
183
|
+
const required = Boolean(host.required);
|
|
184
|
+
if ((_a = this.form) == null ? void 0 : _a.noValidate) {
|
|
185
|
+
host.removeAttribute("data-required");
|
|
186
|
+
host.removeAttribute("data-optional");
|
|
187
|
+
host.removeAttribute("data-invalid");
|
|
188
|
+
host.removeAttribute("data-valid");
|
|
189
|
+
host.removeAttribute("data-user-invalid");
|
|
190
|
+
host.removeAttribute("data-user-valid");
|
|
191
|
+
} else {
|
|
192
|
+
host.toggleAttribute("data-required", required);
|
|
193
|
+
host.toggleAttribute("data-optional", !required);
|
|
194
|
+
host.toggleAttribute("data-invalid", !isValid);
|
|
195
|
+
host.toggleAttribute("data-valid", isValid);
|
|
196
|
+
host.toggleAttribute("data-user-invalid", !isValid && hasInteracted);
|
|
197
|
+
host.toggleAttribute("data-user-valid", isValid && hasInteracted);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Updates the form control's validity based on the current value of `host.checkValidity()`. Call this when anything
|
|
202
|
+
* that affects constraint validation changes so the component receives the correct validity states.
|
|
203
|
+
*/
|
|
204
|
+
updateValidity() {
|
|
205
|
+
const host = this.host;
|
|
206
|
+
this.setValidity(host.checkValidity());
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
FormControlController,
|
|
211
|
+
formCollections
|
|
212
|
+
};
|