@acorex/core 22.1.0-next.9 → 22.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.
@@ -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;
@@ -34,6 +34,8 @@ interface AXLocaleProfile {
34
34
  week: {
35
35
  startsOn: number;
36
36
  weekends: number[];
37
+ /** Number of characters shown for weekday headers in calendar views (e.g. 1 for fa, 2 for en). */
38
+ weekdayLabelLength: number;
37
39
  };
38
40
  clock: {
39
41
  format24Hour: boolean;
@@ -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 querySelector;
91
- private searchValue;
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 query selector.
111
+ * Highlights all occurrences of a search value within the elements matching the provided target.
94
112
  *
95
- * @param querySelector - CSS selector to identify target elements.
96
- * @param searchValue - Text to search and highlight.
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(querySelector: string, searchValue: string): void;
118
+ highlight(target: AXHighlightTarget, term: string | readonly string[], options?: AXHighlightOptions): number;
99
119
  /**
100
- * Resets highlighted text within the elements matching the query selector.
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 querySelector - CSS selector to clear. Falls back to the last selector used by `highlight`.
123
+ * @param target - CSS selector, element, or elements to clear.
103
124
  */
104
- clear(querySelector?: string): void;
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 applyHighlight;
107
- private recursivelyHighlight;
108
- private createHighlightedHTML;
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 };