@acorex/core 22.1.0-next.9 → 22.1.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/fesm2022/acorex-core-date-time.mjs +30 -16
- package/fesm2022/acorex-core-date-time.mjs.map +1 -1
- package/fesm2022/acorex-core-locale.mjs +3 -0
- package/fesm2022/acorex-core-locale.mjs.map +1 -1
- package/fesm2022/acorex-core-theme-builder.mjs +1339 -0
- package/fesm2022/acorex-core-theme-builder.mjs.map +1 -0
- package/fesm2022/acorex-core-translation.mjs +3 -6
- package/fesm2022/acorex-core-translation.mjs.map +1 -1
- package/fesm2022/acorex-core-utils.mjs +250 -74
- package/fesm2022/acorex-core-utils.mjs.map +1 -1
- package/package.json +7 -2
- package/theme-builder/README.md +53 -0
- package/types/acorex-core-date-time.d.ts +5 -0
- package/types/acorex-core-locale.d.ts +2 -0
- package/types/acorex-core-theme-builder.d.ts +42 -0
- package/types/acorex-core-utils.d.ts +52 -14
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @acorex/core/theme-builder
|
|
2
|
+
|
|
3
|
+
Secondary entry point of `@acorex/core`. Import from `@acorex/core/theme-builder`.
|
|
4
|
+
|
|
5
|
+
Generate a complete ACoreX theme CSS file from a flat map of role seed colors.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createTheme } from '@acorex/core/theme-builder';
|
|
11
|
+
|
|
12
|
+
// Full theme with defaults for omitted roles
|
|
13
|
+
const { css } = createTheme();
|
|
14
|
+
|
|
15
|
+
// Custom theme — only specify the roles you want to override
|
|
16
|
+
const { css: brandedCss, palette } = createTheme({
|
|
17
|
+
primary: '#2b7fff',
|
|
18
|
+
secondary: '#6a7282',
|
|
19
|
+
success: '#00bc7d',
|
|
20
|
+
warning: '#fd9a00',
|
|
21
|
+
danger: '#ff2056',
|
|
22
|
+
surface: '#c2c2c2',
|
|
23
|
+
accent: '#06b6d4',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Write css to theme.css in your app
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Role colors
|
|
30
|
+
|
|
31
|
+
Supported roles: `primary`, `secondary`, `success`, `warning`, `danger`, `surface`, `accent`, `accent1`–`accent6`.
|
|
32
|
+
|
|
33
|
+
Each provided color is applied to both light and dark modes. Dark shades are derived automatically. Omitted roles use the packaged default seeds.
|
|
34
|
+
|
|
35
|
+
## Options
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
createTheme(colors, {
|
|
39
|
+
/** 'file' (default) — complete stylesheet with :root, .ax-dark, and Tailwind layer */
|
|
40
|
+
target: 'file',
|
|
41
|
+
/** 'preview' — scoped CSS variables for live preview injection */
|
|
42
|
+
target: 'preview',
|
|
43
|
+
scope: { light: ':root', dark: '.ax-dark' },
|
|
44
|
+
roles: ['primary', 'secondary'], // preview only: limit emitted roles
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Return value
|
|
49
|
+
|
|
50
|
+
`createTheme` returns:
|
|
51
|
+
|
|
52
|
+
- `css` — the generated stylesheet string
|
|
53
|
+
- `palette` — generated shade scales (`50`–`950`, `on`, `on-contrast`) for light and dark modes
|
|
@@ -411,6 +411,11 @@ declare class AXSolarHijriCalendar extends AXCalendar {
|
|
|
411
411
|
monthOfYear(date: Date): number;
|
|
412
412
|
add(date: Date, unit: TimeUnit, amount: number): AXDateTime;
|
|
413
413
|
set(date: Date, unit: TimeUnit, value: number): AXDateTime;
|
|
414
|
+
/**
|
|
415
|
+
* Builds a Date from converted civil Y/M/D while keeping the original time.
|
|
416
|
+
* Assigning year/month/day on an existing Date sequentially overflows (e.g. Aug 31 → Feb).
|
|
417
|
+
*/
|
|
418
|
+
private withCivilDate;
|
|
414
419
|
startOf(date: Date, unit: TimeUnit): AXDateTime;
|
|
415
420
|
endOf(date: Date, unit: TimeUnit): AXDateTime;
|
|
416
421
|
parse(value: string): AXDateTime;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type AXThemeBuilderColors = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'surface' | 'accent' | 'accent1' | 'accent2' | 'accent3' | 'accent4' | 'accent5' | 'accent6';
|
|
2
|
+
type AXThemeBuilderColorVariants = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | '950' | 'on' | 'on-contrast';
|
|
3
|
+
type AXThemeBuilderPalette = Record<AXThemeBuilderColors, Record<AXThemeBuilderColorVariants, string>>;
|
|
4
|
+
type AXThemeBuilderFullPalette = {
|
|
5
|
+
light: AXThemeBuilderPalette;
|
|
6
|
+
dark: AXThemeBuilderPalette;
|
|
7
|
+
};
|
|
8
|
+
type AXThemeBuilderBaseColors = {
|
|
9
|
+
light: Record<AXThemeBuilderColors, string>;
|
|
10
|
+
dark: Record<AXThemeBuilderColors, string>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type AXThemeColors = Partial<Record<AXThemeBuilderColors, string>>;
|
|
14
|
+
interface AXCreateThemeOptions {
|
|
15
|
+
/** 'file' (default) emits a complete stylesheet with :root/.ax-dark plus the Tailwind layer.
|
|
16
|
+
* 'preview' emits variables only, scoped to `scope`, for injecting into a live page. */
|
|
17
|
+
target?: 'file' | 'preview';
|
|
18
|
+
/** Selectors used when target is 'preview'. */
|
|
19
|
+
scope?: {
|
|
20
|
+
light: string;
|
|
21
|
+
dark: string;
|
|
22
|
+
};
|
|
23
|
+
/** Roles to emit when target is 'preview'. Defaults to all roles. */
|
|
24
|
+
roles?: AXThemeBuilderColors[];
|
|
25
|
+
}
|
|
26
|
+
interface AXTheme {
|
|
27
|
+
/** The generated CSS. */
|
|
28
|
+
css: string;
|
|
29
|
+
/** Generated shade scales per role, for both modes. */
|
|
30
|
+
palette: AXThemeBuilderFullPalette;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an ACoreX theme from a flat map of role seed colors.
|
|
34
|
+
*
|
|
35
|
+
* Each provided color is applied to both light and dark modes; dark shades are
|
|
36
|
+
* derived via the dark-palette tone mapping. Omitted roles fall back to the
|
|
37
|
+
* packaged default seeds (which may differ per mode for `secondary`, `danger`, and `surface`).
|
|
38
|
+
*/
|
|
39
|
+
declare function createTheme(colors?: AXThemeColors, options?: AXCreateThemeOptions): AXTheme;
|
|
40
|
+
|
|
41
|
+
export { createTheme };
|
|
42
|
+
export type { AXCreateThemeOptions, AXTheme, AXThemeBuilderBaseColors, AXThemeBuilderColorVariants, AXThemeBuilderColors, AXThemeBuilderFullPalette, AXThemeBuilderPalette, AXThemeColors };
|
|
@@ -83,33 +83,71 @@ declare function debounceAsync<T extends (...args: any[]) => Promise<any>>(fn: T
|
|
|
83
83
|
*/
|
|
84
84
|
declare function fallbackChain<T>(tasks: Array<() => Promise<T>>): Promise<T>;
|
|
85
85
|
|
|
86
|
+
type AXHighlightTarget = string | Element | readonly Element[];
|
|
87
|
+
interface AXHighlightOptions {
|
|
88
|
+
/** When false (default), matching is case-insensitive. */
|
|
89
|
+
caseSensitive?: boolean;
|
|
90
|
+
/** When true, only match whole words. */
|
|
91
|
+
wholeWord?: boolean;
|
|
92
|
+
/** Maximum number of matches to highlight across all targets. */
|
|
93
|
+
maxMatches?: number;
|
|
94
|
+
/** CSS class applied to highlighted match spans. */
|
|
95
|
+
highlightClass?: string;
|
|
96
|
+
/** CSS class applied to the wrapper span around highlighted text nodes. */
|
|
97
|
+
wrapperClass?: string;
|
|
98
|
+
/** Parent tag names whose text content is skipped. */
|
|
99
|
+
ignoredTags?: readonly string[];
|
|
100
|
+
}
|
|
86
101
|
/**
|
|
87
102
|
* Service for applying and resetting text highlighting within specified HTML elements.
|
|
88
103
|
*/
|
|
89
104
|
declare class AXHighlightService {
|
|
90
|
-
private
|
|
91
|
-
private
|
|
105
|
+
private readonly document;
|
|
106
|
+
private readonly platformId;
|
|
107
|
+
private readonly selectorStates;
|
|
108
|
+
private readonly elementStates;
|
|
109
|
+
private readonly trackedElements;
|
|
92
110
|
/**
|
|
93
|
-
* Highlights all occurrences of a search value within the elements matching the provided
|
|
111
|
+
* Highlights all occurrences of a search value within the elements matching the provided target.
|
|
94
112
|
*
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
113
|
+
* @param target - CSS selector, a single element, or an array of elements to search within.
|
|
114
|
+
* @param term - Text or list of texts to search and highlight.
|
|
115
|
+
* @param options - Optional highlight behavior configuration.
|
|
116
|
+
* @returns The number of matches highlighted.
|
|
97
117
|
*/
|
|
98
|
-
highlight(
|
|
118
|
+
highlight(target: AXHighlightTarget, term: string | readonly string[], options?: AXHighlightOptions): number;
|
|
99
119
|
/**
|
|
100
|
-
* Resets highlighted text within the elements matching the
|
|
120
|
+
* Resets highlighted text within the elements matching the target.
|
|
121
|
+
* When no target is provided, clears all highlights registered by this service.
|
|
101
122
|
*
|
|
102
|
-
* @param
|
|
123
|
+
* @param target - CSS selector, element, or elements to clear.
|
|
103
124
|
*/
|
|
104
|
-
clear(
|
|
125
|
+
clear(target?: AXHighlightTarget): void;
|
|
126
|
+
private toElementArray;
|
|
127
|
+
private normalizeTerms;
|
|
128
|
+
private resolveOptions;
|
|
129
|
+
private registerState;
|
|
130
|
+
private resolveRoots;
|
|
105
131
|
private createSearchRegex;
|
|
106
|
-
private
|
|
107
|
-
private
|
|
108
|
-
private
|
|
132
|
+
private collectTextNodes;
|
|
133
|
+
private highlightTextNode;
|
|
134
|
+
private clearSelector;
|
|
135
|
+
private clearElement;
|
|
136
|
+
private unwrapHighlight;
|
|
109
137
|
static ɵfac: i0.ɵɵFactoryDeclaration<AXHighlightService, never>;
|
|
110
138
|
static ɵprov: i0.ɵɵInjectableDeclaration<AXHighlightService>;
|
|
111
139
|
}
|
|
112
140
|
|
|
141
|
+
interface AXHighlightSegment {
|
|
142
|
+
text: string;
|
|
143
|
+
match: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Splits text into highlighted and non-highlighted segments for template rendering.
|
|
147
|
+
* Uses the same matching semantics as {@link AXHighlightService}.
|
|
148
|
+
*/
|
|
149
|
+
declare function splitHighlightSegments(text: string, term: string | readonly string[], options?: AXHighlightOptions): AXHighlightSegment[];
|
|
150
|
+
|
|
113
151
|
/** ACoreX layout size classes applied on a host or container. */
|
|
114
152
|
declare const AX_SIZE_CLASSES: readonly ["ax-xs", "ax-sm", "ax-md", "ax-lg", "ax-xl"];
|
|
115
153
|
type AXSizeClass = (typeof AX_SIZE_CLASSES)[number];
|
|
@@ -149,5 +187,5 @@ declare function getWordBoundsAtPosition(str: string, position: number): {
|
|
|
149
187
|
end: number;
|
|
150
188
|
};
|
|
151
189
|
|
|
152
|
-
export { AXAutoUnsubscriber, AXColorUtil, AXDrawingUtil, AXHighlightService, AXHtmlUtil, AXUnsubscriber, AX_SIZE_CLASSES, debounceAsync, delay, fallbackChain, getWordBoundsAtPosition, pollUntil, pollUntilAbortable, retryUntil, throttleAsync, waitFor };
|
|
153
|
-
export type { AXBoundingClientRect, AXClosestAxSizeMatch, AXColorFormat, AXColorMode, AXPoint, AXSizeClass };
|
|
190
|
+
export { AXAutoUnsubscriber, AXColorUtil, AXDrawingUtil, AXHighlightService, AXHtmlUtil, AXUnsubscriber, AX_SIZE_CLASSES, debounceAsync, delay, fallbackChain, getWordBoundsAtPosition, pollUntil, pollUntilAbortable, retryUntil, splitHighlightSegments, throttleAsync, waitFor };
|
|
191
|
+
export type { AXBoundingClientRect, AXClosestAxSizeMatch, AXColorFormat, AXColorMode, AXHighlightOptions, AXHighlightSegment, AXHighlightTarget, AXPoint, AXSizeClass };
|