@rokkit/core 1.0.2 → 1.0.3
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/dist/calendar.d.ts +10 -0
- package/dist/colors/index.d.ts +47 -0
- package/dist/connector.d.ts +8 -0
- package/dist/constants.d.ts +80 -0
- package/dist/events.d.ts +12 -0
- package/dist/field-mapper.d.ts +60 -0
- package/dist/index.d.ts +13 -0
- package/dist/key-event-map.d.ts +18 -0
- package/dist/mapped-items.d.ts +14 -0
- package/dist/mapping.d.ts +14 -0
- package/dist/nested.d.ts +9 -0
- package/dist/string.d.ts +59 -0
- package/dist/theme.d.ts +107 -0
- package/dist/ticks.d.ts +10 -0
- package/dist/types.d.ts +300 -0
- package/dist/utils.d.ts +104 -0
- package/dist/vite/icon-collections.d.ts +32 -0
- package/dist/vite/index.d.ts +1 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jerry Thomas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the days in the month.
|
|
3
|
+
*
|
|
4
|
+
* @param {Date} value
|
|
5
|
+
* @param {Array} holidays
|
|
6
|
+
* @param {boolean} fixed
|
|
7
|
+
* @returns {import('./types').CalendarDay[]}
|
|
8
|
+
*/
|
|
9
|
+
export function getCalendarDays(value: Date, holidays?: any[], fixed?: boolean): import("./types").CalendarDay[];
|
|
10
|
+
export const weekdays: string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PresetMiniColors } from '@unocss/preset-mini/colors';
|
|
2
|
+
import extraColors from './extra.json';
|
|
3
|
+
export declare const shades: number[];
|
|
4
|
+
export declare const defaultPalette: string[];
|
|
5
|
+
export declare const syntaxColors: {
|
|
6
|
+
"one-dark": {
|
|
7
|
+
dark: {
|
|
8
|
+
"--tab-size": string;
|
|
9
|
+
"--code-fill": string;
|
|
10
|
+
"--code-normal": string;
|
|
11
|
+
"--code-string": string;
|
|
12
|
+
"--code-number": string;
|
|
13
|
+
"--code-atrule": string;
|
|
14
|
+
"--code-keyword": string;
|
|
15
|
+
"--code-comment": string;
|
|
16
|
+
"--code-property": string;
|
|
17
|
+
"--code-selector": string;
|
|
18
|
+
"--code-operator": string;
|
|
19
|
+
"--code-function": string;
|
|
20
|
+
"--code-gutter-marker": string;
|
|
21
|
+
"--code-gutter-z2": string;
|
|
22
|
+
"--code-cursor": string;
|
|
23
|
+
"--code-cursor-block": string;
|
|
24
|
+
"--code-linenumbers": string;
|
|
25
|
+
};
|
|
26
|
+
light: {
|
|
27
|
+
"--tab-size": string;
|
|
28
|
+
"--code-fill": string;
|
|
29
|
+
"--code-normal": string;
|
|
30
|
+
"--code-string": string;
|
|
31
|
+
"--code-number": string;
|
|
32
|
+
"--code-atrule": string;
|
|
33
|
+
"--code-keyword": string;
|
|
34
|
+
"--code-comment": string;
|
|
35
|
+
"--code-property": string;
|
|
36
|
+
"--code-selector": string;
|
|
37
|
+
"--code-operator": string;
|
|
38
|
+
"--code-function": string;
|
|
39
|
+
"--code-gutter-marker": string;
|
|
40
|
+
"--code-gutter-z2": string;
|
|
41
|
+
"--code-cursor": string;
|
|
42
|
+
"--code-cursor-block": string;
|
|
43
|
+
"--code-linenumbers": string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare const defaultColors: PresetMiniColors & typeof extraColors;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs an array of line types for tree visualization
|
|
3
|
+
* @param {boolean} hasChildren - Whether the node has children
|
|
4
|
+
* @param {import('./types').LineType[]} parentTypes - Types from parent nodes
|
|
5
|
+
* @param {import('./types').LineType} position - Current position type
|
|
6
|
+
* @returns {import('./types').LineType[]} Array of line types
|
|
7
|
+
*/
|
|
8
|
+
export function getLineTypes(hasChildren?: boolean, parentTypes?: import("./types").LineType[], position?: import("./types").LineType): import("./types").LineType[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a state icon mapping from a list of icon names
|
|
3
|
+
*
|
|
4
|
+
* @param {string[]} icons
|
|
5
|
+
* @returns {import('./types').StateIcons}
|
|
6
|
+
*/
|
|
7
|
+
export function stateIconsFromNames(icons: string[]): import("./types").StateIcons;
|
|
8
|
+
export const DATA_IMAGE_REGEX: RegExp;
|
|
9
|
+
export const ITEM_SNIPPET: "itemContent";
|
|
10
|
+
export const GROUP_SNIPPET: "groupContent";
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use BASE_FIELDS from @rokkit/core instead.
|
|
13
|
+
* Retained for legacy ListController/FieldMapper/Proxy consumers (Toolbar, Table).
|
|
14
|
+
* Will be removed when those components migrate to Wrapper+Navigator.
|
|
15
|
+
* @type {import('./types).FieldMapping} Fields
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_FIELDS: any;
|
|
18
|
+
export namespace BASE_FIELDS {
|
|
19
|
+
let id: string;
|
|
20
|
+
let value: string;
|
|
21
|
+
let label: string;
|
|
22
|
+
let icon: string;
|
|
23
|
+
let avatar: string;
|
|
24
|
+
let subtext: string;
|
|
25
|
+
let tooltip: string;
|
|
26
|
+
let badge: string;
|
|
27
|
+
let shortcut: string;
|
|
28
|
+
let children: string;
|
|
29
|
+
let type: string;
|
|
30
|
+
let snippet: string;
|
|
31
|
+
let href: string;
|
|
32
|
+
let hrefTarget: string;
|
|
33
|
+
let disabled: string;
|
|
34
|
+
let expanded: string;
|
|
35
|
+
let selected: string;
|
|
36
|
+
}
|
|
37
|
+
export const DEFAULT_ICONS: string[];
|
|
38
|
+
export namespace DEFAULT_OPTIONS {
|
|
39
|
+
let id_1: string;
|
|
40
|
+
export { id_1 as id };
|
|
41
|
+
let label_1: string;
|
|
42
|
+
export { label_1 as label };
|
|
43
|
+
let value_1: string;
|
|
44
|
+
export { value_1 as value };
|
|
45
|
+
export let checked: string;
|
|
46
|
+
}
|
|
47
|
+
export namespace DEFAULT_KEYMAP {
|
|
48
|
+
let ArrowRight: string;
|
|
49
|
+
let ArrowLeft: string;
|
|
50
|
+
let ArrowDown: string;
|
|
51
|
+
let ArrowUp: string;
|
|
52
|
+
let Enter: string;
|
|
53
|
+
let Escape: string;
|
|
54
|
+
}
|
|
55
|
+
export namespace DEFAULT_THEME_MAPPING {
|
|
56
|
+
let surface: string;
|
|
57
|
+
let primary: string;
|
|
58
|
+
let secondary: string;
|
|
59
|
+
let accent: string;
|
|
60
|
+
let success: string;
|
|
61
|
+
let warning: string;
|
|
62
|
+
let danger: string;
|
|
63
|
+
let error: string;
|
|
64
|
+
let info: string;
|
|
65
|
+
}
|
|
66
|
+
export namespace TONE_MAP {
|
|
67
|
+
let z0: number;
|
|
68
|
+
let z1: number;
|
|
69
|
+
let z2: number;
|
|
70
|
+
let z3: number;
|
|
71
|
+
let z4: number;
|
|
72
|
+
let z5: number;
|
|
73
|
+
let z6: number;
|
|
74
|
+
let z7: number;
|
|
75
|
+
let z8: number;
|
|
76
|
+
let z9: number;
|
|
77
|
+
let z10: number;
|
|
78
|
+
}
|
|
79
|
+
export const DEFAULT_STATE_ICONS: any;
|
|
80
|
+
export { defaultColors, syntaxColors, shades, defaultPalette } from "./colors/index";
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an emitter object from the given properties.
|
|
3
|
+
*
|
|
4
|
+
* - Filters attributes that start with 'on' and are functions,
|
|
5
|
+
* - Returns an object with keys that are the event names (without the 'on' prefix)
|
|
6
|
+
* - If a default event is not present in the props, it will be set to a no-op function.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} props - The properties object to filter.
|
|
9
|
+
* @param {Array<string>} defaults - An array of default events.
|
|
10
|
+
* @returns {import('./types.js').EventHandlers} The emitter object.
|
|
11
|
+
*/
|
|
12
|
+
export function createEmitter(props: Object, defaults?: Array<string>): import("./types.js").EventHandlers;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export class FieldMapper {
|
|
2
|
+
constructor(fields?: any);
|
|
3
|
+
hasIcon: ((obj: unknown) => obj is {
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
}) | undefined;
|
|
6
|
+
hasImage: ((obj: unknown) => obj is {
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
}) | undefined;
|
|
9
|
+
hasValue: ((obj: unknown) => obj is {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
}) | undefined;
|
|
12
|
+
hasLabel: ((obj: unknown) => obj is {
|
|
13
|
+
[x: string]: unknown;
|
|
14
|
+
}) | undefined;
|
|
15
|
+
hasComponent: ((obj: unknown) => obj is {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
}) | undefined;
|
|
18
|
+
hasCurrency: ((obj: unknown) => obj is {
|
|
19
|
+
[x: string]: unknown;
|
|
20
|
+
}) | undefined;
|
|
21
|
+
withPrefix: ((x: any) => string) | undefined;
|
|
22
|
+
excludeFlags: (<U extends Partial<Record<any, any>>>(obj: any extends keyof U ? U : never) => any extends keyof U ? Omit<U, any> : never) | undefined;
|
|
23
|
+
getChildMapper(): null;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
private prop;
|
|
28
|
+
/**
|
|
29
|
+
* Gets a mapped attribute from the original item
|
|
30
|
+
*
|
|
31
|
+
* @param {string} fieldName - Name of the field to get
|
|
32
|
+
* @returns {any|null} - The attribute value or null if not found
|
|
33
|
+
*/
|
|
34
|
+
get(fieldName: string, value: any, defaultValue?: null): any | null;
|
|
35
|
+
set fields(fields: any);
|
|
36
|
+
get fields(): any;
|
|
37
|
+
getIcon(value: any): string | null;
|
|
38
|
+
getValue(value: any): any;
|
|
39
|
+
getFormattedText(value: any, formatter: any): any;
|
|
40
|
+
hasChildren(item: any): item is never;
|
|
41
|
+
isNested(items: any): boolean;
|
|
42
|
+
getChildren(item: any): never[];
|
|
43
|
+
/**
|
|
44
|
+
* Finds children by an index path
|
|
45
|
+
*
|
|
46
|
+
* @param {Array<Object>} items
|
|
47
|
+
* @param {Array<number>} path
|
|
48
|
+
* @returns {Array<Object>}
|
|
49
|
+
*/
|
|
50
|
+
getChildrenByPath(items: Array<Object>, path?: Array<number>): Array<Object>;
|
|
51
|
+
/**
|
|
52
|
+
* Finds an item by an index path
|
|
53
|
+
*
|
|
54
|
+
* @param {Array<Object>} items
|
|
55
|
+
* @param {Array<number>} path
|
|
56
|
+
* @returns {Object|null}
|
|
57
|
+
*/
|
|
58
|
+
getItemByPath(items: Array<Object>, path?: Array<number>): Object | null;
|
|
59
|
+
#private;
|
|
60
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./utils.js";
|
|
4
|
+
export * from "./nested.js";
|
|
5
|
+
export * from "./string.js";
|
|
6
|
+
export * from "./theme.js";
|
|
7
|
+
export { FieldMapper } from "./field-mapper.js";
|
|
8
|
+
export { createEmitter } from "./events.js";
|
|
9
|
+
export { getLineTypes } from "./connector.js";
|
|
10
|
+
export { generateTicks } from "./ticks.js";
|
|
11
|
+
export { getNestedFields } from "./mapping.js";
|
|
12
|
+
export { getItemAtIndex, getIndexForItem } from "./mapped-items.js";
|
|
13
|
+
export { weekdays, getCalendarDays } from "./calendar.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to manage key event mappings.
|
|
3
|
+
*/
|
|
4
|
+
export class KeyEventMap {
|
|
5
|
+
mapping: {};
|
|
6
|
+
/**
|
|
7
|
+
* Add a new key mapping.
|
|
8
|
+
* @param {string} eventName - The event name.
|
|
9
|
+
* @param {Array<string>|RegExp} keys - The keys to match.
|
|
10
|
+
*/
|
|
11
|
+
add(eventName: string, keys: Array<string> | RegExp): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get the event name for a given key.
|
|
14
|
+
* @param {string} key - The key to match.
|
|
15
|
+
* @returns {string|null} - The event name or null if no match is found.
|
|
16
|
+
*/
|
|
17
|
+
getEventForKey(key: string): string | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get an item at a specific index
|
|
3
|
+
* @param {Array<any>} items
|
|
4
|
+
* @param {any} index
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function getItemAtIndex(items: Array<any>, index: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* Get the index for an item in an array
|
|
10
|
+
* @param {Array<any} items
|
|
11
|
+
* @param {any} item
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function getIndexForItem(items: Array<any>, item: any): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the attribute from the node
|
|
3
|
+
* @param {*} node
|
|
4
|
+
* @param {string} attr
|
|
5
|
+
* @returns {*}
|
|
6
|
+
*/
|
|
7
|
+
export function getAttribute(node: any, attr: string): any;
|
|
8
|
+
/**
|
|
9
|
+
* Fetches the fieldmapping for a child node
|
|
10
|
+
*
|
|
11
|
+
* @param {import('./types').FieldMapping} fields
|
|
12
|
+
* @returns {import('./types').FieldMapping}
|
|
13
|
+
*/
|
|
14
|
+
export function getNestedFields(fields: import("./types").FieldMapping): import("./types").FieldMapping;
|
package/dist/nested.d.ts
ADDED
package/dist/string.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capitalizes the first letter of input string
|
|
3
|
+
*
|
|
4
|
+
* @param {String} str
|
|
5
|
+
* @returns {String}
|
|
6
|
+
*/
|
|
7
|
+
export function toInitCapCase(text: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert a hyphen separated string to PascalCase
|
|
10
|
+
*
|
|
11
|
+
* @param {String} text
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export function toPascalCase(text: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a PascalCase string to snake case with separator as hyphen
|
|
17
|
+
*
|
|
18
|
+
* @param {string} text
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function toHyphenCase(text: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Simple comparison for two strings
|
|
24
|
+
*
|
|
25
|
+
* @param {String} a
|
|
26
|
+
* @param {String} b
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function compareStrings(a: string, b: string): 1 | 0 | -1;
|
|
30
|
+
/**
|
|
31
|
+
* Sort by splitting hyphen separated strings while keeping strings with same number of parts together
|
|
32
|
+
*
|
|
33
|
+
* @param {String} a hyphen separates string
|
|
34
|
+
* @param {String} b hyphen separates string
|
|
35
|
+
* @param {string} separator - separator to split the string
|
|
36
|
+
* @returns {Number} -1, 0, 1 based on comparison
|
|
37
|
+
*/
|
|
38
|
+
export function sortByParts(a: string, b: string, separator?: string): number;
|
|
39
|
+
/**
|
|
40
|
+
* Generates a unique id from current timestamp
|
|
41
|
+
*
|
|
42
|
+
* @returns {String} timestamp based unique id
|
|
43
|
+
*/
|
|
44
|
+
export function uniqueId(prefix?: string, separator?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Removes undefined and null values from the input object.
|
|
47
|
+
*
|
|
48
|
+
* @param {Object} obj
|
|
49
|
+
* @returns {Object}
|
|
50
|
+
*/
|
|
51
|
+
export function compact(obj: Object): Object;
|
|
52
|
+
/**
|
|
53
|
+
* Converts an input number into it's hexadecimal representation, with optional left padded zeroes based on the `size`
|
|
54
|
+
*
|
|
55
|
+
* @param {number} value
|
|
56
|
+
* @param {number} size
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
export function toHexString(value: number, size?: number): string;
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate shades for a color using css varuable
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name
|
|
5
|
+
* @param {string} modifier
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function shadesOf(name: any, modifier?: string): {
|
|
9
|
+
DEFAULT: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Constructs and returns the light and dark theme variants based on provided color mapping and color definitions.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} [mapping=DEFAULT_THEME_MAPPING] - An object mapping variant names to color property names.
|
|
15
|
+
* @param {Object} [colors=defaultColors] - The object containing default color definitions.
|
|
16
|
+
* @returns {Array<Array>} An array containing two arrays, one for the light theme variant and another for the dark theme.
|
|
17
|
+
*/
|
|
18
|
+
export declare function themeRules(mapping?: {
|
|
19
|
+
surface: string;
|
|
20
|
+
primary: string;
|
|
21
|
+
secondary: string;
|
|
22
|
+
accent: string;
|
|
23
|
+
success: string;
|
|
24
|
+
warning: string;
|
|
25
|
+
danger: string;
|
|
26
|
+
error: string;
|
|
27
|
+
info: string;
|
|
28
|
+
}, colors?: any): {};
|
|
29
|
+
/**
|
|
30
|
+
* Generates UnoCSS shortcut definitions for semantic tones with bg, border, text.
|
|
31
|
+
* @param {string} name - Color name (e.g., 'primary')
|
|
32
|
+
* @returns {Array} Array of shortcut definitions
|
|
33
|
+
*/
|
|
34
|
+
export declare function semanticShortcuts(name: any): (string[] | (RegExp | (([, variant, end]: [any, any, any]) => string))[] | (RegExp | (([, end]: [any, any]) => string))[])[];
|
|
35
|
+
/**
|
|
36
|
+
* Generates "on-color" text shortcuts for readable text on colored backgrounds.
|
|
37
|
+
*
|
|
38
|
+
* - `text-on-{name}` → high contrast text for use on z5+ backgrounds (always light text)
|
|
39
|
+
* - `text-on-{name}-muted` → slightly muted but still readable on z5+ backgrounds
|
|
40
|
+
*
|
|
41
|
+
* @param {string} name - Color name (e.g., 'primary', 'surface')
|
|
42
|
+
* @returns {Array} Array of shortcut definitions
|
|
43
|
+
*/
|
|
44
|
+
export declare function contrastShortcuts(name: any): (RegExp | (([, end]: [any, any]) => string))[][];
|
|
45
|
+
/**
|
|
46
|
+
* Theme class for managing color palettes, mappings, and semantic shortcuts.
|
|
47
|
+
*/
|
|
48
|
+
export declare class Theme {
|
|
49
|
+
#private;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {import('./types.js').ColorTheme} param0
|
|
53
|
+
*/
|
|
54
|
+
constructor({ colors, mapping }?: {
|
|
55
|
+
colors?: any;
|
|
56
|
+
mapping?: {
|
|
57
|
+
surface: string;
|
|
58
|
+
primary: string;
|
|
59
|
+
secondary: string;
|
|
60
|
+
accent: string;
|
|
61
|
+
success: string;
|
|
62
|
+
warning: string;
|
|
63
|
+
danger: string;
|
|
64
|
+
error: string;
|
|
65
|
+
info: string;
|
|
66
|
+
} | undefined;
|
|
67
|
+
});
|
|
68
|
+
get colors(): any;
|
|
69
|
+
set colors(colors: any);
|
|
70
|
+
get mapping(): {
|
|
71
|
+
surface: string;
|
|
72
|
+
primary: string;
|
|
73
|
+
secondary: string;
|
|
74
|
+
accent: string;
|
|
75
|
+
success: string;
|
|
76
|
+
warning: string;
|
|
77
|
+
danger: string;
|
|
78
|
+
error: string;
|
|
79
|
+
info: string;
|
|
80
|
+
};
|
|
81
|
+
set mapping(mapping: {
|
|
82
|
+
surface: string;
|
|
83
|
+
primary: string;
|
|
84
|
+
secondary: string;
|
|
85
|
+
accent: string;
|
|
86
|
+
success: string;
|
|
87
|
+
warning: string;
|
|
88
|
+
danger: string;
|
|
89
|
+
error: string;
|
|
90
|
+
info: string;
|
|
91
|
+
});
|
|
92
|
+
mapVariant(color: any, variant: any): {};
|
|
93
|
+
getColorRules(mapping?: null): {};
|
|
94
|
+
getPalette(mapping?: null): {};
|
|
95
|
+
getShortcuts(name: any): (string[] | (RegExp | (([, variant, end]: [any, any, any]) => string))[] | (RegExp | (([, end]: [any, any]) => string))[])[];
|
|
96
|
+
/**
|
|
97
|
+
* Generates CSS custom property declarations for the semantic z0–z10 tone scale.
|
|
98
|
+
*
|
|
99
|
+
* Returns a CSS string with two blocks:
|
|
100
|
+
* - `:root` — light-mode aliases (z0=50 … z10=950)
|
|
101
|
+
* - `[data-mode="dark"]` — dark-mode aliases (z0=950 … z10=50)
|
|
102
|
+
*
|
|
103
|
+
* These let consumers write `var(--color-primary-z5)` instead of hardcoding
|
|
104
|
+
* numeric shades, and the value automatically adapts to the active mode.
|
|
105
|
+
*/
|
|
106
|
+
getZScaleCSS(): string;
|
|
107
|
+
}
|
package/dist/ticks.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an array of tick marks for a range of values.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} lowerBound - The lower bound of the range.
|
|
5
|
+
* @param {number} upperBound - The upper bound of the range.
|
|
6
|
+
* @param {number} [minorTickStep=upperBound-lowerBound] - The step size for minor ticks.
|
|
7
|
+
* @param {number} [majorTickStep=1] - The step size for major ticks.
|
|
8
|
+
* @returns {import('./types').TickMark[]>} An array of tick mark objects.
|
|
9
|
+
*/
|
|
10
|
+
export function generateTicks(lowerBound: number, upperBound: number, minorTickStep?: number, majorTickStep?: number): import("./types").TickMark[];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
declare const _default: {};
|
|
2
|
+
export default _default;
|
|
3
|
+
export type LineType = "child" | "last" | "sibling" | "empty" | "icon";
|
|
4
|
+
/**
|
|
5
|
+
* An object where keys are event names and values are event handler functions.
|
|
6
|
+
*/
|
|
7
|
+
export type EventHandlers = {
|
|
8
|
+
[x: string]: Function;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Component map to be used to render the item.
|
|
12
|
+
*/
|
|
13
|
+
export type ComponentMap = {
|
|
14
|
+
[x: string]: import("svelte").SvelteComponent<Record<string, any>, any, any>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Options for the sort order of the column.
|
|
18
|
+
*/
|
|
19
|
+
export type SortOptions = "ascending" | "descending" | "none";
|
|
20
|
+
export type SelectionState = "checked" | "unchecked" | "indeterminate";
|
|
21
|
+
/**
|
|
22
|
+
* Options for the horizontal alignment of the column content.
|
|
23
|
+
*/
|
|
24
|
+
export type HorizontalAlignOptions = "left" | "middle" | "right";
|
|
25
|
+
/**
|
|
26
|
+
* Options for the action type of the column.
|
|
27
|
+
*/
|
|
28
|
+
export type ActionTypes = "select" | "edit" | "delete";
|
|
29
|
+
/**
|
|
30
|
+
* Structure to map custom fields for rendering. This is used to identofy the attributes for various purposes.
|
|
31
|
+
*/
|
|
32
|
+
export type FieldMapping = {
|
|
33
|
+
/**
|
|
34
|
+
* Unique id for the item
|
|
35
|
+
*/
|
|
36
|
+
id?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* the text to render
|
|
39
|
+
*/
|
|
40
|
+
text?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* the value associated with the item
|
|
43
|
+
*/
|
|
44
|
+
value?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* a URL
|
|
47
|
+
*/
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* icon to render
|
|
51
|
+
*/
|
|
52
|
+
icon?: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* the image to render
|
|
55
|
+
*/
|
|
56
|
+
image?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* children of the item
|
|
59
|
+
*/
|
|
60
|
+
children?: string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* summary of the item
|
|
63
|
+
*/
|
|
64
|
+
summary?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* notes for the item
|
|
67
|
+
*/
|
|
68
|
+
notes?: string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* additional properties
|
|
71
|
+
*/
|
|
72
|
+
props?: string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* item is open or closed
|
|
75
|
+
*/
|
|
76
|
+
isOpen?: string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* level of item
|
|
79
|
+
*/
|
|
80
|
+
level?: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* item is a parent
|
|
83
|
+
*/
|
|
84
|
+
parent?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* {string} [isDeleted='_deleted'] item is deleted
|
|
87
|
+
*/
|
|
88
|
+
currency?: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Field mapping to be used on children in the next level
|
|
91
|
+
*/
|
|
92
|
+
fields?: FieldMapping | undefined;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Column metadata for the table.
|
|
96
|
+
*/
|
|
97
|
+
export type ColumnMetadata = {
|
|
98
|
+
/**
|
|
99
|
+
* - The name of the column.
|
|
100
|
+
*/
|
|
101
|
+
name: string;
|
|
102
|
+
/**
|
|
103
|
+
* - The data type of the column (e.g., "string", "number", "date").
|
|
104
|
+
*/
|
|
105
|
+
dataType: string;
|
|
106
|
+
/**
|
|
107
|
+
* - Additional attributes for the column.
|
|
108
|
+
*/
|
|
109
|
+
fields?: FieldMapping | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* - The number of digits for numeric values (defaults to 0).
|
|
112
|
+
*/
|
|
113
|
+
digits?: number | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* - A function to format the column value.
|
|
116
|
+
*/
|
|
117
|
+
formatter: Function;
|
|
118
|
+
/**
|
|
119
|
+
* - Indicates if the column is virtual (true/false).
|
|
120
|
+
*/
|
|
121
|
+
virtual?: boolean | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* - Indicates if the column is sortable (true/false).
|
|
124
|
+
*/
|
|
125
|
+
sortable?: boolean | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* - The sort order of the column.
|
|
128
|
+
*/
|
|
129
|
+
sortOrder?: SortOptions | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* - The alignment of the column content.
|
|
132
|
+
*/
|
|
133
|
+
align?: HorizontalAlignOptions | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* - Action attribute for action columns.
|
|
136
|
+
*/
|
|
137
|
+
action?: ActionTypes | undefined;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Track the state of a row in the table.
|
|
141
|
+
*/
|
|
142
|
+
export type RowState = {
|
|
143
|
+
/**
|
|
144
|
+
* - The index of the node in the flat list.
|
|
145
|
+
*/
|
|
146
|
+
index: number;
|
|
147
|
+
/**
|
|
148
|
+
* - The depth of the node in the hierarchy.
|
|
149
|
+
*/
|
|
150
|
+
depth: number;
|
|
151
|
+
/**
|
|
152
|
+
* - The value of the hierarchy node.
|
|
153
|
+
*/
|
|
154
|
+
value?: string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* - Indicates whether the node is visible (true/false).
|
|
157
|
+
*/
|
|
158
|
+
isHidden?: boolean | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* - Indicates if this node is a parent (true/false).
|
|
161
|
+
*/
|
|
162
|
+
isParent?: boolean | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* - Indicates whether the node is expanded (true/false).
|
|
165
|
+
*/
|
|
166
|
+
isExpanded?: boolean | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* - The index of the parent node in the flat list.
|
|
169
|
+
*/
|
|
170
|
+
parentIndex?: number | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* - Indicates whether the node is selected (true/false/indeterminate).
|
|
173
|
+
*/
|
|
174
|
+
selected?: SelectionState | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* - The indices of the children in the flat list.
|
|
177
|
+
*/
|
|
178
|
+
childred: Array<number>;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Track the state of all rows in the table.
|
|
182
|
+
*/
|
|
183
|
+
export type RowStateMap = {
|
|
184
|
+
/**
|
|
185
|
+
* - Flat list of hierarchy nodes.
|
|
186
|
+
*/
|
|
187
|
+
rows: RowState[];
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Shade mapping for color variables
|
|
191
|
+
*/
|
|
192
|
+
export type ShadeMapping = {
|
|
193
|
+
/**
|
|
194
|
+
* - the variable name to be used
|
|
195
|
+
*/
|
|
196
|
+
key: string;
|
|
197
|
+
/**
|
|
198
|
+
* - the value to be used
|
|
199
|
+
*/
|
|
200
|
+
value: string;
|
|
201
|
+
/**
|
|
202
|
+
* - light or dark mode
|
|
203
|
+
*/
|
|
204
|
+
mode: string;
|
|
205
|
+
};
|
|
206
|
+
export type TickMark = {
|
|
207
|
+
/**
|
|
208
|
+
* - The value of the tick mark.
|
|
209
|
+
*/
|
|
210
|
+
value: number;
|
|
211
|
+
/**
|
|
212
|
+
* - The label for the tick mark.
|
|
213
|
+
*/
|
|
214
|
+
label: string;
|
|
215
|
+
/**
|
|
216
|
+
* - Indicates if the tick mark is a major tick.
|
|
217
|
+
*/
|
|
218
|
+
major: boolean;
|
|
219
|
+
};
|
|
220
|
+
export type CalendarDay = {
|
|
221
|
+
/**
|
|
222
|
+
* - The day of the month.
|
|
223
|
+
*/
|
|
224
|
+
day: number;
|
|
225
|
+
/**
|
|
226
|
+
* - indicates the offset for positioning
|
|
227
|
+
*/
|
|
228
|
+
offset: number;
|
|
229
|
+
/**
|
|
230
|
+
* - Datevalue for the day.
|
|
231
|
+
*/
|
|
232
|
+
date: date;
|
|
233
|
+
/**
|
|
234
|
+
* - formatted text for the day.
|
|
235
|
+
*/
|
|
236
|
+
text: string;
|
|
237
|
+
/**
|
|
238
|
+
* - Indicates if the day is a holiday.
|
|
239
|
+
*/
|
|
240
|
+
holiday: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* - Indicates if the day is on the weekend.
|
|
243
|
+
*/
|
|
244
|
+
weekend: boolean;
|
|
245
|
+
};
|
|
246
|
+
export type ColorPalette = {
|
|
247
|
+
/**
|
|
248
|
+
* 50 - The color for the 50 shade.
|
|
249
|
+
*/
|
|
250
|
+
"": string;
|
|
251
|
+
};
|
|
252
|
+
export type ColorCollection = {
|
|
253
|
+
[x: string]: ColorPalette;
|
|
254
|
+
};
|
|
255
|
+
export type ColorMapping = {
|
|
256
|
+
/**
|
|
257
|
+
* - The primary color.
|
|
258
|
+
*/
|
|
259
|
+
primary?: string | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* - The secondary color.
|
|
262
|
+
*/
|
|
263
|
+
secondary?: string | undefined;
|
|
264
|
+
/**
|
|
265
|
+
* - The tertiary color.
|
|
266
|
+
*/
|
|
267
|
+
tertiary?: string | undefined;
|
|
268
|
+
/**
|
|
269
|
+
* - The surface color.
|
|
270
|
+
*/
|
|
271
|
+
surface?: string | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* - The info color.
|
|
274
|
+
*/
|
|
275
|
+
info?: string | undefined;
|
|
276
|
+
/**
|
|
277
|
+
* - The success color.
|
|
278
|
+
*/
|
|
279
|
+
success?: string | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* - The warning color.
|
|
282
|
+
*/
|
|
283
|
+
warning?: string | undefined;
|
|
284
|
+
/**
|
|
285
|
+
* - The error color.
|
|
286
|
+
*/
|
|
287
|
+
error?: string | undefined;
|
|
288
|
+
};
|
|
289
|
+
export type ColorTheme = {
|
|
290
|
+
/**
|
|
291
|
+
* - The color mapping.
|
|
292
|
+
*/
|
|
293
|
+
mapping?: ColorMapping | undefined;
|
|
294
|
+
/**
|
|
295
|
+
* - The color collection.
|
|
296
|
+
*/
|
|
297
|
+
colors?: {
|
|
298
|
+
[x: string]: ColorPalette;
|
|
299
|
+
} | undefined;
|
|
300
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects text direction based on HTML lang attribute
|
|
3
|
+
* @returns {'ltr' | 'rtl'}
|
|
4
|
+
*/
|
|
5
|
+
export function detectDirection(): "ltr" | "rtl";
|
|
6
|
+
/**
|
|
7
|
+
* Checks if current document direction is RTL
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function isRTL(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Finds the closest ancestor of the given element that has the given attribute.
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} element
|
|
15
|
+
* @param {string} attribute
|
|
16
|
+
* @returns {HTMLElement|null}
|
|
17
|
+
*/
|
|
18
|
+
export function getClosestAncestorWithAttribute(element: HTMLElement, attribute: string): HTMLElement | null;
|
|
19
|
+
/**
|
|
20
|
+
* A function that performs no operations.
|
|
21
|
+
*/
|
|
22
|
+
export function noop(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Generates a random id
|
|
25
|
+
*
|
|
26
|
+
* @returns {string} A random id
|
|
27
|
+
*/
|
|
28
|
+
export function id(prefix?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a value is a json object
|
|
31
|
+
*
|
|
32
|
+
* @param {*} val
|
|
33
|
+
* @returns {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function isObject(val: any): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Converts the value to a string. If the value is an object, it will convert it to a JSON string.
|
|
38
|
+
*
|
|
39
|
+
* @param {*} value
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
export function toString(value: any): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generates icon shortcuts for a collection of icons
|
|
45
|
+
*
|
|
46
|
+
* @param {string[]} icons
|
|
47
|
+
* @param {string} collection
|
|
48
|
+
* @param {string} variants
|
|
49
|
+
* @returns {Object}
|
|
50
|
+
*/
|
|
51
|
+
export function iconShortcuts(icons: string[], collection: string, variants: string): Object;
|
|
52
|
+
/**
|
|
53
|
+
* Scales the path by the size
|
|
54
|
+
*
|
|
55
|
+
* @param {number} size
|
|
56
|
+
* @param {string|number} x
|
|
57
|
+
* @returns {string|number}
|
|
58
|
+
*/
|
|
59
|
+
export function scaledPath(size: number, x: string | number): string | number;
|
|
60
|
+
/**
|
|
61
|
+
* Gets a key string from path
|
|
62
|
+
* @param {string[]} path
|
|
63
|
+
* @returns {string}
|
|
64
|
+
*/
|
|
65
|
+
export function getKeyFromPath(path: string[]): string;
|
|
66
|
+
/**
|
|
67
|
+
* Gets a path array from key string
|
|
68
|
+
* @param {string} key
|
|
69
|
+
* @returns {string[]}
|
|
70
|
+
*/
|
|
71
|
+
export function getPathFromKey(key: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Get snippet function from an object
|
|
74
|
+
* @param {Object} obj
|
|
75
|
+
* @param {string} key
|
|
76
|
+
* @param {null|Function} defaultSnippet
|
|
77
|
+
* @returns {Function|undefined}
|
|
78
|
+
*/
|
|
79
|
+
export function getSnippet(obj: Object, key: string, defaultSnippet?: null | Function): Function | undefined;
|
|
80
|
+
export function resolveSnippet(snippets: any, proxy: any, fallback?: string): Function | null;
|
|
81
|
+
/**
|
|
82
|
+
* convert hex string to `{r} {g} {b}`
|
|
83
|
+
* @param {string} hex
|
|
84
|
+
* @return {string}
|
|
85
|
+
*/
|
|
86
|
+
export function hex2rgb(hex: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Convert a CSS color value to r,g,b for use in CSS variables.
|
|
89
|
+
* Hex values (#rrggbb) are converted to "r,g,b" for rgba() support.
|
|
90
|
+
* All other CSS color formats (oklch, hsl, named) are returned as-is.
|
|
91
|
+
* Non-string values are returned unchanged.
|
|
92
|
+
* Note: non-hex values will NOT work with UnoCSS opacity utilities like bg-primary/50.
|
|
93
|
+
*
|
|
94
|
+
* @param {unknown} value
|
|
95
|
+
* @returns {unknown}
|
|
96
|
+
*/
|
|
97
|
+
export function colorToRgb(value: unknown): unknown;
|
|
98
|
+
/**
|
|
99
|
+
* A utility function that detects if a string is an image URL or image data (base64)
|
|
100
|
+
*
|
|
101
|
+
* @param {string} str - The string to check
|
|
102
|
+
* @returns {string|null} - Returns the original string if it's an image URL or image data, otherwise null
|
|
103
|
+
*/
|
|
104
|
+
export function getImage(str: string): string | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates icon collection loaders for UnoCSS presetIcons from a simple config.
|
|
3
|
+
*
|
|
4
|
+
* This function transforms a map of collection names to JSON package paths
|
|
5
|
+
* into the format expected by UnoCSS's presetIcons.
|
|
6
|
+
*
|
|
7
|
+
* Supports three types of paths:
|
|
8
|
+
* - Package paths (e.g., '@rokkit/icons/ui.json') - resolved via require
|
|
9
|
+
* - Absolute paths (e.g., '/path/to/icons.json') - used directly
|
|
10
|
+
* - Relative paths (e.g., './static/icons.json') - resolved from process.cwd()
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // uno.config.js
|
|
14
|
+
* import { iconCollections } from '@rokkit/core/vite'
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* presets: [
|
|
18
|
+
* presetIcons({
|
|
19
|
+
* collections: iconCollections({
|
|
20
|
+
* rokkit: '@rokkit/icons/ui.json',
|
|
21
|
+
* logo: '@rokkit/icons/auth.json',
|
|
22
|
+
* solar: '@iconify-json/solar/icons.json',
|
|
23
|
+
* custom: './static/icons/custom.json'
|
|
24
|
+
* })
|
|
25
|
+
* })
|
|
26
|
+
* ]
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* @param {Record<string, string>} config - Map of collection alias to JSON path
|
|
30
|
+
* @returns {Record<string, () => any>} Collections object for presetIcons
|
|
31
|
+
*/
|
|
32
|
+
export function iconCollections(config: Record<string, string>): Record<string, () => any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { iconCollections } from "./icon-collections.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"ramda": "^0.32.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@rokkit/icons": "1.0.
|
|
49
|
+
"@rokkit/icons": "1.0.3"
|
|
50
50
|
}
|
|
51
51
|
}
|