@duskmoon-dev/el-base 0.6.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/README.md +368 -0
- package/dist/cjs/index.js +990 -0
- package/dist/cjs/index.js.map +16 -0
- package/dist/esm/index.js +958 -0
- package/dist/esm/index.js.map +16 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/animations.d.ts +53 -0
- package/dist/types/animations.d.ts.map +1 -0
- package/dist/types/base-element.d.ts +148 -0
- package/dist/types/base-element.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mixins.d.ts +1494 -0
- package/dist/types/mixins.d.ts.map +1 -0
- package/dist/types/performance.d.ts +49 -0
- package/dist/types/performance.d.ts.map +1 -0
- package/dist/types/styles.d.ts +64 -0
- package/dist/types/styles.d.ts.map +1 -0
- package/dist/types/themes.d.ts +55 -0
- package/dist/types/themes.d.ts.map +1 -0
- package/dist/types/types.d.ts +83 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/validation.d.ts +64 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixins.d.ts","sourceRoot":"","sources":["../../src/mixins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;GAIG;AAEH,KAAK,WAAW,CAAC,CAAC,GAAG,WAAW,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEvE,UAAU,eAAgB,SAAQ,WAAW;IAC3C,iBAAiB,IAAI,IAAI,CAAC;IAC1B,oBAAoB,IAAI,IAAI,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;CACxB;AAMD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8JvB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance utilities for DuskMoon custom elements
|
|
3
|
+
*
|
|
4
|
+
* Provides debounce, throttle, and scheduling helpers for
|
|
5
|
+
* optimizing element responsiveness and reducing unnecessary work.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { debounce, throttle, scheduleTask } from '@duskmoon-dev/el-base';
|
|
10
|
+
*
|
|
11
|
+
* class MySearch extends BaseElement {
|
|
12
|
+
* #search = debounce((query: string) => {
|
|
13
|
+
* this.emit('search', { query });
|
|
14
|
+
* }, 300);
|
|
15
|
+
*
|
|
16
|
+
* #handleScroll = throttle(() => {
|
|
17
|
+
* this._updatePosition();
|
|
18
|
+
* }, 100);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Creates a debounced function that delays invocation until after
|
|
24
|
+
* `delay` milliseconds have elapsed since the last call.
|
|
25
|
+
*
|
|
26
|
+
* Returns a function with a `.cancel()` method to abort pending execution.
|
|
27
|
+
*/
|
|
28
|
+
export declare function debounce<T extends (...args: Parameters<T>) => void>(fn: T, delay: number): T & {
|
|
29
|
+
cancel: () => void;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Creates a throttled function that invokes at most once per `interval` ms.
|
|
33
|
+
* Uses leading-edge execution: fires immediately, then suppresses until interval passes.
|
|
34
|
+
*
|
|
35
|
+
* Returns a function with a `.cancel()` method to abort pending execution.
|
|
36
|
+
*/
|
|
37
|
+
export declare function throttle<T extends (...args: Parameters<T>) => void>(fn: T, interval: number): T & {
|
|
38
|
+
cancel: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Schedule a low-priority task using requestIdleCallback (with fallback).
|
|
42
|
+
* Useful for deferring non-critical work like analytics, preloading, or cleanup.
|
|
43
|
+
*
|
|
44
|
+
* @returns A cancel function
|
|
45
|
+
*/
|
|
46
|
+
export declare function scheduleIdle(callback: () => void, options?: {
|
|
47
|
+
timeout?: number;
|
|
48
|
+
}): () => void;
|
|
49
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/performance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EACjE,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAqB5B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EACjE,EAAE,EAAE,CAAC,EACL,QAAQ,EAAE,MAAM,GACf,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAiC5B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,IAAI,CAQ7F"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS-in-JS utilities for constructable stylesheets
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a CSSStyleSheet from a template literal
|
|
6
|
+
* Results are cached for performance
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const styles = css`
|
|
11
|
+
* :host {
|
|
12
|
+
* display: block;
|
|
13
|
+
* }
|
|
14
|
+
* `;
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param strings - Template literal strings
|
|
18
|
+
* @param values - Interpolated values
|
|
19
|
+
* @returns A CSSStyleSheet instance
|
|
20
|
+
*/
|
|
21
|
+
export declare function css(strings: TemplateStringsArray, ...values: (string | number)[]): CSSStyleSheet;
|
|
22
|
+
/**
|
|
23
|
+
* Combines multiple CSSStyleSheet instances into an array
|
|
24
|
+
* Useful for composing styles from multiple sources
|
|
25
|
+
*
|
|
26
|
+
* @param sheets - Stylesheets to combine
|
|
27
|
+
* @returns Array of stylesheets
|
|
28
|
+
*/
|
|
29
|
+
export declare function combineStyles(...sheets: CSSStyleSheet[]): CSSStyleSheet[];
|
|
30
|
+
/**
|
|
31
|
+
* Creates CSS custom property declarations from an object
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const vars = cssVars({
|
|
36
|
+
* 'color-primary': 'oklch(60% 0.15 250)',
|
|
37
|
+
* 'spacing-md': '1rem'
|
|
38
|
+
* });
|
|
39
|
+
* // Returns: '--color-primary: oklch(60% 0.15 250); --spacing-md: 1rem;'
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param vars - Object of variable names to values
|
|
43
|
+
* @returns CSS custom property declarations string
|
|
44
|
+
*/
|
|
45
|
+
export declare function cssVars(vars: Record<string, string | number>): string;
|
|
46
|
+
/**
|
|
47
|
+
* Default theme CSS custom properties
|
|
48
|
+
* Uses --color-* naming to be compatible with @duskmoon-dev/core
|
|
49
|
+
*
|
|
50
|
+
* Note: Color variables are NOT set here to allow inheritance from document.
|
|
51
|
+
* Document should provide these via :root or [data-theme] selectors.
|
|
52
|
+
* Only non-color design tokens are set as defaults.
|
|
53
|
+
*/
|
|
54
|
+
export declare const defaultTheme: CSSStyleSheet;
|
|
55
|
+
/**
|
|
56
|
+
* Light theme color defaults
|
|
57
|
+
* Apply this to :root or document for light theme
|
|
58
|
+
*/
|
|
59
|
+
export declare const lightThemeColors = "\n /* Primary colors */\n --color-primary: oklch(60% 0.15 250);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary colors */\n --color-secondary: oklch(55% 0.1 250);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary colors */\n --color-tertiary: oklch(50% 0.12 300);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface colors */\n --color-surface: white;\n --color-surface-container: oklch(97% 0.01 250);\n --color-surface-container-low: oklch(98% 0.005 250);\n --color-surface-container-high: oklch(94% 0.01 250);\n --color-on-surface: oklch(25% 0.02 250);\n --color-on-surface-variant: oklch(45% 0.02 250);\n\n /* Outline colors */\n --color-outline: oklch(75% 0.02 250);\n --color-outline-variant: oklch(85% 0.01 250);\n\n /* Semantic colors */\n --color-success: oklch(60% 0.15 145);\n --color-warning: oklch(75% 0.15 85);\n --color-error: oklch(55% 0.2 25);\n --color-info: oklch(60% 0.15 250);\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--color-primary);\n";
|
|
60
|
+
/**
|
|
61
|
+
* Reset styles for Shadow DOM elements
|
|
62
|
+
*/
|
|
63
|
+
export declare const resetStyles: CSSStyleSheet;
|
|
64
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,aAAa,CAuBhG;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAEzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAIrE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,eAiCxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,27CA4C5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,eAcvB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme presets for DuskMoon Elements
|
|
3
|
+
*
|
|
4
|
+
* Each theme provides a complete set of CSS custom properties
|
|
5
|
+
* that can be applied to :root or any container element.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```html
|
|
9
|
+
* <style>
|
|
10
|
+
* :root { ${sunshineTheme} }
|
|
11
|
+
* [data-theme="moonlight"] { ${moonlightTheme} }
|
|
12
|
+
* [data-theme="ocean"] { ${oceanTheme} }
|
|
13
|
+
* </style>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Sunshine theme (light) — warm, friendly, high contrast
|
|
18
|
+
* Default light theme with blue primary
|
|
19
|
+
*/
|
|
20
|
+
export declare const sunshineTheme = "\n /* Primary */\n --color-primary: oklch(60% 0.15 250);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.1 250);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(50% 0.12 300);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: white;\n --color-surface-container: oklch(97% 0.01 250);\n --color-surface-container-low: oklch(98% 0.005 250);\n --color-surface-container-high: oklch(94% 0.01 250);\n --color-surface-variant: oklch(92% 0.01 250);\n --color-on-surface: oklch(25% 0.02 250);\n --color-on-surface-variant: oklch(45% 0.02 250);\n --color-inverse-surface: oklch(25% 0.02 250);\n --color-inverse-on-surface: oklch(95% 0.01 250);\n\n /* Outline */\n --color-outline: oklch(75% 0.02 250);\n --color-outline-variant: oklch(85% 0.01 250);\n\n /* Semantic */\n --color-success: oklch(60% 0.15 145);\n --color-on-success: white;\n --color-warning: oklch(75% 0.15 85);\n --color-on-warning: oklch(25% 0.05 85);\n --color-error: oklch(55% 0.2 25);\n --color-on-error: white;\n --color-info: oklch(60% 0.15 250);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--color-primary);\n";
|
|
21
|
+
/**
|
|
22
|
+
* Moonlight theme (dark) — elegant, modern dark mode
|
|
23
|
+
*/
|
|
24
|
+
export declare const moonlightTheme = "\n /* Primary */\n --color-primary: oklch(72% 0.15 250);\n --color-primary-content: oklch(20% 0.05 250);\n --color-on-primary: oklch(20% 0.05 250);\n\n /* Secondary */\n --color-secondary: oklch(68% 0.1 250);\n --color-secondary-content: oklch(20% 0.05 250);\n --color-on-secondary: oklch(20% 0.05 250);\n\n /* Tertiary */\n --color-tertiary: oklch(70% 0.12 300);\n --color-tertiary-content: oklch(20% 0.05 300);\n --color-on-tertiary: oklch(20% 0.05 300);\n\n /* Surface */\n --color-surface: oklch(18% 0.02 250);\n --color-surface-container: oklch(22% 0.02 250);\n --color-surface-container-low: oklch(20% 0.02 250);\n --color-surface-container-high: oklch(26% 0.02 250);\n --color-surface-variant: oklch(30% 0.02 250);\n --color-on-surface: oklch(92% 0.01 250);\n --color-on-surface-variant: oklch(75% 0.02 250);\n --color-inverse-surface: oklch(92% 0.01 250);\n --color-inverse-on-surface: oklch(25% 0.02 250);\n\n /* Outline */\n --color-outline: oklch(45% 0.02 250);\n --color-outline-variant: oklch(35% 0.02 250);\n\n /* Semantic */\n --color-success: oklch(70% 0.15 145);\n --color-on-success: oklch(20% 0.05 145);\n --color-warning: oklch(80% 0.12 85);\n --color-on-warning: oklch(20% 0.05 85);\n --color-error: oklch(65% 0.2 25);\n --color-on-error: oklch(20% 0.05 25);\n --color-info: oklch(70% 0.15 250);\n --color-on-info: oklch(20% 0.05 250);\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.5);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(18% 0.02 250), 0 0 0 4px var(--color-primary);\n";
|
|
25
|
+
/**
|
|
26
|
+
* Ocean theme — deep blue/teal palette, calm and professional
|
|
27
|
+
*/
|
|
28
|
+
export declare const oceanTheme = "\n /* Primary */\n --color-primary: oklch(58% 0.12 210);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.08 185);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(60% 0.1 170);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(98% 0.005 210);\n --color-surface-container: oklch(96% 0.01 210);\n --color-surface-container-low: oklch(97% 0.005 210);\n --color-surface-container-high: oklch(93% 0.01 210);\n --color-surface-variant: oklch(91% 0.01 210);\n --color-on-surface: oklch(22% 0.02 210);\n --color-on-surface-variant: oklch(40% 0.02 210);\n --color-inverse-surface: oklch(22% 0.02 210);\n --color-inverse-on-surface: oklch(95% 0.01 210);\n\n /* Outline */\n --color-outline: oklch(72% 0.02 210);\n --color-outline-variant: oklch(82% 0.01 210);\n\n /* Semantic */\n --color-success: oklch(62% 0.14 155);\n --color-on-success: white;\n --color-warning: oklch(76% 0.14 80);\n --color-on-warning: oklch(25% 0.05 80);\n --color-error: oklch(56% 0.18 20);\n --color-on-error: white;\n --color-info: oklch(58% 0.12 210);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.06);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 210), 0 0 0 4px var(--color-primary);\n";
|
|
29
|
+
/**
|
|
30
|
+
* Forest theme — earthy greens and warm browns, natural feel
|
|
31
|
+
*/
|
|
32
|
+
export declare const forestTheme = "\n /* Primary */\n --color-primary: oklch(52% 0.12 155);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(50% 0.08 70);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(55% 0.1 120);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(97% 0.005 90);\n --color-surface-container: oklch(95% 0.01 90);\n --color-surface-container-low: oklch(96% 0.005 90);\n --color-surface-container-high: oklch(92% 0.01 90);\n --color-surface-variant: oklch(90% 0.01 90);\n --color-on-surface: oklch(22% 0.03 90);\n --color-on-surface-variant: oklch(40% 0.03 90);\n --color-inverse-surface: oklch(22% 0.03 90);\n --color-inverse-on-surface: oklch(95% 0.01 90);\n\n /* Outline */\n --color-outline: oklch(70% 0.03 90);\n --color-outline-variant: oklch(82% 0.01 90);\n\n /* Semantic */\n --color-success: oklch(58% 0.14 145);\n --color-on-success: white;\n --color-warning: oklch(74% 0.14 85);\n --color-on-warning: oklch(25% 0.05 85);\n --color-error: oklch(54% 0.18 25);\n --color-on-error: white;\n --color-info: oklch(55% 0.12 230);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(97% 0.005 90), 0 0 0 4px var(--color-primary);\n";
|
|
33
|
+
/**
|
|
34
|
+
* Rosé theme — soft pinks and warm tones, elegant and modern
|
|
35
|
+
*/
|
|
36
|
+
export declare const roseTheme = "\n /* Primary */\n --color-primary: oklch(60% 0.16 350);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.1 330);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(58% 0.12 15);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(98% 0.005 350);\n --color-surface-container: oklch(96% 0.01 350);\n --color-surface-container-low: oklch(97% 0.005 350);\n --color-surface-container-high: oklch(93% 0.01 350);\n --color-surface-variant: oklch(91% 0.01 350);\n --color-on-surface: oklch(22% 0.02 350);\n --color-on-surface-variant: oklch(42% 0.02 350);\n --color-inverse-surface: oklch(22% 0.02 350);\n --color-inverse-on-surface: oklch(95% 0.005 350);\n\n /* Outline */\n --color-outline: oklch(72% 0.02 350);\n --color-outline-variant: oklch(84% 0.01 350);\n\n /* Semantic */\n --color-success: oklch(62% 0.14 148);\n --color-on-success: white;\n --color-warning: oklch(76% 0.14 82);\n --color-on-warning: oklch(25% 0.05 82);\n --color-error: oklch(55% 0.2 22);\n --color-on-error: white;\n --color-info: oklch(58% 0.14 245);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 350), 0 0 0 4px var(--color-primary);\n";
|
|
37
|
+
/**
|
|
38
|
+
* Map of all available theme presets
|
|
39
|
+
*/
|
|
40
|
+
export declare const themes: {
|
|
41
|
+
readonly sunshine: "\n /* Primary */\n --color-primary: oklch(60% 0.15 250);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.1 250);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(50% 0.12 300);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: white;\n --color-surface-container: oklch(97% 0.01 250);\n --color-surface-container-low: oklch(98% 0.005 250);\n --color-surface-container-high: oklch(94% 0.01 250);\n --color-surface-variant: oklch(92% 0.01 250);\n --color-on-surface: oklch(25% 0.02 250);\n --color-on-surface-variant: oklch(45% 0.02 250);\n --color-inverse-surface: oklch(25% 0.02 250);\n --color-inverse-on-surface: oklch(95% 0.01 250);\n\n /* Outline */\n --color-outline: oklch(75% 0.02 250);\n --color-outline-variant: oklch(85% 0.01 250);\n\n /* Semantic */\n --color-success: oklch(60% 0.15 145);\n --color-on-success: white;\n --color-warning: oklch(75% 0.15 85);\n --color-on-warning: oklch(25% 0.05 85);\n --color-error: oklch(55% 0.2 25);\n --color-on-error: white;\n --color-info: oklch(60% 0.15 250);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--color-primary);\n";
|
|
42
|
+
readonly moonlight: "\n /* Primary */\n --color-primary: oklch(72% 0.15 250);\n --color-primary-content: oklch(20% 0.05 250);\n --color-on-primary: oklch(20% 0.05 250);\n\n /* Secondary */\n --color-secondary: oklch(68% 0.1 250);\n --color-secondary-content: oklch(20% 0.05 250);\n --color-on-secondary: oklch(20% 0.05 250);\n\n /* Tertiary */\n --color-tertiary: oklch(70% 0.12 300);\n --color-tertiary-content: oklch(20% 0.05 300);\n --color-on-tertiary: oklch(20% 0.05 300);\n\n /* Surface */\n --color-surface: oklch(18% 0.02 250);\n --color-surface-container: oklch(22% 0.02 250);\n --color-surface-container-low: oklch(20% 0.02 250);\n --color-surface-container-high: oklch(26% 0.02 250);\n --color-surface-variant: oklch(30% 0.02 250);\n --color-on-surface: oklch(92% 0.01 250);\n --color-on-surface-variant: oklch(75% 0.02 250);\n --color-inverse-surface: oklch(92% 0.01 250);\n --color-inverse-on-surface: oklch(25% 0.02 250);\n\n /* Outline */\n --color-outline: oklch(45% 0.02 250);\n --color-outline-variant: oklch(35% 0.02 250);\n\n /* Semantic */\n --color-success: oklch(70% 0.15 145);\n --color-on-success: oklch(20% 0.05 145);\n --color-warning: oklch(80% 0.12 85);\n --color-on-warning: oklch(20% 0.05 85);\n --color-error: oklch(65% 0.2 25);\n --color-on-error: oklch(20% 0.05 25);\n --color-info: oklch(70% 0.15 250);\n --color-on-info: oklch(20% 0.05 250);\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.5);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(18% 0.02 250), 0 0 0 4px var(--color-primary);\n";
|
|
43
|
+
readonly ocean: "\n /* Primary */\n --color-primary: oklch(58% 0.12 210);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.08 185);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(60% 0.1 170);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(98% 0.005 210);\n --color-surface-container: oklch(96% 0.01 210);\n --color-surface-container-low: oklch(97% 0.005 210);\n --color-surface-container-high: oklch(93% 0.01 210);\n --color-surface-variant: oklch(91% 0.01 210);\n --color-on-surface: oklch(22% 0.02 210);\n --color-on-surface-variant: oklch(40% 0.02 210);\n --color-inverse-surface: oklch(22% 0.02 210);\n --color-inverse-on-surface: oklch(95% 0.01 210);\n\n /* Outline */\n --color-outline: oklch(72% 0.02 210);\n --color-outline-variant: oklch(82% 0.01 210);\n\n /* Semantic */\n --color-success: oklch(62% 0.14 155);\n --color-on-success: white;\n --color-warning: oklch(76% 0.14 80);\n --color-on-warning: oklch(25% 0.05 80);\n --color-error: oklch(56% 0.18 20);\n --color-on-error: white;\n --color-info: oklch(58% 0.12 210);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.06);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 210), 0 0 0 4px var(--color-primary);\n";
|
|
44
|
+
readonly forest: "\n /* Primary */\n --color-primary: oklch(52% 0.12 155);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(50% 0.08 70);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(55% 0.1 120);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(97% 0.005 90);\n --color-surface-container: oklch(95% 0.01 90);\n --color-surface-container-low: oklch(96% 0.005 90);\n --color-surface-container-high: oklch(92% 0.01 90);\n --color-surface-variant: oklch(90% 0.01 90);\n --color-on-surface: oklch(22% 0.03 90);\n --color-on-surface-variant: oklch(40% 0.03 90);\n --color-inverse-surface: oklch(22% 0.03 90);\n --color-inverse-on-surface: oklch(95% 0.01 90);\n\n /* Outline */\n --color-outline: oklch(70% 0.03 90);\n --color-outline-variant: oklch(82% 0.01 90);\n\n /* Semantic */\n --color-success: oklch(58% 0.14 145);\n --color-on-success: white;\n --color-warning: oklch(74% 0.14 85);\n --color-on-warning: oklch(25% 0.05 85);\n --color-error: oklch(54% 0.18 25);\n --color-on-error: white;\n --color-info: oklch(55% 0.12 230);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(97% 0.005 90), 0 0 0 4px var(--color-primary);\n";
|
|
45
|
+
readonly rose: "\n /* Primary */\n --color-primary: oklch(60% 0.16 350);\n --color-primary-content: white;\n --color-on-primary: white;\n\n /* Secondary */\n --color-secondary: oklch(55% 0.1 330);\n --color-secondary-content: white;\n --color-on-secondary: white;\n\n /* Tertiary */\n --color-tertiary: oklch(58% 0.12 15);\n --color-tertiary-content: white;\n --color-on-tertiary: white;\n\n /* Surface */\n --color-surface: oklch(98% 0.005 350);\n --color-surface-container: oklch(96% 0.01 350);\n --color-surface-container-low: oklch(97% 0.005 350);\n --color-surface-container-high: oklch(93% 0.01 350);\n --color-surface-variant: oklch(91% 0.01 350);\n --color-on-surface: oklch(22% 0.02 350);\n --color-on-surface-variant: oklch(42% 0.02 350);\n --color-inverse-surface: oklch(22% 0.02 350);\n --color-inverse-on-surface: oklch(95% 0.005 350);\n\n /* Outline */\n --color-outline: oklch(72% 0.02 350);\n --color-outline-variant: oklch(84% 0.01 350);\n\n /* Semantic */\n --color-success: oklch(62% 0.14 148);\n --color-on-success: white;\n --color-warning: oklch(76% 0.14 82);\n --color-on-warning: oklch(25% 0.05 82);\n --color-error: oklch(55% 0.2 22);\n --color-on-error: white;\n --color-info: oklch(58% 0.14 245);\n --color-on-info: white;\n\n /* Shadows */\n --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n /* Focus */\n --focus-ring: 0 0 0 2px var(--color-primary);\n --focus-ring-offset: 0 0 0 2px oklch(98% 0.005 350), 0 0 0 4px var(--color-primary);\n";
|
|
46
|
+
};
|
|
47
|
+
export type ThemeName = keyof typeof themes;
|
|
48
|
+
/**
|
|
49
|
+
* Apply a theme to an element by setting CSS custom properties
|
|
50
|
+
*
|
|
51
|
+
* @param element - The element to apply the theme to (usually document.documentElement)
|
|
52
|
+
* @param theme - Theme name or custom CSS properties string
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyTheme(element: HTMLElement, theme: ThemeName | string): void;
|
|
55
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,uqDAmDzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,6zDAmD1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,usDAmDtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,0rDAmDvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,ssDAmDrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAYhF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types and interfaces for DuskMoon Elements
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Represents a CSS property value with support for CSS custom properties
|
|
6
|
+
*/
|
|
7
|
+
export type CSSValue = string | number;
|
|
8
|
+
/**
|
|
9
|
+
* Size variants available for elements
|
|
10
|
+
*/
|
|
11
|
+
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
/**
|
|
13
|
+
* Color variants available for elements
|
|
14
|
+
*/
|
|
15
|
+
export type Variant = 'primary' | 'secondary' | 'tertiary' | 'ghost' | 'outline';
|
|
16
|
+
/**
|
|
17
|
+
* Validation state for form elements
|
|
18
|
+
*/
|
|
19
|
+
export type ValidationState = 'valid' | 'invalid' | 'pending' | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Base props shared by all elements
|
|
22
|
+
*/
|
|
23
|
+
export interface BaseElementProps {
|
|
24
|
+
/** Whether the element is disabled */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Additional CSS classes */
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Props for elements with size variants
|
|
31
|
+
*/
|
|
32
|
+
export interface SizableProps {
|
|
33
|
+
/** Size variant */
|
|
34
|
+
size?: Size;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Props for elements with color variants
|
|
38
|
+
*/
|
|
39
|
+
export interface VariantProps {
|
|
40
|
+
/** Color variant */
|
|
41
|
+
variant?: Variant;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Props for form elements
|
|
45
|
+
*/
|
|
46
|
+
export interface FormElementProps extends BaseElementProps {
|
|
47
|
+
/** Name attribute for form submission */
|
|
48
|
+
name?: string;
|
|
49
|
+
/** Current value */
|
|
50
|
+
value?: string;
|
|
51
|
+
/** Whether the field is required */
|
|
52
|
+
required?: boolean;
|
|
53
|
+
/** Whether the field is readonly */
|
|
54
|
+
readonly?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props for validatable form elements
|
|
58
|
+
*/
|
|
59
|
+
export interface ValidatableProps {
|
|
60
|
+
/** Current validation state */
|
|
61
|
+
validationState?: ValidationState;
|
|
62
|
+
/** Error message to display */
|
|
63
|
+
errorMessage?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Event detail for value change events
|
|
67
|
+
*/
|
|
68
|
+
export interface ValueChangeEventDetail<T = string> {
|
|
69
|
+
/** The new value */
|
|
70
|
+
value: T;
|
|
71
|
+
/** The previous value */
|
|
72
|
+
previousValue?: T;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Type for attribute converters
|
|
76
|
+
*/
|
|
77
|
+
export interface AttributeConverter<T> {
|
|
78
|
+
/** Convert from attribute string to property value */
|
|
79
|
+
fromAttribute: (value: string | null) => T;
|
|
80
|
+
/** Convert from property value to attribute string */
|
|
81
|
+
toAttribute: (value: T) => string | null;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/B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,MAAM;IAChD,oBAAoB;IACpB,KAAK,EAAE,CAAC,CAAC;IACT,yBAAyB;IACzB,aAAa,CAAC,EAAE,CAAC,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,sDAAsD;IACtD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC;IAC3C,sDAAsD;IACtD,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAC;CAC1C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for DuskMoon form elements
|
|
3
|
+
*
|
|
4
|
+
* Provides composable validator functions that can be used with
|
|
5
|
+
* any form element supporting ValidationState and errorMessage props.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { validate, validators } from '@duskmoon-dev/el-base';
|
|
10
|
+
*
|
|
11
|
+
* const result = validate('hello@example.com', [
|
|
12
|
+
* validators.required('Email is required'),
|
|
13
|
+
* validators.email('Must be a valid email'),
|
|
14
|
+
* ]);
|
|
15
|
+
*
|
|
16
|
+
* // result = { state: 'valid', message: undefined }
|
|
17
|
+
*
|
|
18
|
+
* inputEl.validationState = result.state;
|
|
19
|
+
* inputEl.errorMessage = result.message ?? '';
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { ValidationState } from './types.js';
|
|
23
|
+
/**
|
|
24
|
+
* Result of a validation check
|
|
25
|
+
*/
|
|
26
|
+
export interface ValidationResult {
|
|
27
|
+
state: NonNullable<ValidationState>;
|
|
28
|
+
message: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A validator function takes a value and returns an error message
|
|
32
|
+
* if invalid, or undefined/null if valid.
|
|
33
|
+
*/
|
|
34
|
+
export type Validator<T = string> = (value: T) => string | undefined | null;
|
|
35
|
+
/**
|
|
36
|
+
* Run a value through a list of validators, returning on the first failure.
|
|
37
|
+
* Returns { state: 'valid' } if all pass, { state: 'invalid', message } on first failure.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validate<T = string>(value: T, rules: Validator<T>[]): ValidationResult;
|
|
40
|
+
/**
|
|
41
|
+
* Run a value through an async validator.
|
|
42
|
+
* Sets state to 'pending' during execution.
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateAsync<T = string>(value: T, rules: Validator<T>[], asyncRule: (value: T) => Promise<string | undefined | null>): Promise<ValidationResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Built-in validators for common patterns
|
|
47
|
+
*/
|
|
48
|
+
export declare const validators: {
|
|
49
|
+
/** Requires a non-empty value */
|
|
50
|
+
readonly required: (message?: string) => Validator<string>;
|
|
51
|
+
/** Requires a minimum string length */
|
|
52
|
+
readonly minLength: (min: number, message?: string) => Validator<string>;
|
|
53
|
+
/** Requires a maximum string length */
|
|
54
|
+
readonly maxLength: (max: number, message?: string) => Validator<string>;
|
|
55
|
+
/** Requires a value matching a regex pattern */
|
|
56
|
+
readonly pattern: (regex: RegExp, message?: string) => Validator<string>;
|
|
57
|
+
/** Requires a valid email address */
|
|
58
|
+
readonly email: (message?: string) => Validator<string>;
|
|
59
|
+
/** Requires a numeric value within a range */
|
|
60
|
+
readonly range: (min: number, max: number, message?: string) => Validator<string>;
|
|
61
|
+
/** Custom validator from a predicate function */
|
|
62
|
+
readonly custom: <T = string>(predicate: (value: T) => boolean, message: string) => Validator<T>;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,eAA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CAAC,CAAC;CAG3E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@duskmoon-dev/el-base",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prebuild": "bun run clean",
|
|
20
|
+
"build": "bun run build:esm && bun run build:cjs && bun run build:types",
|
|
21
|
+
"build:esm": "bun build ./src/index.ts --outdir ./dist/esm --format esm --sourcemap",
|
|
22
|
+
"build:cjs": "bun build ./src/index.ts --outdir ./dist/cjs --format cjs --sourcemap",
|
|
23
|
+
"build:types": "tsc --emitDeclarationOnly --outDir ./dist/types",
|
|
24
|
+
"dev": "bun build ./src/index.ts --outdir ./dist/esm --format esm --sourcemap --watch",
|
|
25
|
+
"clean": "del-cli dist",
|
|
26
|
+
"test": "bun test",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"format": "prettier --write 'src/**/*.ts' '*.json' '*.md'",
|
|
29
|
+
"format:check": "prettier --check 'src/**/*.ts' '*.json' '*.md'",
|
|
30
|
+
"lint": "eslint src",
|
|
31
|
+
"lint:check": "eslint src --max-warnings 0",
|
|
32
|
+
"lint:fix": "eslint src --fix",
|
|
33
|
+
"release": "bun publish",
|
|
34
|
+
"release:dry-run": "bun publish --dry-run"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "^5.7.2"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"duskmoon-dev",
|
|
44
|
+
"duskmoon",
|
|
45
|
+
"custom-elements",
|
|
46
|
+
"customelements",
|
|
47
|
+
"web-components",
|
|
48
|
+
"webcomponents",
|
|
49
|
+
"html"
|
|
50
|
+
]
|
|
51
|
+
}
|