@hypoth-ui/wc 0.1.1
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 +21 -0
- package/README.md +60 -0
- package/dist/button-MKQKTC5Q.js +10 -0
- package/dist/button-MKQKTC5Q.js.map +1 -0
- package/dist/chunk-4HLM6DBG.js +910 -0
- package/dist/chunk-4HLM6DBG.js.map +1 -0
- package/dist/chunk-55ID7LJL.js +3602 -0
- package/dist/chunk-55ID7LJL.js.map +1 -0
- package/dist/chunk-66HFYJD7.js +86 -0
- package/dist/chunk-66HFYJD7.js.map +1 -0
- package/dist/chunk-CZOXIJVS.js +70 -0
- package/dist/chunk-CZOXIJVS.js.map +1 -0
- package/dist/chunk-DHUM4Q5Y.js +495 -0
- package/dist/chunk-DHUM4Q5Y.js.map +1 -0
- package/dist/chunk-DNNI5BDE.js +1842 -0
- package/dist/chunk-DNNI5BDE.js.map +1 -0
- package/dist/chunk-GXKZ6E6K.js +99 -0
- package/dist/chunk-GXKZ6E6K.js.map +1 -0
- package/dist/chunk-H4GJJZ3N.js +51 -0
- package/dist/chunk-H4GJJZ3N.js.map +1 -0
- package/dist/chunk-JMPTFALJ.js +175 -0
- package/dist/chunk-JMPTFALJ.js.map +1 -0
- package/dist/chunk-MYQWCLUJ.js +45 -0
- package/dist/chunk-MYQWCLUJ.js.map +1 -0
- package/dist/chunk-QZSPWT7L.js +183 -0
- package/dist/chunk-QZSPWT7L.js.map +1 -0
- package/dist/chunk-TSKBQCTR.js +5137 -0
- package/dist/chunk-TSKBQCTR.js.map +1 -0
- package/dist/chunk-TXIIUVL3.js +130 -0
- package/dist/chunk-TXIIUVL3.js.map +1 -0
- package/dist/chunk-UM7WRO7W.js +237 -0
- package/dist/chunk-UM7WRO7W.js.map +1 -0
- package/dist/chunk-VPXL4RB3.js +202 -0
- package/dist/chunk-VPXL4RB3.js.map +1 -0
- package/dist/chunk-VX5CKSMN.js +39 -0
- package/dist/chunk-VX5CKSMN.js.map +1 -0
- package/dist/chunk-WQ5BEP3E.js +2845 -0
- package/dist/chunk-WQ5BEP3E.js.map +1 -0
- package/dist/chunk-YDQ434UH.js +60 -0
- package/dist/chunk-YDQ434UH.js.map +1 -0
- package/dist/chunk-ZWV4VI6D.js +153 -0
- package/dist/chunk-ZWV4VI6D.js.map +1 -0
- package/dist/core.d.ts +127 -0
- package/dist/core.js +38 -0
- package/dist/core.js.map +1 -0
- package/dist/data-display.d.ts +872 -0
- package/dist/data-display.js +57 -0
- package/dist/data-display.js.map +1 -0
- package/dist/ds-element-Db0LMfxI.d.ts +43 -0
- package/dist/feedback.d.ts +292 -0
- package/dist/feedback.js +31 -0
- package/dist/feedback.js.map +1 -0
- package/dist/form-controls.d.ts +1713 -0
- package/dist/form-controls.js +63 -0
- package/dist/form-controls.js.map +1 -0
- package/dist/icon-7IZTJ5WT.js +8 -0
- package/dist/icon-7IZTJ5WT.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +423 -0
- package/dist/index.js.map +1 -0
- package/dist/input-LB6UR37A.js +10 -0
- package/dist/input-LB6UR37A.js.map +1 -0
- package/dist/layout.d.ts +504 -0
- package/dist/layout.js +34 -0
- package/dist/layout.js.map +1 -0
- package/dist/link-NHDJ6SFY.js +9 -0
- package/dist/link-NHDJ6SFY.js.map +1 -0
- package/dist/navigation.d.ts +255 -0
- package/dist/navigation.js +111 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlays.d.ts +1291 -0
- package/dist/overlays.js +106 -0
- package/dist/overlays.js.map +1 -0
- package/dist/primitives.d.ts +230 -0
- package/dist/primitives.js +26 -0
- package/dist/primitives.js.map +1 -0
- package/dist/registry-Bns0t11H.d.ts +233 -0
- package/dist/skeleton-MUdd2029.d.ts +109 -0
- package/dist/spinner-BWaNlc-Y.d.ts +45 -0
- package/dist/spinner-UIYDUVBZ.js +8 -0
- package/dist/spinner-UIYDUVBZ.js.map +1 -0
- package/dist/stepper-CCRwcQOe.d.ts +851 -0
- package/dist/text-MT3S3EMU.js +8 -0
- package/dist/text-MT3S3EMU.js.map +1 -0
- package/dist/visually-hidden-MW2XY4CS.js +8 -0
- package/dist/visually-hidden-MW2XY4CS.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DSElement,
|
|
3
|
+
__decorateClass,
|
|
4
|
+
define
|
|
5
|
+
} from "./chunk-H4GJJZ3N.js";
|
|
6
|
+
|
|
7
|
+
// src/components/icon/icon.ts
|
|
8
|
+
import { html, nothing } from "lit";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
11
|
+
|
|
12
|
+
// src/components/icon/icon-adapter.ts
|
|
13
|
+
import { createElement, icons } from "lucide";
|
|
14
|
+
function toPascalCase(str) {
|
|
15
|
+
return str.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
|
|
16
|
+
}
|
|
17
|
+
function getIconSvg(name, options) {
|
|
18
|
+
const pascalName = toPascalCase(name);
|
|
19
|
+
const iconNode = icons[pascalName];
|
|
20
|
+
if (!iconNode) {
|
|
21
|
+
if (process.env.NODE_ENV !== "production") {
|
|
22
|
+
console.warn(`[ds-icon] Icon "${name}" not found in Lucide library.`);
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const customAttrs = {};
|
|
27
|
+
if (options?.size) {
|
|
28
|
+
customAttrs.width = options.size;
|
|
29
|
+
customAttrs.height = options.size;
|
|
30
|
+
}
|
|
31
|
+
if (options?.color) {
|
|
32
|
+
customAttrs.color = options.color;
|
|
33
|
+
}
|
|
34
|
+
if (options?.strokeWidth) {
|
|
35
|
+
customAttrs["stroke-width"] = options.strokeWidth;
|
|
36
|
+
}
|
|
37
|
+
const [tag, defaultAttrs, children] = iconNode;
|
|
38
|
+
const mergedAttrs = { ...defaultAttrs, ...customAttrs };
|
|
39
|
+
const modifiedIconNode = children ? [tag, mergedAttrs, children] : [tag, mergedAttrs];
|
|
40
|
+
const element = createElement(modifiedIconNode);
|
|
41
|
+
return element;
|
|
42
|
+
}
|
|
43
|
+
function hasIcon(name) {
|
|
44
|
+
const pascalName = toPascalCase(name);
|
|
45
|
+
return pascalName in icons;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/components/icon/icon.ts
|
|
49
|
+
var SIZE_MAP = {
|
|
50
|
+
xs: 12,
|
|
51
|
+
sm: 16,
|
|
52
|
+
md: 20,
|
|
53
|
+
lg: 24,
|
|
54
|
+
xl: 32
|
|
55
|
+
};
|
|
56
|
+
var DsIcon = class extends DSElement {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
this.name = "";
|
|
60
|
+
this.size = "md";
|
|
61
|
+
this.label = "";
|
|
62
|
+
this.color = "";
|
|
63
|
+
this._svgElement = null;
|
|
64
|
+
this._isValidIcon = true;
|
|
65
|
+
}
|
|
66
|
+
static {
|
|
67
|
+
this.styles = [];
|
|
68
|
+
}
|
|
69
|
+
willUpdate(changedProperties) {
|
|
70
|
+
if (changedProperties.has("name") || changedProperties.has("size")) {
|
|
71
|
+
this.updateSvg();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
updateSvg() {
|
|
75
|
+
if (!this.name) {
|
|
76
|
+
this._svgElement = null;
|
|
77
|
+
this._isValidIcon = false;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (!hasIcon(this.name)) {
|
|
81
|
+
this._svgElement = null;
|
|
82
|
+
this._isValidIcon = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this._svgElement = getIconSvg(this.name, {
|
|
86
|
+
size: SIZE_MAP[this.size]
|
|
87
|
+
});
|
|
88
|
+
this._isValidIcon = this._svgElement !== null;
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
const isDecorative = !this.label;
|
|
92
|
+
const classes = {
|
|
93
|
+
"ds-icon": true,
|
|
94
|
+
[`ds-icon--${this.size}`]: true,
|
|
95
|
+
"ds-icon--fallback": !this._isValidIcon
|
|
96
|
+
};
|
|
97
|
+
const style = this.color ? `color: ${this.color}` : "";
|
|
98
|
+
if (!this._isValidIcon) {
|
|
99
|
+
return html`
|
|
100
|
+
<span
|
|
101
|
+
class=${classMap(classes)}
|
|
102
|
+
style=${style || nothing}
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
></span>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
if (isDecorative) {
|
|
108
|
+
return html`
|
|
109
|
+
<span
|
|
110
|
+
class=${classMap(classes)}
|
|
111
|
+
style=${style || nothing}
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
>
|
|
114
|
+
${this._svgElement}
|
|
115
|
+
</span>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
return html`
|
|
119
|
+
<span
|
|
120
|
+
class=${classMap(classes)}
|
|
121
|
+
style=${style || nothing}
|
|
122
|
+
role="img"
|
|
123
|
+
aria-label=${this.label}
|
|
124
|
+
>
|
|
125
|
+
${this._svgElement}
|
|
126
|
+
</span>
|
|
127
|
+
`;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
__decorateClass([
|
|
131
|
+
property({ type: String, reflect: true })
|
|
132
|
+
], DsIcon.prototype, "name", 2);
|
|
133
|
+
__decorateClass([
|
|
134
|
+
property({ type: String, reflect: true })
|
|
135
|
+
], DsIcon.prototype, "size", 2);
|
|
136
|
+
__decorateClass([
|
|
137
|
+
property({ type: String })
|
|
138
|
+
], DsIcon.prototype, "label", 2);
|
|
139
|
+
__decorateClass([
|
|
140
|
+
property({ type: String })
|
|
141
|
+
], DsIcon.prototype, "color", 2);
|
|
142
|
+
__decorateClass([
|
|
143
|
+
state()
|
|
144
|
+
], DsIcon.prototype, "_svgElement", 2);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
state()
|
|
147
|
+
], DsIcon.prototype, "_isValidIcon", 2);
|
|
148
|
+
define("ds-icon", DsIcon);
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
DsIcon
|
|
152
|
+
};
|
|
153
|
+
//# sourceMappingURL=chunk-ZWV4VI6D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/icon/icon.ts","../src/components/icon/icon-adapter.ts"],"sourcesContent":["import { type TemplateResult, html, nothing } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { DSElement } from \"../../base/ds-element.js\";\nimport { define } from \"../../registry/define.js\";\nimport { getIconSvg, hasIcon } from \"./icon-adapter.js\";\n\nexport type IconSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/**\n * Size mappings in pixels for SVG generation\n */\nconst SIZE_MAP: Record<IconSize, number> = {\n xs: 12,\n sm: 16,\n md: 20,\n lg: 24,\n xl: 32,\n};\n\n/**\n * An accessible icon component with Lucide integration.\n *\n * @element ds-icon\n *\n * @example\n * ```html\n * <!-- Decorative icon (hidden from screen readers) -->\n * <ds-icon name=\"search\"></ds-icon>\n *\n * <!-- Meaningful icon (announced to screen readers) -->\n * <ds-icon name=\"alert-triangle\" label=\"Warning\"></ds-icon>\n * ```\n */\nexport class DsIcon extends DSElement {\n static override styles = [];\n\n /**\n * The icon name from Lucide library (kebab-case).\n * e.g., \"search\", \"arrow-right\", \"external-link\"\n */\n @property({ type: String, reflect: true })\n name = \"\";\n\n /**\n * The icon size.\n */\n @property({ type: String, reflect: true })\n size: IconSize = \"md\";\n\n /**\n * Accessible label for meaningful icons.\n * When provided, the icon is announced to screen readers.\n * When omitted, the icon is decorative and hidden from screen readers.\n */\n @property({ type: String })\n label = \"\";\n\n /**\n * Custom color for the icon.\n * Accepts any valid CSS color value.\n * Default is currentColor (inherits from text color).\n */\n @property({ type: String })\n color = \"\";\n\n /**\n * Cached SVG element\n */\n @state()\n private _svgElement: SVGSVGElement | null = null;\n\n /**\n * Track if icon is valid\n */\n @state()\n private _isValidIcon = true;\n\n override willUpdate(changedProperties: Map<string, unknown>): void {\n if (changedProperties.has(\"name\") || changedProperties.has(\"size\")) {\n this.updateSvg();\n }\n }\n\n private updateSvg(): void {\n if (!this.name) {\n this._svgElement = null;\n this._isValidIcon = false;\n return;\n }\n\n if (!hasIcon(this.name)) {\n this._svgElement = null;\n this._isValidIcon = false;\n return;\n }\n\n this._svgElement = getIconSvg(this.name, {\n size: SIZE_MAP[this.size],\n });\n this._isValidIcon = this._svgElement !== null;\n }\n\n override render(): TemplateResult {\n const isDecorative = !this.label;\n\n const classes = {\n \"ds-icon\": true,\n [`ds-icon--${this.size}`]: true,\n \"ds-icon--fallback\": !this._isValidIcon,\n };\n\n const style = this.color ? `color: ${this.color}` : \"\";\n\n // Render fallback if icon not found\n if (!this._isValidIcon) {\n return html`\n <span\n class=${classMap(classes)}\n style=${style || nothing}\n aria-hidden=\"true\"\n ></span>\n `;\n }\n\n // Decorative icon (no label)\n if (isDecorative) {\n return html`\n <span\n class=${classMap(classes)}\n style=${style || nothing}\n aria-hidden=\"true\"\n >\n ${this._svgElement}\n </span>\n `;\n }\n\n // Meaningful icon (with label)\n return html`\n <span\n class=${classMap(classes)}\n style=${style || nothing}\n role=\"img\"\n aria-label=${this.label}\n >\n ${this._svgElement}\n </span>\n `;\n }\n}\n\n// Register the component\ndefine(\"ds-icon\", DsIcon);\n\n// TypeScript declaration for HTML\ndeclare global {\n interface HTMLElementTagNameMap {\n \"ds-icon\": DsIcon;\n }\n}\n","/**\n * Icon Adapter for Lucide Icons\n *\n * Provides a unified interface for accessing icons from the Lucide library.\n * Uses createElement() for efficient SVG generation.\n */\n\nimport { createElement, icons } from \"lucide\";\nimport type { IconNode } from \"lucide\";\n\n/**\n * Convert kebab-case to PascalCase for Lucide icon names\n * e.g., \"arrow-right\" -> \"ArrowRight\"\n */\nfunction toPascalCase(str: string): string {\n return str\n .split(\"-\")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\"\");\n}\n\n/**\n * Get an SVG element for the specified icon name.\n *\n * @param name - The icon name in kebab-case (e.g., \"arrow-right\", \"search\", \"external-link\")\n * @param options - Optional attributes to apply to the SVG\n * @returns SVGSVGElement or null if icon not found\n *\n * @example\n * ```typescript\n * const svg = getIconSvg(\"search\");\n * if (svg) {\n * container.appendChild(svg);\n * }\n * ```\n */\nexport function getIconSvg(\n name: string,\n options?: {\n size?: number | string;\n color?: string;\n strokeWidth?: number | string;\n }\n): SVGSVGElement | null {\n // Convert kebab-case name to PascalCase for Lucide lookup\n const pascalName = toPascalCase(name);\n\n // Check if icon exists in Lucide\n const iconNode = icons[pascalName as keyof typeof icons] as IconNode | undefined;\n\n if (!iconNode) {\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(`[ds-icon] Icon \"${name}\" not found in Lucide library.`);\n }\n return null;\n }\n\n // Build custom attributes to merge with default icon attrs\n const customAttrs: Record<string, string | number> = {};\n\n if (options?.size) {\n customAttrs.width = options.size;\n customAttrs.height = options.size;\n }\n\n if (options?.color) {\n customAttrs.color = options.color;\n }\n\n if (options?.strokeWidth) {\n customAttrs[\"stroke-width\"] = options.strokeWidth;\n }\n\n // Merge custom attributes with the icon's default attributes\n // IconNode is [tag, attrs, children?]\n const [tag, defaultAttrs, children] = iconNode;\n const mergedAttrs = { ...defaultAttrs, ...customAttrs };\n const modifiedIconNode: IconNode = children ? [tag, mergedAttrs, children] : [tag, mergedAttrs];\n\n const element = createElement(modifiedIconNode);\n\n return element as SVGSVGElement;\n}\n\n/**\n * Check if an icon name exists in the Lucide library.\n *\n * @param name - The icon name in kebab-case\n * @returns True if the icon exists\n */\nexport function hasIcon(name: string): boolean {\n const pascalName = toPascalCase(name);\n return pascalName in icons;\n}\n\n/**\n * Get all available icon names.\n *\n * @returns Array of icon names in kebab-case\n */\nexport function getAvailableIcons(): string[] {\n return Object.keys(icons).map((name) =>\n name\n .replace(/([A-Z])/g, \"-$1\")\n .toLowerCase()\n .replace(/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,gBACjB,SAAS,OAAO;AAAA;AAAA,qBAEX,KAAK,KAAK;AAAA;AAAA,UAErB,KAAK,WAAW;AAAA;AAAA;AAAA,EAGxB;AACF;AA5GE;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAP9B,OAQX;AAMA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,GAb9B,OAcX;AAQA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GArBf,OAsBX;AAQA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GA7Bf,OA8BX;AAMQ;AAAA,EADP,MAAM;AAAA,GAnCI,OAoCH;AAMA;AAAA,EADP,MAAM;AAAA,GAzCI,OA0CH;AA6EV,OAAO,WAAW,MAAM;","names":[]}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export { D as DSElement, D as LightElement } from './ds-element-Db0LMfxI.js';
|
|
2
|
+
export { f as ComponentRegistryType, i as ComponentTag, C as CustomElementConstructor, a as FormAssociatedElement, b as FormAssociatedInterface, F as FormAssociatedMixin, c as FormLifecycleCallbacks, V as ValidationFlags, d as getComponentClass, e as getComponentClassSync, g as getRegisteredTags, h as hasComponent, l as loadAllComponents, r as registerComponent } from './registry-Bns0t11H.js';
|
|
3
|
+
import 'lit';
|
|
4
|
+
import './primitives.js';
|
|
5
|
+
import './spinner-BWaNlc-Y.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event emission utilities for design system components.
|
|
9
|
+
*
|
|
10
|
+
* All custom events use the `ds:` prefix to avoid collision with native DOM events.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Options for emitting custom events
|
|
14
|
+
*/
|
|
15
|
+
interface EmitEventOptions<T = unknown> {
|
|
16
|
+
/** Event payload data */
|
|
17
|
+
detail?: T;
|
|
18
|
+
/** Whether event bubbles up the DOM tree (default: true) */
|
|
19
|
+
bubbles?: boolean;
|
|
20
|
+
/** Whether event crosses shadow DOM boundaries (default: true) */
|
|
21
|
+
composed?: boolean;
|
|
22
|
+
/** Whether event can be cancelled (default: false) */
|
|
23
|
+
cancelable?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Emit a design system custom event with the `ds:` prefix.
|
|
27
|
+
*
|
|
28
|
+
* Events are automatically prefixed with `ds:` namespace.
|
|
29
|
+
* Default behavior: bubbles and composed are true.
|
|
30
|
+
*
|
|
31
|
+
* @param element - The element dispatching the event
|
|
32
|
+
* @param name - Event name (without ds: prefix)
|
|
33
|
+
* @param options - Event options including detail payload
|
|
34
|
+
* @returns The dispatched CustomEvent
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Emit ds:change event
|
|
39
|
+
* emitEvent(this, 'change', { detail: { value: newValue } });
|
|
40
|
+
*
|
|
41
|
+
* // Emit ds:dismiss with reason
|
|
42
|
+
* emitEvent(this, 'dismiss', { detail: { reason: 'escape' } });
|
|
43
|
+
*
|
|
44
|
+
* // Emit cancelable event
|
|
45
|
+
* const event = emitEvent(this, 'before-close', { cancelable: true });
|
|
46
|
+
* if (event.defaultPrevented) {
|
|
47
|
+
* // Consumer called event.preventDefault()
|
|
48
|
+
* return;
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function emitEvent<T = unknown>(element: HTMLElement, name: string, options?: EmitEventOptions<T>): CustomEvent<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Standard event names used across the design system.
|
|
55
|
+
*
|
|
56
|
+
* Components SHOULD use these standard names when applicable
|
|
57
|
+
* for consistency across the component library.
|
|
58
|
+
*
|
|
59
|
+
* Naming conventions (per event-names.ts):
|
|
60
|
+
* - React props use camelCase callbacks (e.g., onPress, onValueChange)
|
|
61
|
+
* - Web Components use ds: prefixed custom events (e.g., ds:press, ds:change)
|
|
62
|
+
*/
|
|
63
|
+
declare const StandardEvents: {
|
|
64
|
+
/** User activation (click, Enter, Space) - buttons, links, menu items */
|
|
65
|
+
readonly PRESS: "press";
|
|
66
|
+
/** Value changed (inputs, selects) */
|
|
67
|
+
readonly CHANGE: "change";
|
|
68
|
+
/** Item selected (lists, menus) */
|
|
69
|
+
readonly SELECT: "select";
|
|
70
|
+
/** Open state changed (dialogs, dropdowns, menus) - detail: { open, reason } */
|
|
71
|
+
readonly OPEN_CHANGE: "open-change";
|
|
72
|
+
/** Component dismissed (toasts, alerts) */
|
|
73
|
+
readonly DISMISS: "dismiss";
|
|
74
|
+
/** Focus moved within component */
|
|
75
|
+
readonly FOCUS_CHANGE: "focus-change";
|
|
76
|
+
/** Expanded state changed (trees, accordions, collapsibles) */
|
|
77
|
+
readonly EXPANDED_CHANGE: "expanded-change";
|
|
78
|
+
/** Checked state changed (checkboxes, switches, radio groups) */
|
|
79
|
+
readonly CHECKED_CHANGE: "checked-change";
|
|
80
|
+
/** Sort state changed (tables) */
|
|
81
|
+
readonly SORT_CHANGE: "sort-change";
|
|
82
|
+
/** Index changed (pagination, tabs, steppers, carousels) */
|
|
83
|
+
readonly INDEX_CHANGE: "index-change";
|
|
84
|
+
/** Search query changed */
|
|
85
|
+
readonly SEARCH: "search";
|
|
86
|
+
/** Hover state changed */
|
|
87
|
+
readonly HOVER_CHANGE: "hover-change";
|
|
88
|
+
/** Items reordered (drag-and-drop) */
|
|
89
|
+
readonly REORDER: "reorder";
|
|
90
|
+
/** Content copied to clipboard */
|
|
91
|
+
readonly COPY: "copy";
|
|
92
|
+
/** Element resized */
|
|
93
|
+
readonly RESIZE: "resize";
|
|
94
|
+
/** @deprecated Use OPEN_CHANGE instead */
|
|
95
|
+
readonly OPEN: "open";
|
|
96
|
+
/** @deprecated Use OPEN_CHANGE instead */
|
|
97
|
+
readonly CLOSE: "close";
|
|
98
|
+
/** @deprecated Use OPEN_CHANGE with cancelable: true instead */
|
|
99
|
+
readonly BEFORE_CLOSE: "before-close";
|
|
100
|
+
/** @deprecated Use PRESS instead */
|
|
101
|
+
readonly CLICK: "click";
|
|
102
|
+
/** Navigate event (links) */
|
|
103
|
+
readonly NAVIGATE: "navigate";
|
|
104
|
+
};
|
|
105
|
+
type StandardEventName = (typeof StandardEvents)[keyof typeof StandardEvents];
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Safe custom element registration utility.
|
|
109
|
+
* Prevents duplicate registration errors.
|
|
110
|
+
*/
|
|
111
|
+
type CustomElementConstructor = new (...args: unknown[]) => HTMLElement;
|
|
112
|
+
/**
|
|
113
|
+
* Register a custom element if not already defined.
|
|
114
|
+
* @param tagName - The custom element tag name (e.g., 'ds-button')
|
|
115
|
+
* @param elementClass - The custom element class
|
|
116
|
+
*/
|
|
117
|
+
declare function define(tagName: string, elementClass: CustomElementConstructor): void;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a custom element is already registered.
|
|
120
|
+
*/
|
|
121
|
+
declare function isDefined(tagName: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Wait for a custom element to be defined.
|
|
124
|
+
*/
|
|
125
|
+
declare function whenDefined(tagName: string): Promise<CustomElementConstructor>;
|
|
126
|
+
|
|
127
|
+
export { type EmitEventOptions, type StandardEventName, StandardEvents, define, emitEvent, isDefined, whenDefined };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getComponentClass,
|
|
3
|
+
getComponentClassSync,
|
|
4
|
+
getRegisteredTags,
|
|
5
|
+
hasComponent,
|
|
6
|
+
loadAllComponents,
|
|
7
|
+
registerComponent
|
|
8
|
+
} from "./chunk-66HFYJD7.js";
|
|
9
|
+
import {
|
|
10
|
+
FormAssociatedMixin
|
|
11
|
+
} from "./chunk-UM7WRO7W.js";
|
|
12
|
+
import {
|
|
13
|
+
StandardEvents,
|
|
14
|
+
emitEvent
|
|
15
|
+
} from "./chunk-YDQ434UH.js";
|
|
16
|
+
import {
|
|
17
|
+
DSElement,
|
|
18
|
+
define,
|
|
19
|
+
isDefined,
|
|
20
|
+
whenDefined
|
|
21
|
+
} from "./chunk-H4GJJZ3N.js";
|
|
22
|
+
export {
|
|
23
|
+
DSElement,
|
|
24
|
+
FormAssociatedMixin,
|
|
25
|
+
DSElement as LightElement,
|
|
26
|
+
StandardEvents,
|
|
27
|
+
define,
|
|
28
|
+
emitEvent,
|
|
29
|
+
getComponentClass,
|
|
30
|
+
getComponentClassSync,
|
|
31
|
+
getRegisteredTags,
|
|
32
|
+
hasComponent,
|
|
33
|
+
isDefined,
|
|
34
|
+
loadAllComponents,
|
|
35
|
+
registerComponent,
|
|
36
|
+
whenDefined
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|