@rokkit/core 1.0.0-next.120 → 1.0.0-next.122
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/dist/colors/index.d.ts +326 -252
- package/dist/constants.d.ts +12 -0
- package/dist/theme.d.ts +1141 -35
- package/package.json +1 -1
- package/src/colors/extra.json +16 -0
- package/src/colors/index.js +5 -2
- package/src/colors/tailwind.json +0 -14
- package/src/constants.js +50 -10
- package/src/theme.js +105 -151
- package/src/utils.js +19 -12
- package/dist/packages/actions/src/delegate.svelte.d.ts +0 -13
- package/dist/packages/actions/src/dismissable.svelte.d.ts +0 -7
- package/dist/packages/actions/src/fillable.svelte.d.ts +0 -8
- package/dist/packages/actions/src/index.d.ts +0 -11
- package/dist/packages/actions/src/kbd.d.ts +0 -44
- package/dist/packages/actions/src/keyboard.svelte.d.ts +0 -7
- package/dist/packages/actions/src/lib/event-manager.d.ts +0 -8
- package/dist/packages/actions/src/lib/index.d.ts +0 -2
- package/dist/packages/actions/src/lib/internal.d.ts +0 -19
- package/dist/packages/actions/src/navigable.svelte.d.ts +0 -8
- package/dist/packages/actions/src/navigator.svelte.d.ts +0 -20
- package/dist/packages/actions/src/pannable.svelte.d.ts +0 -6
- package/dist/packages/actions/src/skinnable.svelte.d.ts +0 -8
- package/dist/packages/actions/src/swipeable.svelte.d.ts +0 -14
- package/dist/packages/actions/src/themable.svelte.d.ts +0 -7
- package/dist/packages/actions/src/types.d.ts +0 -72
- package/dist/packages/actions/src/utils.d.ts +0 -18
- package/dist/packages/bits-ui/src/index.d.ts +0 -2
- package/dist/packages/bits-ui/src/reference.d.ts +0 -22
- package/dist/packages/bits-ui/src/tree/constants.d.ts +0 -13
- package/dist/packages/bits-ui/src/tree/index.d.ts +0 -7
- package/dist/packages/bits-ui/src/tree/types.d.ts +0 -71
- package/dist/packages/core/src/calendar.d.ts +0 -10
- package/dist/packages/core/src/colors/index.d.ts +0 -333
- package/dist/packages/core/src/connector.d.ts +0 -8
- package/dist/packages/core/src/constants.d.ts +0 -39
- package/dist/packages/core/src/events.d.ts +0 -12
- package/dist/packages/core/src/field-mapper.d.ts +0 -63
- package/dist/packages/core/src/index.d.ts +0 -13
- package/dist/packages/core/src/key-event-map.d.ts +0 -18
- package/dist/packages/core/src/mapped-items.d.ts +0 -14
- package/dist/packages/core/src/mapping.d.ts +0 -75
- package/dist/packages/core/src/nested.d.ts +0 -18
- package/dist/packages/core/src/string.d.ts +0 -59
- package/dist/packages/core/src/theme.d.ts +0 -52
- package/dist/packages/core/src/ticks.d.ts +0 -10
- package/dist/packages/core/src/types.d.ts +0 -245
- package/dist/packages/core/src/utils.d.ts +0 -70
- package/dist/packages/data/src/aggregators.d.ts +0 -2
- package/dist/packages/data/src/constants.d.ts +0 -46
- package/dist/packages/data/src/convert.d.ts +0 -10
- package/dist/packages/data/src/dataset.d.ts +0 -43
- package/dist/packages/data/src/filter.d.ts +0 -26
- package/dist/packages/data/src/formatter.d.ts +0 -10
- package/dist/packages/data/src/hierarchy.d.ts +0 -36
- package/dist/packages/data/src/index.d.ts +0 -7
- package/dist/packages/data/src/infer.d.ts +0 -80
- package/dist/packages/data/src/join.d.ts +0 -95
- package/dist/packages/data/src/list.d.ts +0 -121
- package/dist/packages/data/src/metadata.d.ts +0 -32
- package/dist/packages/data/src/model.d.ts +0 -29
- package/dist/packages/data/src/parser.d.ts +0 -31
- package/dist/packages/data/src/renamer.d.ts +0 -37
- package/dist/packages/data/src/rollup.d.ts +0 -51
- package/dist/packages/data/src/types.d.ts +0 -346
- package/dist/packages/data/src/utils.d.ts +0 -6
- package/dist/packages/data/src/view.d.ts +0 -35
- package/dist/packages/helpers/src/components/index.d.ts +0 -2
- package/dist/packages/helpers/src/index.d.ts +0 -1
- package/dist/packages/helpers/src/matchers/action.d.ts +0 -27
- package/dist/packages/helpers/src/matchers/array.d.ts +0 -10
- package/dist/packages/helpers/src/matchers/dataset.d.ts +0 -10
- package/dist/packages/helpers/src/matchers/event.d.ts +0 -10
- package/dist/packages/helpers/src/matchers/index.d.ts +0 -4
- package/dist/packages/helpers/src/matchers/internal.d.ts +0 -1
- package/dist/packages/helpers/src/mocks/animate.d.ts +0 -1
- package/dist/packages/helpers/src/mocks/element.d.ts +0 -60
- package/dist/packages/helpers/src/mocks/index.d.ts +0 -2
- package/dist/packages/helpers/src/mocks/match-media.d.ts +0 -30
- package/dist/packages/helpers/src/mocks/resize-observer.d.ts +0 -9
- package/dist/packages/helpers/src/simulators/index.d.ts +0 -1
- package/dist/packages/helpers/src/simulators/touch.d.ts +0 -40
- package/dist/packages/icons/src/convert.d.ts +0 -22
- package/dist/packages/icons/src/index.d.ts +0 -2
- package/dist/packages/input/src/index.d.ts +0 -18
- package/dist/packages/states/src/constants.d.ts +0 -27
- package/dist/packages/states/src/derive.svelte.d.ts +0 -22
- package/dist/packages/states/src/hierarchy.d.ts +0 -34
- package/dist/packages/states/src/index.d.ts +0 -5
- package/dist/packages/states/src/list-controller.svelte.d.ts +0 -70
- package/dist/packages/states/src/nested-controller.svelte.d.ts +0 -32
- package/dist/packages/states/src/proxy.svelte.d.ts +0 -43
- package/dist/packages/states/src/tabular.svelte.d.ts +0 -5
- package/dist/packages/states/src/traversal.svelte.d.ts +0 -69
- package/dist/packages/states/src/vibe.svelte.d.ts +0 -622
- package/dist/packages/themes/src/constants.d.ts +0 -6
- package/dist/packages/themes/src/index.d.ts +0 -2
- package/dist/packages/tutorial/src/assimilate.d.ts +0 -25
- package/dist/packages/tutorial/src/collector.d.ts +0 -46
- package/dist/packages/tutorial/src/files.d.ts +0 -8
- package/dist/packages/tutorial/src/index.d.ts +0 -2
- package/dist/packages/tutorial/src/metadata/base.d.ts +0 -19
- package/dist/packages/tutorial/src/metadata/factory.d.ts +0 -19
- package/dist/packages/tutorial/src/metadata/index.d.ts +0 -2
- package/dist/packages/tutorial/src/metadata/javascript.d.ts +0 -7
- package/dist/packages/tutorial/src/metadata/json.d.ts +0 -7
- package/dist/packages/tutorial/src/metadata/markdown.d.ts +0 -7
- package/dist/packages/tutorial/src/metadata/registry.d.ts +0 -26
- package/dist/packages/tutorial/src/metamodel.d.ts +0 -45
- package/dist/packages/tutorial/src/tutorial.d.ts +0 -21
- package/dist/packages/tutorial/src/types.d.ts +0 -172
- package/dist/packages/tutorial/src/utils.d.ts +0 -13
- package/dist/packages/ui/src/constants.d.ts +0 -2
- package/dist/packages/ui/src/index.d.ts +0 -42
- package/dist/packages/ui/src/input/types.d.ts +0 -9
- package/dist/packages/ui/src/lib/fields.d.ts +0 -16
- package/dist/packages/ui/src/lib/form.d.ts +0 -95
- package/dist/packages/ui/src/lib/index.d.ts +0 -6
- package/dist/packages/ui/src/lib/layout.d.ts +0 -7
- package/dist/packages/ui/src/lib/nested.d.ts +0 -48
- package/dist/packages/ui/src/lib/schema.d.ts +0 -7
- package/dist/packages/ui/src/lib/select.d.ts +0 -8
- package/dist/packages/ui/src/lib/tree.d.ts +0 -9
- package/dist/packages/ui/src/types.d.ts +0 -5
- package/dist/packages/ui/src/wrappers/index.d.ts +0 -3
- package/dist/sites/learn/src/hooks.d.ts +0 -1
- package/dist/sites/learn/src/hooks.server.d.ts +0 -2
- package/dist/sites/learn/src/lib/index.d.ts +0 -7
- package/dist/sites/learn/src/lib/media.d.ts +0 -13
- package/dist/sites/learn/src/lib/paraglide/messages/en.d.ts +0 -3
- package/dist/sites/learn/src/lib/paraglide/messages/fr.d.ts +0 -3
- package/dist/sites/learn/src/lib/paraglide/messages/hi.d.ts +0 -3
- package/dist/sites/learn/src/lib/paraglide/messages.d.ts +0 -5
- package/dist/sites/learn/src/lib/paraglide/runtime.d.ts +0 -52
- package/dist/sites/learn/src/lib/stories/02-elements/01-list/03-mapping/src/data.d.ts +0 -5
- package/dist/sites/learn/src/lib/stories/02-elements/01-list/04-mixed/src/data.d.ts +0 -13
- package/dist/sites/learn/src/lib/stories/02-elements/02-tabs/04-fields/src/data.d.ts +0 -5
- package/dist/sites/learn/src/lib/stories/02-elements/02-tabs/05-using/src/data.d.ts +0 -6
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/01-intro/src/data.d.ts +0 -4
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/02-fields/src/data.d.ts +0 -9
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/03-using/src/data.d.ts +0 -19
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/04-mixed/src/data.d.ts +0 -30
- package/dist/sites/learn/src/lib/stories/02-elements/03-accordion/props.d.ts +0 -15
- package/dist/sites/learn/src/lib/stories/02-elements/04-tree/01-intro/src/data.d.ts +0 -12
- package/dist/sites/learn/src/lib/stories/02-elements/06-select/02-fields/src/data.d.ts +0 -5
- package/dist/sites/learn/src/lib/stories/02-elements/07-multi-select/02-fields/src/data.d.ts +0 -5
- package/dist/sites/learn/src/lib/stories/02-elements/08-drop-down/02-fields/src/data.d.ts +0 -5
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/02-schema/src/schema.d.ts +0 -22
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/03-layout/src/layout.d.ts +0 -19
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/03-layout/src/schema.d.ts +0 -36
- package/dist/sites/learn/src/lib/stories/05-templates/01-form/05-validation/src/schema.d.ts +0 -34
- package/dist/sites/learn/src/lib/stories/05-templates/02-editor/01-introduction/src/data.d.ts +0 -39
- package/dist/sites/learn/src/lib/stories/05-templates/02-editor/01-introduction/src/schema.d.ts +0 -187
- package/dist/sites/learn/src/lib/stories/06-layout/03-stepper/01-intro/src/data.d.ts +0 -37
- package/dist/sites/learn/src/lib/stories/06-layout/03-stepper/02-play/src/data.d.ts +0 -37
- package/dist/sites/learn/src/lib/stories/index.d.ts +0 -1
- package/dist/sites/learn/src/lib/theme.svelte.d.ts +0 -70
- package/dist/sites/learn/src/routes/(learn)/+layout.d.ts +0 -12
- package/dist/sites/learn/src/routes/(learn)/[segment]/[...slug]/+page.d.ts +0 -8
- package/dist/sites/learn/src/routes/+layout.d.ts +0 -18
- package/dist/sites/quick-start/src/hooks.d.ts +0 -1
- package/dist/sites/quick-start/src/hooks.server.d.ts +0 -2
- package/dist/sites/quick-start/src/lib/index.d.ts +0 -1
- package/dist/sites/quick-start/src/lib/paraglide/messages/en.d.ts +0 -3
- package/dist/sites/quick-start/src/lib/paraglide/messages/fr.d.ts +0 -3
- package/dist/sites/quick-start/src/lib/paraglide/messages/hi.d.ts +0 -3
- package/dist/sites/quick-start/src/lib/paraglide/messages.d.ts +0 -5
- package/dist/sites/quick-start/src/lib/paraglide/runtime.d.ts +0 -52
- package/dist/sites/quick-start/src/routes/+layout.d.ts +0 -9
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"shark": {
|
|
3
|
+
"DEFAULT": "#828C9F",
|
|
4
|
+
"50": "#ffffff",
|
|
5
|
+
"100": "#efefef",
|
|
6
|
+
"200": "#E0E0E0",
|
|
7
|
+
"300": "#C1C6D0",
|
|
8
|
+
"400": "#828C9F",
|
|
9
|
+
"500": "#677287",
|
|
10
|
+
"600": "#51596A",
|
|
11
|
+
"700": "#3B414D",
|
|
12
|
+
"800": "#2E323C",
|
|
13
|
+
"900": "#20242A",
|
|
14
|
+
"950": "#1A1C22"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/colors/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { colors } from '@unocss/preset-mini/colors'
|
|
2
|
+
// import defaultTailwindColors from './tailwind.json' with { type: 'json' }
|
|
2
3
|
import syntaxColorPalette from './syntax.json' with { type: 'json' }
|
|
4
|
+
import extraColors from './extra.json' with { type: 'json' }
|
|
3
5
|
|
|
4
6
|
export const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
|
5
7
|
export const defaultPalette = [
|
|
@@ -15,5 +17,6 @@ export const defaultPalette = [
|
|
|
15
17
|
|
|
16
18
|
export const syntaxColors = syntaxColorPalette
|
|
17
19
|
export const defaultColors = {
|
|
18
|
-
...
|
|
20
|
+
...colors,
|
|
21
|
+
...extraColors
|
|
19
22
|
}
|
package/src/colors/tailwind.json
CHANGED
|
@@ -271,19 +271,5 @@
|
|
|
271
271
|
"800": "#27272a",
|
|
272
272
|
"900": "#18181b",
|
|
273
273
|
"950": "#000000"
|
|
274
|
-
},
|
|
275
|
-
"shark": {
|
|
276
|
-
"DEFAULT": "#677287",
|
|
277
|
-
"50": "#ffffff",
|
|
278
|
-
"100": "#efefef",
|
|
279
|
-
"200": "#E0E0E0",
|
|
280
|
-
"300": "#C1C6D0",
|
|
281
|
-
"400": "#828C9F",
|
|
282
|
-
"500": "#677287",
|
|
283
|
-
"600": "#51596A",
|
|
284
|
-
"700": "#3B414D",
|
|
285
|
-
"800": "#2E323C",
|
|
286
|
-
"900": "#20242A",
|
|
287
|
-
"950": "#1A1C22"
|
|
288
274
|
}
|
|
289
275
|
}
|
package/src/constants.js
CHANGED
|
@@ -38,6 +38,8 @@ export const defaultIcons = [
|
|
|
38
38
|
'action-clear',
|
|
39
39
|
'action-search',
|
|
40
40
|
'action-close',
|
|
41
|
+
'action-copy',
|
|
42
|
+
'action-copysuccess',
|
|
41
43
|
'node-opened',
|
|
42
44
|
'node-closed',
|
|
43
45
|
'selector-opened',
|
|
@@ -71,7 +73,15 @@ export const defaultIcons = [
|
|
|
71
73
|
'validity-failed',
|
|
72
74
|
'validity-passed',
|
|
73
75
|
'validity-unknown',
|
|
74
|
-
'validity-warning'
|
|
76
|
+
'validity-warning',
|
|
77
|
+
'alert-clear',
|
|
78
|
+
'alert-unread',
|
|
79
|
+
'align-horizontal-left',
|
|
80
|
+
'align-horizontal-right',
|
|
81
|
+
'align-horizontal-center',
|
|
82
|
+
'align-vertical-top',
|
|
83
|
+
'align-vertical-bottom',
|
|
84
|
+
'align-vertical-middle'
|
|
75
85
|
]
|
|
76
86
|
|
|
77
87
|
export const defaultOptions = {
|
|
@@ -102,6 +112,38 @@ export const defaultThemeMapping = {
|
|
|
102
112
|
info: 'cyan'
|
|
103
113
|
}
|
|
104
114
|
|
|
115
|
+
export const TONE_MAP = {
|
|
116
|
+
z1: 50,
|
|
117
|
+
z2: 100,
|
|
118
|
+
z3: 200,
|
|
119
|
+
z4: 300,
|
|
120
|
+
z5: 500,
|
|
121
|
+
z6: 600,
|
|
122
|
+
z7: 700,
|
|
123
|
+
z8: 800,
|
|
124
|
+
z9: 900,
|
|
125
|
+
z10: 950
|
|
126
|
+
// base: 50,
|
|
127
|
+
// inset: 100,
|
|
128
|
+
// subtle: 200,
|
|
129
|
+
// muted: 300,
|
|
130
|
+
// raised: 400,
|
|
131
|
+
// elevated: 600,
|
|
132
|
+
// floating: 700,
|
|
133
|
+
// contrast: 800,
|
|
134
|
+
// overlay: 900
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Splits an icon name into its group and key components.
|
|
138
|
+
* @param {string} name - The icon name to split.
|
|
139
|
+
* @returns {{ group: string, key: string, value: string }} An object containing the group, key, and value of the icon name.
|
|
140
|
+
*/
|
|
141
|
+
function splitIconName(name) {
|
|
142
|
+
const parts = name.split('-')
|
|
143
|
+
const group = parts.slice(0, parts.length - 1).join('-')
|
|
144
|
+
return { group, key: parts[parts.length - 1], value: name }
|
|
145
|
+
}
|
|
146
|
+
|
|
105
147
|
/**
|
|
106
148
|
* Generate a state icon mapping from a list of icon names
|
|
107
149
|
*
|
|
@@ -109,15 +151,13 @@ export const defaultThemeMapping = {
|
|
|
109
151
|
* @returns {import('./types').StateIcons}
|
|
110
152
|
*/
|
|
111
153
|
export function stateIconsFromNames(icons) {
|
|
112
|
-
return icons
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{}
|
|
120
|
-
)
|
|
154
|
+
return icons.map(splitIconName).reduce(
|
|
155
|
+
(acc, { group, key, value }) => ({
|
|
156
|
+
...acc,
|
|
157
|
+
[group]: { ...acc[group], [key]: value }
|
|
158
|
+
}),
|
|
159
|
+
{}
|
|
160
|
+
)
|
|
121
161
|
}
|
|
122
162
|
|
|
123
163
|
export const defaultStateIcons = stateIconsFromNames(defaultIcons)
|
package/src/theme.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defaultThemeMapping, defaultColors,
|
|
2
|
-
import { shades
|
|
1
|
+
import { defaultThemeMapping, defaultColors, TONE_MAP } from './constants.js'
|
|
2
|
+
import { shades } from './colors/index.js'
|
|
3
3
|
import { hex2rgb } from './utils'
|
|
4
4
|
|
|
5
5
|
const modifiers = {
|
|
6
6
|
hsl: (value) => `hsl(${value} / <alpha-value>)`,
|
|
7
|
-
rgb: (value) => `rgb(${value} / <alpha-value>)
|
|
8
|
-
|
|
7
|
+
rgb: (value) => `rgb(${value} / <alpha-value>)`,
|
|
8
|
+
none: (value) => value
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -15,109 +15,20 @@ const modifiers = {
|
|
|
15
15
|
* @param {string} modifier
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
export function shadesOf(name, modifier = '
|
|
19
|
-
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.
|
|
18
|
+
export function shadesOf(name, modifier = 'none') {
|
|
19
|
+
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.none
|
|
20
20
|
|
|
21
21
|
return shades.reduce(
|
|
22
22
|
(result, shade) => ({
|
|
23
23
|
...result,
|
|
24
|
-
[shade]: fn(`var(
|
|
24
|
+
[shade]: fn(`var(--color-${name}-${shade})`)
|
|
25
25
|
}),
|
|
26
26
|
{
|
|
27
|
-
DEFAULT: fn(`var(
|
|
28
|
-
base: fn(`var(--${name}-50)`),
|
|
29
|
-
inset: fn(`var(--${name}-100)`),
|
|
30
|
-
subtle: fn(`var(--${name}-200)`),
|
|
31
|
-
muted: fn(`var(--${name}-300)`),
|
|
32
|
-
raised: fn(`var(--${name}-400)`),
|
|
33
|
-
elevated: fn(`var(--${name}-600)`),
|
|
34
|
-
floating: fn(`var(--${name}-700)`),
|
|
35
|
-
contrast: fn(`var(--${name}-800)`),
|
|
36
|
-
overlay: fn(`var(--${name}-900)`)
|
|
27
|
+
DEFAULT: fn(`var(--color-${name}-500)`)
|
|
37
28
|
}
|
|
38
29
|
)
|
|
39
30
|
}
|
|
40
31
|
|
|
41
|
-
/**
|
|
42
|
-
* Generate shades for a color using css varuable
|
|
43
|
-
*
|
|
44
|
-
* @param {string} name
|
|
45
|
-
* @param {string} modifier
|
|
46
|
-
* @returns {object}
|
|
47
|
-
*/
|
|
48
|
-
export function stateColors(name, modifier = 'rgb') {
|
|
49
|
-
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.rgb
|
|
50
|
-
return {
|
|
51
|
-
DEFAULT: fn(`var(--${name}-500)`),
|
|
52
|
-
light: fn(`var(--${name}-200)`),
|
|
53
|
-
dark: fn(`var(--${name}-700)`)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {string} modifier
|
|
60
|
-
* @returns
|
|
61
|
-
*/
|
|
62
|
-
export function themeColors(modifier = 'rgb') {
|
|
63
|
-
const fn = modifier in modifiers ? modifiers[modifier] : modifiers.rgb
|
|
64
|
-
|
|
65
|
-
const states = ['info', 'danger', 'warning', 'success', 'error']
|
|
66
|
-
const variants = ['neutral', 'primary', 'secondary', 'accent']
|
|
67
|
-
let colors = states.reduce(
|
|
68
|
-
(acc, state) => ({ ...acc, [state]: stateColors(state, modifier) }),
|
|
69
|
-
{}
|
|
70
|
-
)
|
|
71
|
-
colors = variants.reduce(
|
|
72
|
-
(acc, variant) => ({ ...acc, [variant]: shadesOf(variant, modifier) }),
|
|
73
|
-
colors
|
|
74
|
-
)
|
|
75
|
-
colors.neutral = {
|
|
76
|
-
...colors.neutral,
|
|
77
|
-
// contrast: fn(`var(--neutral-800)`),
|
|
78
|
-
zebra: fn('var(--neutral-zebra)')
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return colors
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates an array of shade mapping objects for a given theme variant and mode.
|
|
86
|
-
* Each object represents a CSS custom property (variable) with its value set based on a provided condition.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} variant - The name of the theme variant (e.g., 'primary', 'secondary').
|
|
89
|
-
* @param {'light' | 'dark'} mode - The theme mode for which the mappings are being created.
|
|
90
|
-
* @param {function(number): string} valueCondition - A function that takes a shade value and returns the color value
|
|
91
|
-
* based on the condition appropriate for light or dark mode.
|
|
92
|
-
* @returns {{import('./types'}.ShadeMapping[]>} An array of objects, where each object contains key, value, and mode
|
|
93
|
-
* properties corresponding to a CSS custom property definition.
|
|
94
|
-
*/
|
|
95
|
-
function createShadeMappings(variant, mode, valueCondition) {
|
|
96
|
-
return shades.map((shade) => ({
|
|
97
|
-
key: `--on-${variant}-${shade}`,
|
|
98
|
-
value: valueCondition(shade),
|
|
99
|
-
mode
|
|
100
|
-
}))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Generates contrast colors for light and dark modes based on a given palette. Each color variant in the
|
|
105
|
-
* palette is mapped to either a light or dark contrast color depending on the shade's value.
|
|
106
|
-
*
|
|
107
|
-
* @param {string} [light='#ffffff'] - The default light color used when the shade is >= 500 in light mode or <= 500 in dark mode.
|
|
108
|
-
* @param {string} [dark='#000000'] - The default dark color used when the shade is < 500 in light mode or > 500 in dark mode.
|
|
109
|
-
* @param {Array<string>} [palette=defaultPalette] - An array of color variant names to generate contrast colors for.
|
|
110
|
-
* @returns {Array<Object>} An array containing contrast color rules organized by light and dark modes for each variant in the palette.
|
|
111
|
-
*/
|
|
112
|
-
export function contrastColors(light = '#ffffff', dark = '#000000', palette = defaultPalette) {
|
|
113
|
-
const colors = palette
|
|
114
|
-
.flatMap((variant) => [
|
|
115
|
-
createShadeMappings(variant, 'light', (shade) => (shade < 500 ? dark : light)),
|
|
116
|
-
createShadeMappings(variant, 'dark', (shade) => (shade > 500 ? dark : light))
|
|
117
|
-
])
|
|
118
|
-
.reduce((acc, item) => [...acc, ...item], [])
|
|
119
|
-
return colors
|
|
120
|
-
}
|
|
121
32
|
/**
|
|
122
33
|
* Generates color rules for a specific theme variant, for both light and dark modes.
|
|
123
34
|
*
|
|
@@ -127,80 +38,123 @@ export function contrastColors(light = '#ffffff', dark = '#000000', palette = de
|
|
|
127
38
|
* @returns {import('./types').ShadeMappings} An array containing the color rules for both light and dark modes.
|
|
128
39
|
*/
|
|
129
40
|
function generateColorRules(variant, colors, mapping) {
|
|
130
|
-
return shades.flatMap((shade
|
|
131
|
-
{
|
|
132
|
-
key: `--${variant}-${shade}`,
|
|
133
|
-
value: hex2rgb(colors[mapping[variant]][shade]),
|
|
134
|
-
mode: 'light'
|
|
135
|
-
},
|
|
41
|
+
return ['DEFAULT', ...shades].flatMap((shade) => [
|
|
136
42
|
{
|
|
137
|
-
key:
|
|
138
|
-
value:
|
|
139
|
-
mode: 'dark'
|
|
43
|
+
key: shade === 'DEFAULT' ? `--color-${variant}` : `--color-${variant}-${shade}`,
|
|
44
|
+
value: colors[mapping[variant]][`${shade}`]
|
|
140
45
|
}
|
|
141
46
|
])
|
|
142
47
|
}
|
|
143
48
|
|
|
144
49
|
/**
|
|
145
|
-
*
|
|
146
|
-
* CSS variable names to their values.
|
|
50
|
+
* Constructs and returns the light and dark theme variants based on provided color mapping and color definitions.
|
|
147
51
|
*
|
|
148
|
-
* @param {
|
|
149
|
-
* @param {
|
|
150
|
-
* @returns {
|
|
52
|
+
* @param {Object} [mapping=defaultThemeMapping] - An object mapping variant names to color property names.
|
|
53
|
+
* @param {Object} [colors=defaultColors] - The object containing default color definitions.
|
|
54
|
+
* @returns {Array<Array>} An array containing two arrays, one for the light theme variant and another for the dark theme.
|
|
151
55
|
*/
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
56
|
+
export function themeRules(mapping = defaultThemeMapping, colors = defaultColors) {
|
|
57
|
+
mapping = { ...defaultThemeMapping, ...mapping }
|
|
58
|
+
colors = { ...defaultColors, ...colors }
|
|
59
|
+
const variants = Object.keys(mapping)
|
|
60
|
+
const rules = variants
|
|
61
|
+
.flatMap((variant) => generateColorRules(variant, colors, mapping))
|
|
155
62
|
.reduce((acc, { key, value }) => ({ ...acc, [key]: value }), {})
|
|
63
|
+
|
|
64
|
+
return rules
|
|
156
65
|
}
|
|
157
66
|
|
|
158
67
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* @
|
|
162
|
-
* @param {'light' | 'dark'} mode - The mode of the theme variant.
|
|
163
|
-
* @param {Object} colors - The object containing color rules for the theme.
|
|
164
|
-
* @param {Object} extraColors - Any additional color properties for the theme.
|
|
165
|
-
* @returns {Array} An array where the first element is the theme's name and the second element
|
|
166
|
-
* is an object containing all color rules and extra properties for the theme variant.
|
|
68
|
+
* Generates UnoCSS shortcut definitions for semantic tones with bg, border, text.
|
|
69
|
+
* @param {string} name - Color name (e.g., 'primary')
|
|
70
|
+
* @returns {Array} Array of shortcut definitions
|
|
167
71
|
*/
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
72
|
+
export function semanticShortcuts(name) {
|
|
73
|
+
const prefixes = ['bg', 'border', 'text', 'ring', 'outline', 'from', 'to', 'divide']
|
|
74
|
+
const shortcuts = []
|
|
75
|
+
|
|
76
|
+
for (const [toneName, lightValue] of Object.entries(TONE_MAP)) {
|
|
77
|
+
const darkValue = 1000 - lightValue
|
|
78
|
+
|
|
79
|
+
for (const prefix of prefixes) {
|
|
80
|
+
// Variant-prefixed regex (e.g., hover:bg-primary-base)
|
|
81
|
+
const variantPattern = new RegExp(`^(.+):${prefix}-${name}-${toneName}$`)
|
|
82
|
+
shortcuts.push([
|
|
83
|
+
variantPattern,
|
|
84
|
+
([, variant]) =>
|
|
85
|
+
`${variant}:${prefix}-${name}-${lightValue} ${variant}:dark:${prefix}-${name}-${darkValue}`
|
|
86
|
+
])
|
|
87
|
+
|
|
88
|
+
// Exact static shortcut (e.g., bg-primary-base)
|
|
89
|
+
const exactPattern = `${prefix}-${name}-${toneName}`
|
|
90
|
+
shortcuts.push([
|
|
91
|
+
exactPattern,
|
|
92
|
+
`${prefix}-${name}-${lightValue} dark:${prefix}-${name}-${darkValue}`
|
|
93
|
+
])
|
|
175
94
|
}
|
|
176
|
-
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return shortcuts
|
|
177
98
|
}
|
|
178
99
|
|
|
179
100
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @param {string} name - The base name for the theme, defaults to 'rokkit' if not provided.
|
|
183
|
-
* @param {Object} [mapping=defaultThemeMapping] - An object mapping variant names to color property names.
|
|
184
|
-
* @param {Object} [colors=defaultColors] - The object containing default color definitions.
|
|
185
|
-
* @returns {Array<Array>} An array containing two arrays, one for the light theme variant and another for the dark theme.
|
|
101
|
+
* Theme class for managing color palettes, mappings, and semantic shortcuts.
|
|
186
102
|
*/
|
|
187
|
-
export
|
|
188
|
-
|
|
189
|
-
|
|
103
|
+
export class Theme {
|
|
104
|
+
#colors
|
|
105
|
+
#mapping
|
|
190
106
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
],
|
|
196
|
-
[]
|
|
197
|
-
)
|
|
107
|
+
constructor({ colors = defaultColors, mapping = defaultThemeMapping } = {}) {
|
|
108
|
+
this.#colors = { ...defaultColors, ...colors }
|
|
109
|
+
this.#mapping = { ...defaultThemeMapping, ...mapping }
|
|
110
|
+
}
|
|
198
111
|
|
|
199
|
-
|
|
200
|
-
|
|
112
|
+
get colors() {
|
|
113
|
+
return this.#colors
|
|
114
|
+
}
|
|
115
|
+
set colors(colors) {
|
|
116
|
+
this.#colors = { ...colors }
|
|
117
|
+
}
|
|
201
118
|
|
|
202
|
-
|
|
203
|
-
|
|
119
|
+
get mapping() {
|
|
120
|
+
return this.#mapping
|
|
121
|
+
}
|
|
122
|
+
set mapping(mapping) {
|
|
123
|
+
this.#mapping = { ...mapping }
|
|
124
|
+
}
|
|
204
125
|
|
|
205
|
-
|
|
126
|
+
mapVariant(color, variant) {
|
|
127
|
+
return Object.keys(color).reduce(
|
|
128
|
+
(acc, key) => ({
|
|
129
|
+
...acc,
|
|
130
|
+
[key]: key === 'DEFAULT' ? `var(--color-${variant})` : `var(--color-${variant}-${key})`
|
|
131
|
+
}),
|
|
132
|
+
{}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getColorRules(mapping = null) {
|
|
137
|
+
const variants = Object.entries({ ...this.#mapping, ...mapping })
|
|
138
|
+
return variants.reduce(
|
|
139
|
+
(acc, [variant, key]) => ({
|
|
140
|
+
...acc,
|
|
141
|
+
[variant]: this.mapVariant(this.#colors[key], variant)
|
|
142
|
+
}),
|
|
143
|
+
{}
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getPalette(mapping = null) {
|
|
148
|
+
const useMapping = { ...this.#mapping, ...mapping }
|
|
149
|
+
const useColors = { ...defaultColors, ...this.#colors }
|
|
150
|
+
const variants = Object.keys(useMapping)
|
|
151
|
+
const rules = variants
|
|
152
|
+
.flatMap((variant) => generateColorRules(variant, useColors, useMapping))
|
|
153
|
+
.reduce((acc, { key, value }) => ({ ...acc, [key]: value }), {})
|
|
154
|
+
return rules
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
getShortcuts(name) {
|
|
158
|
+
return semanticShortcuts(name)
|
|
159
|
+
}
|
|
206
160
|
}
|
package/src/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { has, isNil } from 'ramda'
|
|
2
|
-
import { URL } from 'url'
|
|
3
2
|
import { DATA_IMAGE_REGEX } from './constants'
|
|
4
3
|
|
|
5
4
|
let idCounter = 0
|
|
@@ -156,23 +155,31 @@ export function hex2rgb(hex) {
|
|
|
156
155
|
* @returns {boolean} - Returns true if the string is an image URL
|
|
157
156
|
*/
|
|
158
157
|
function isImageUrl(str) {
|
|
159
|
-
// Check if the string
|
|
158
|
+
// Check if the string looks like a URL
|
|
160
159
|
try {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
// Use browser-native URL constructor or fallback to regex
|
|
161
|
+
const url = typeof URL !== 'undefined' ? new URL(str) : null
|
|
162
|
+
|
|
163
|
+
if (url) {
|
|
164
|
+
// Check common image extensions
|
|
165
|
+
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.tiff']
|
|
166
|
+
const path = url.pathname.toLowerCase()
|
|
167
|
+
|
|
168
|
+
if (imageExtensions.some((ext) => path.endsWith(ext))) {
|
|
169
|
+
return true
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
// Fallback regex-based URL validation for image extensions
|
|
173
|
+
const urlRegex = /^https?:\/\/.+\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff)(\?.*)?$/i
|
|
174
|
+
return urlRegex.test(str)
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
return false
|
|
172
178
|
// eslint-disable-next-line no-unused-vars
|
|
173
179
|
} catch (e) {
|
|
174
|
-
//
|
|
175
|
-
|
|
180
|
+
// Fallback regex-based validation
|
|
181
|
+
const urlRegex = /^https?:\/\/.+\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff)(\?.*)?$/i
|
|
182
|
+
return urlRegex.test(str)
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
/**
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Svelte action function for forwarding keyboard events from a parent element to a child.
|
|
3
|
-
* The child is selected using a CSS selector passed in the options object.
|
|
4
|
-
* Optionally, you can specify which keyboard events you want to forward: "keydown", "keyup", and/or "keypress".
|
|
5
|
-
* By default, all three events are forwarded.
|
|
6
|
-
*
|
|
7
|
-
* @param {HTMLElement} element - The parent element from which keyboard events will be forwarded.
|
|
8
|
-
* @param {import('./types').PushDownOptions} options - The options object.
|
|
9
|
-
* @returns {{destroy: Function}}
|
|
10
|
-
*/
|
|
11
|
-
export function delegateKeyboardEvents(element: HTMLElement, { selector, events }: import("./types").PushDownOptions): {
|
|
12
|
-
destroy: Function;
|
|
13
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./types.js";
|
|
2
|
-
export { keyboard } from "./keyboard.svelte.js";
|
|
3
|
-
export { pannable } from "./pannable.svelte.js";
|
|
4
|
-
export { swipeable } from "./swipeable.svelte.js";
|
|
5
|
-
export { navigator } from "./navigator.svelte.js";
|
|
6
|
-
export { themable } from "./themable.svelte.js";
|
|
7
|
-
export { skinnable } from "./skinnable.svelte.js";
|
|
8
|
-
export { dismissable } from "./dismissable.svelte.js";
|
|
9
|
-
export { navigable } from "./navigable.svelte.js";
|
|
10
|
-
export { fillable } from "./fillable.svelte.js";
|
|
11
|
-
export { delegateKeyboardEvents } from "./delegate.svelte.js";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets keyboard action handlers based on orientation and direction
|
|
3
|
-
* @param {Object} options - Configuration options
|
|
4
|
-
* @param {Object} handlers - Event handler functions
|
|
5
|
-
* @returns {Object} Object mapping key presses to handler functions
|
|
6
|
-
*/
|
|
7
|
-
export function getKeyboardActions(options: Object, handlers: Object): Object;
|
|
8
|
-
/**
|
|
9
|
-
* Creates a keyboard action mapping based on navigation options
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} options - Navigation options
|
|
12
|
-
* @param {string} options.orientation - Whether navigation is horizontal or vertical
|
|
13
|
-
* @param {string} options.dir - Text direction ('ltr' or 'rtl')
|
|
14
|
-
* @param {boolean} options.nested - Whether navigation is nested
|
|
15
|
-
* @returns {Object} Mapping of keys to actions
|
|
16
|
-
*/
|
|
17
|
-
export function createKeyboardActionMap(options: {
|
|
18
|
-
orientation: string;
|
|
19
|
-
dir: string;
|
|
20
|
-
nested: boolean;
|
|
21
|
-
}): Object;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a keyboard action mapping for modifier keys based on navigation options
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} options - Navigation options
|
|
26
|
-
* @param {string} options.orientation - Whether navigation is horizontal or vertical
|
|
27
|
-
* @returns {Object} Mapping of keys to actions
|
|
28
|
-
*/
|
|
29
|
-
export function createModifierKeyboardActionMap(options: {
|
|
30
|
-
orientation: string;
|
|
31
|
-
}): Object;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the keyboard action for a key event
|
|
34
|
-
* @param {KeyboardEvent} event - The keyboard event
|
|
35
|
-
* @param {Object} options - Configuration options
|
|
36
|
-
* @returns {string|null} The action to perform, or null if no action is defined
|
|
37
|
-
*/
|
|
38
|
-
export function getKeyboardAction(event: KeyboardEvent, options?: Object): string | null;
|
|
39
|
-
export namespace defaultNavigationOptions {
|
|
40
|
-
let orientation: string;
|
|
41
|
-
let dir: string;
|
|
42
|
-
let nested: boolean;
|
|
43
|
-
let enabled: boolean;
|
|
44
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventManager class to manage event listeners on an element.
|
|
3
|
-
*
|
|
4
|
-
* @param {HTMLElement} element - The element to listen for events on.
|
|
5
|
-
* @param {Object} handlers - An object with event names as keys and event handlers as values.
|
|
6
|
-
* @returns {Object} - An object with methods to activate, reset, and update the event listeners.
|
|
7
|
-
*/
|
|
8
|
-
export function EventManager(element: HTMLElement, handlers?: Object, enabled?: boolean): Object;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sets up event handlers based on the given options.
|
|
3
|
-
* Returns whether or not the event handlers are listening.
|
|
4
|
-
*
|
|
5
|
-
* @param {HTMLElement} element
|
|
6
|
-
* @param {import('../types').EventHandlers} listeners
|
|
7
|
-
* @param {import('../types').TraversableOptions} options
|
|
8
|
-
* @returns {void}
|
|
9
|
-
*/
|
|
10
|
-
export function setupListeners(element: HTMLElement, listeners: import("../types").EventHandlers, options: import("../types").TraversableOptions): void;
|
|
11
|
-
/**
|
|
12
|
-
* Removes event handlers based on the given options.
|
|
13
|
-
* Returns whether or not the event handlers are listening.
|
|
14
|
-
*
|
|
15
|
-
* @param {HTMLElement} element
|
|
16
|
-
* @param {import('../types').EventHandlers} listeners
|
|
17
|
-
* @returns {void}
|
|
18
|
-
*/
|
|
19
|
-
export function removeListeners(element: HTMLElement, listeners: import("../types").EventHandlers): void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A svelte action function that captures keyboard evvents and emits event for corresponding movements.
|
|
3
|
-
*
|
|
4
|
-
* @param {HTMLElement} node
|
|
5
|
-
* @param {import('./types').NavigableOptions} options
|
|
6
|
-
* @returns {import('./types').SvelteActionReturn}
|
|
7
|
-
*/
|
|
8
|
-
export function navigable(node: HTMLElement, options: import("./types").NavigableOptions): import("./types").SvelteActionReturn;
|