@rokkit/core 1.0.0-next.14 → 1.0.0-next.140
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 +1 -1
- package/README.md +121 -1
- 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 +88 -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 +96 -0
- package/dist/ticks.d.ts +10 -0
- package/dist/types.d.ts +300 -0
- package/dist/utils.d.ts +93 -0
- package/dist/vite/icon-collections.d.ts +32 -0
- package/dist/vite/index.d.ts +1 -0
- package/package.json +31 -39
- package/src/calendar.js +44 -0
- package/src/colors/extra.json +16 -0
- package/src/colors/index.ts +24 -0
- package/src/colors/syntax.json +42 -0
- package/src/colors/tailwind.json +275 -0
- package/src/connector.js +34 -0
- package/src/constants.js +186 -107
- package/src/events.js +32 -0
- package/src/field-mapper.js +147 -0
- package/src/index.js +19 -27
- package/src/key-event-map.js +35 -0
- package/src/mapped-items.js +22 -0
- package/src/mapping.js +21 -0
- package/src/nested.js +28 -0
- package/src/string.js +97 -0
- package/src/theme.ts +206 -0
- package/src/ticks.js +26 -0
- package/src/types.js +160 -0
- package/src/utils.js +255 -0
- package/src/vite/icon-collections.js +73 -0
- package/src/vite/index.js +1 -0
- package/src/Accordion.svelte +0 -80
- package/src/Alerts.svelte +0 -39
- package/src/DropDown.svelte +0 -82
- package/src/DropSearch.svelte +0 -67
- package/src/EditableTabs.svelte +0 -31
- package/src/Icon.svelte +0 -15
- package/src/List-Discard.svelte +0 -48
- package/src/List.svelte +0 -65
- package/src/ListActions.svelte +0 -35
- package/src/NavTabs.svelte +0 -0
- package/src/NestedList.svelte +0 -77
- package/src/Overlay.svelte +0 -4
- package/src/PageNavigator.svelte +0 -94
- package/src/ResponsiveGrid.svelte +0 -73
- package/src/Scrollable.svelte +0 -8
- package/src/Searchable.svelte +0 -19
- package/src/Sidebar.svelte +0 -5
- package/src/Slider.svelte +0 -17
- package/src/SpinList.svelte +0 -48
- package/src/SplitPane.svelte +0 -109
- package/src/SplitView.svelte +0 -44
- package/src/Splitter.svelte +0 -95
- package/src/TabItem.svelte +0 -27
- package/src/TabItems.svelte +0 -34
- package/src/Tabs.svelte +0 -49
- package/src/Tree.svelte +0 -45
- package/src/actions/dismissable.js +0 -24
- package/src/actions/fillable.js +0 -114
- package/src/actions/hierarchy.js +0 -180
- package/src/actions/index.js +0 -7
- package/src/actions/navigable.js +0 -43
- package/src/actions/navigator.js +0 -179
- package/src/actions/pannable.js +0 -50
- package/src/actions/swipeable.js +0 -56
- package/src/actions/themeable.js +0 -23
- package/src/items/Collapsible.svelte +0 -51
- package/src/items/Connector.svelte +0 -26
- package/src/items/Link.svelte +0 -18
- package/src/items/Node.svelte +0 -52
- package/src/items/Pill.svelte +0 -19
- package/src/items/Separator.svelte +0 -1
- package/src/items/Summary.svelte +0 -27
- package/src/items/Text.svelte +0 -21
- package/src/items/index.js +0 -8
- package/src/list.js +0 -14
- package/src/mocks/Custom.svelte +0 -7
- package/src/mocks/index.js +0 -10
- package/src/stores/alerts.js +0 -3
- package/src/stores/index.js +0 -6
- package/src/stores/persist.js +0 -63
- package/src/stores/theme.js +0 -34
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1 +1,121 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rokkit/core
|
|
2
|
+
|
|
3
|
+
Core utilities for the Rokkit design system — field mapping, constants, calendar, color palette, and event utilities.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @rokkit/core
|
|
9
|
+
# or
|
|
10
|
+
bun add @rokkit/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
`@rokkit/core` is the foundation layer shared across all Rokkit packages. It provides:
|
|
16
|
+
|
|
17
|
+
- **Field mapping** — map arbitrary data object shapes to semantic field names
|
|
18
|
+
- **Constants** — `BASE_FIELDS`, `DEFAULT_STATE_ICONS`, `DEFAULT_KEYMAP`, and more
|
|
19
|
+
- **Color palette** — default colors, shades, and theme color mapping
|
|
20
|
+
- **Calendar utilities** — calendar day generation and weekday labels
|
|
21
|
+
- **Event utilities** — lightweight emitter factory
|
|
22
|
+
- **Direction detection** — RTL/LTR helpers
|
|
23
|
+
- **Tick generation** — axis tick utilities for chart packages
|
|
24
|
+
|
|
25
|
+
No runtime dependencies on other `@rokkit/*` packages.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Field mapping
|
|
30
|
+
|
|
31
|
+
`FieldMapper` maps semantic field names (`label`, `value`, `icon`, etc.) to the actual keys present in your data objects. Pass a fields override to adapt any data shape.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { FieldMapper } from '@rokkit/core'
|
|
35
|
+
|
|
36
|
+
const mapper = new FieldMapper({ label: 'name', value: 'id', icon: 'iconClass' })
|
|
37
|
+
|
|
38
|
+
const item = { id: 42, name: 'Settings', iconClass: 'i-settings' }
|
|
39
|
+
|
|
40
|
+
mapper.get('label', item) // 'Settings'
|
|
41
|
+
mapper.get('value', item) // 42
|
|
42
|
+
mapper.get('icon', item) // 'i-settings'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### normalizeFields
|
|
46
|
+
|
|
47
|
+
Merge user-supplied field overrides with `BASE_FIELDS` defaults, remapping any legacy key names automatically.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { normalizeFields, BASE_FIELDS } from '@rokkit/core'
|
|
51
|
+
|
|
52
|
+
const fields = normalizeFields({ label: 'title', value: 'slug' })
|
|
53
|
+
// { label: 'title', value: 'slug', icon: 'icon', children: 'children', ... }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### BASE_FIELDS reference
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import { BASE_FIELDS } from '@rokkit/core'
|
|
60
|
+
|
|
61
|
+
// {
|
|
62
|
+
// id: 'id', value: 'value', label: 'label',
|
|
63
|
+
// icon: 'icon', avatar: 'image', subtext: 'description',
|
|
64
|
+
// tooltip: 'title', badge: 'badge', shortcut: 'shortcut',
|
|
65
|
+
// children: 'children', type: 'type', snippet: 'snippet',
|
|
66
|
+
// href: 'href', hrefTarget: 'target',
|
|
67
|
+
// disabled: 'disabled', expanded: 'expanded', selected: 'selected'
|
|
68
|
+
// }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Event emitter
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import { createEmitter } from '@rokkit/core'
|
|
75
|
+
|
|
76
|
+
const emitter = createEmitter()
|
|
77
|
+
emitter.on('select', (item) => console.log('selected', item))
|
|
78
|
+
emitter.emit('select', myItem)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Calendar utilities
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { getCalendarDays, weekdays } from '@rokkit/core'
|
|
85
|
+
|
|
86
|
+
const days = getCalendarDays(2025, 2) // February 2025
|
|
87
|
+
// weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Tick generation
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { generateTicks } from '@rokkit/core'
|
|
94
|
+
|
|
95
|
+
const ticks = generateTicks(0, 100, 5)
|
|
96
|
+
// [0, 25, 50, 75, 100]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API
|
|
100
|
+
|
|
101
|
+
| Export | Description |
|
|
102
|
+
| -------------------------------- | ------------------------------------------------------------- |
|
|
103
|
+
| `BASE_FIELDS` | Canonical semantic-to-data-key field mapping |
|
|
104
|
+
| `normalizeFields(fields)` | Merge overrides with BASE_FIELDS defaults |
|
|
105
|
+
| `FieldMapper` | Class that resolves semantic field reads from data objects |
|
|
106
|
+
| `DEFAULT_STATE_ICONS` | Icon name map grouped by category (action, state, sort, etc.) |
|
|
107
|
+
| `DEFAULT_KEYMAP` | Default keyboard navigation key mapping |
|
|
108
|
+
| `DEFAULT_THEME_MAPPING` | Default semantic color → palette color mapping |
|
|
109
|
+
| `createEmitter()` | Lightweight event emitter factory |
|
|
110
|
+
| `getCalendarDays(year, month)` | Calendar day array for a given month |
|
|
111
|
+
| `weekdays` | Localized weekday label array |
|
|
112
|
+
| `generateTicks(min, max, count)` | Evenly spaced axis tick values |
|
|
113
|
+
| `defaultColors` | Default color palette array |
|
|
114
|
+
| `shades` | Available shade scale values |
|
|
115
|
+
| `ITEM_SNIPPET` | Constant: default item snippet key (`'itemContent'`) |
|
|
116
|
+
| `GROUP_SNIPPET` | Constant: default group snippet key (`'groupContent'`) |
|
|
117
|
+
| `stateIconsFromNames(names)` | Build a state icon map from an array of icon name strings |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
Part of [Rokkit](https://github.com/jerrythomas/rokkit) — a Svelte 5 component library and design system.
|
|
@@ -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,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remap legacy field-override keys to their BASE_FIELDS semantic equivalents.
|
|
3
|
+
* e.g. { text: 'name' } → { label: 'name' }
|
|
4
|
+
*
|
|
5
|
+
* @param {Record<string, string> | null | undefined} fields
|
|
6
|
+
* @returns {Record<string, string>}
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeFields(fields: Record<string, string> | null | undefined): Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Generate a state icon mapping from a list of icon names
|
|
11
|
+
*
|
|
12
|
+
* @param {string[]} icons
|
|
13
|
+
* @returns {import('./types').StateIcons}
|
|
14
|
+
*/
|
|
15
|
+
export function stateIconsFromNames(icons: string[]): import("./types").StateIcons;
|
|
16
|
+
export const DATA_IMAGE_REGEX: RegExp;
|
|
17
|
+
export const ITEM_SNIPPET: "itemContent";
|
|
18
|
+
export const GROUP_SNIPPET: "groupContent";
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use BASE_FIELDS from @rokkit/core instead.
|
|
21
|
+
* Retained for legacy ListController/FieldMapper/Proxy consumers (Toolbar, Table).
|
|
22
|
+
* Will be removed when those components migrate to Wrapper+Navigator.
|
|
23
|
+
* @type {import('./types).FieldMapping} Fields
|
|
24
|
+
*/
|
|
25
|
+
export const DEFAULT_FIELDS: any;
|
|
26
|
+
export namespace BASE_FIELDS {
|
|
27
|
+
let id: string;
|
|
28
|
+
let value: string;
|
|
29
|
+
let label: string;
|
|
30
|
+
let icon: string;
|
|
31
|
+
let avatar: string;
|
|
32
|
+
let subtext: string;
|
|
33
|
+
let tooltip: string;
|
|
34
|
+
let badge: string;
|
|
35
|
+
let shortcut: string;
|
|
36
|
+
let children: string;
|
|
37
|
+
let type: string;
|
|
38
|
+
let snippet: string;
|
|
39
|
+
let href: string;
|
|
40
|
+
let hrefTarget: string;
|
|
41
|
+
let disabled: string;
|
|
42
|
+
let expanded: string;
|
|
43
|
+
let selected: string;
|
|
44
|
+
}
|
|
45
|
+
export const DEFAULT_ICONS: string[];
|
|
46
|
+
export namespace DEFAULT_OPTIONS {
|
|
47
|
+
let id_1: string;
|
|
48
|
+
export { id_1 as id };
|
|
49
|
+
let label_1: string;
|
|
50
|
+
export { label_1 as label };
|
|
51
|
+
let value_1: string;
|
|
52
|
+
export { value_1 as value };
|
|
53
|
+
export let checked: string;
|
|
54
|
+
}
|
|
55
|
+
export namespace DEFAULT_KEYMAP {
|
|
56
|
+
let ArrowRight: string;
|
|
57
|
+
let ArrowLeft: string;
|
|
58
|
+
let ArrowDown: string;
|
|
59
|
+
let ArrowUp: string;
|
|
60
|
+
let Enter: string;
|
|
61
|
+
let Escape: string;
|
|
62
|
+
}
|
|
63
|
+
export namespace DEFAULT_THEME_MAPPING {
|
|
64
|
+
let surface: string;
|
|
65
|
+
let primary: string;
|
|
66
|
+
let secondary: string;
|
|
67
|
+
let accent: string;
|
|
68
|
+
let success: string;
|
|
69
|
+
let warning: string;
|
|
70
|
+
let danger: string;
|
|
71
|
+
let error: string;
|
|
72
|
+
let info: string;
|
|
73
|
+
}
|
|
74
|
+
export namespace TONE_MAP {
|
|
75
|
+
let z0: number;
|
|
76
|
+
let z1: number;
|
|
77
|
+
let z2: number;
|
|
78
|
+
let z3: number;
|
|
79
|
+
let z4: number;
|
|
80
|
+
let z5: number;
|
|
81
|
+
let z6: number;
|
|
82
|
+
let z7: number;
|
|
83
|
+
let z8: number;
|
|
84
|
+
let z9: number;
|
|
85
|
+
let z10: number;
|
|
86
|
+
}
|
|
87
|
+
export const DEFAULT_STATE_ICONS: any;
|
|
88
|
+
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,96 @@
|
|
|
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): 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
|
+
}
|
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[];
|