@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/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,93 @@
|
|
|
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
|
+
* A utility function that detects if a string is an image URL or image data (base64)
|
|
89
|
+
*
|
|
90
|
+
* @param {string} str - The string to check
|
|
91
|
+
* @returns {string|null} - Returns the original string if it's an image URL or image data, otherwise null
|
|
92
|
+
*/
|
|
93
|
+
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,59 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-next.140",
|
|
4
|
+
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/jerrythomas/rokkit.git"
|
|
8
|
+
},
|
|
5
9
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
10
|
"license": "MIT",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"svelte": "src/index.js",
|
|
9
|
-
"module": "src/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
11
|
"type": "module",
|
|
12
|
-
"prettier": "@jerrythomas/prettier-config",
|
|
13
12
|
"publishConfig": {
|
|
14
13
|
"access": "public"
|
|
15
14
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"@vitest/coverage-istanbul": "^0.28.5",
|
|
22
|
-
"@vitest/ui": "~0.12.10",
|
|
23
|
-
"eslint": "^7.32.0",
|
|
24
|
-
"jsdom": "^19.0.0",
|
|
25
|
-
"svelte": "^3.55.1",
|
|
26
|
-
"typescript": "^4.9.5",
|
|
27
|
-
"validators": "latest",
|
|
28
|
-
"vite": "^4.1.1",
|
|
29
|
-
"vitest": "~0.19.1",
|
|
30
|
-
"shared-config": "1.0.0"
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prepublishOnly": "cp ../../LICENSE . && bunx tsc --project tsconfig.build.json",
|
|
17
|
+
"postpublish": "rm -f LICENSE",
|
|
18
|
+
"clean": "rm -rf dist",
|
|
19
|
+
"build": "bun clean && bun prepublishOnly"
|
|
31
20
|
},
|
|
32
21
|
"files": [
|
|
33
22
|
"src/**/*.js",
|
|
34
|
-
"src/**/*.
|
|
35
|
-
"
|
|
36
|
-
"
|
|
23
|
+
"src/**/*.ts",
|
|
24
|
+
"src/**/*.json",
|
|
25
|
+
"dist/**/*.d.ts",
|
|
26
|
+
"README.md",
|
|
27
|
+
"package.json",
|
|
28
|
+
"LICENSE"
|
|
37
29
|
],
|
|
38
30
|
"exports": {
|
|
39
31
|
"./src": "./src",
|
|
40
32
|
"./package.json": "./package.json",
|
|
41
|
-
"./stores": "./src/stores/index.js",
|
|
42
|
-
"./actions": "./src/actions/index.js",
|
|
43
|
-
"./constants": "./src/constants.js",
|
|
44
33
|
".": {
|
|
45
34
|
"types": "./dist/index.d.ts",
|
|
46
|
-
"import": "./src/index.js"
|
|
35
|
+
"import": "./src/index.js",
|
|
36
|
+
"svelte": "./src/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./vite": {
|
|
39
|
+
"types": "./dist/vite/index.d.ts",
|
|
40
|
+
"import": "./src/vite/index.js"
|
|
47
41
|
}
|
|
48
42
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"coverage": "vitest run --coverage",
|
|
57
|
-
"upgrade": "pnpm upgrade"
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@unocss/preset-mini": "^66.6.1",
|
|
45
|
+
"date-fns": "^4.1.0",
|
|
46
|
+
"ramda": "^0.32.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@rokkit/icons": "workspace:*"
|
|
58
50
|
}
|
|
59
|
-
}
|
|
51
|
+
}
|
package/src/calendar.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getDay, getMonth, getYear, getDaysInMonth, format, isWeekend } from 'date-fns'
|
|
2
|
+
|
|
3
|
+
export const weekdays = [
|
|
4
|
+
'Sunday',
|
|
5
|
+
'Monday',
|
|
6
|
+
'Tuesday',
|
|
7
|
+
'Wednesday',
|
|
8
|
+
'Thursday',
|
|
9
|
+
'Friday',
|
|
10
|
+
'Saturday'
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the days in the month.
|
|
15
|
+
*
|
|
16
|
+
* @param {Date} value
|
|
17
|
+
* @param {Array} holidays
|
|
18
|
+
* @param {boolean} fixed
|
|
19
|
+
* @returns {import('./types').CalendarDay[]}
|
|
20
|
+
*/
|
|
21
|
+
export function getCalendarDays(value, holidays = [], fixed = false) {
|
|
22
|
+
const month = getMonth(value)
|
|
23
|
+
const year = getYear(value)
|
|
24
|
+
const offset = getDay(new Date(year, month, 1)) + 1
|
|
25
|
+
|
|
26
|
+
holidays = holidays.map((x) => format(new Date(x), 'yyyy-MMM-dd'))
|
|
27
|
+
let days = Array.from({ length: getDaysInMonth(value) }, (_, i) => ({
|
|
28
|
+
day: i + 1,
|
|
29
|
+
offset: i === 0 ? offset : 0,
|
|
30
|
+
date: new Date(year, month, i + 1)
|
|
31
|
+
})).map((x) => ({
|
|
32
|
+
...x,
|
|
33
|
+
text: format(x.date, 'yyyy-MMM-dd'),
|
|
34
|
+
weekend: isWeekend(x.date),
|
|
35
|
+
holiday: holidays.includes(format(x.date, 'yyyy-MMM-dd'))
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
if (fixed && days[0].offset > 4) {
|
|
39
|
+
const n = 5 * 7 - days[0].offset
|
|
40
|
+
days = [...days.slice(n + 1), ...days.slice(0, n + 1)]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return days
|
|
44
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { colors } from '@unocss/preset-mini/colors'
|
|
4
|
+
import type { PresetMiniColors } from '@unocss/preset-mini/colors'
|
|
5
|
+
import syntaxColorPalette from './syntax.json' with { type: 'json' }
|
|
6
|
+
import extraColors from './extra.json' with { type: 'json' }
|
|
7
|
+
|
|
8
|
+
export const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
|
9
|
+
export const defaultPalette = [
|
|
10
|
+
'surface',
|
|
11
|
+
'primary',
|
|
12
|
+
'secondary',
|
|
13
|
+
'accent',
|
|
14
|
+
'success',
|
|
15
|
+
'warning',
|
|
16
|
+
'danger',
|
|
17
|
+
'info'
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
export const syntaxColors = syntaxColorPalette
|
|
21
|
+
export const defaultColors: PresetMiniColors & typeof extraColors = {
|
|
22
|
+
...colors,
|
|
23
|
+
...extraColors
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"one-dark": {
|
|
3
|
+
"dark": {
|
|
4
|
+
"--tab-size": "2",
|
|
5
|
+
"--code-fill": "var(--surface-100)",
|
|
6
|
+
"--code-normal": "#e06c75",
|
|
7
|
+
"--code-string": "#98c379",
|
|
8
|
+
"--code-number": "#d19a66",
|
|
9
|
+
"--code-atrule": "var(--code-string)",
|
|
10
|
+
"--code-keyword": "#c678dd",
|
|
11
|
+
"--code-comment": "#5c6370",
|
|
12
|
+
"--code-property": "#d19a66",
|
|
13
|
+
"--code-selector": "var(--code-keyword)",
|
|
14
|
+
"--code-operator": "#56b6c2",
|
|
15
|
+
"--code-function": "#61afef",
|
|
16
|
+
"--code-gutter-marker": "black",
|
|
17
|
+
"--code-gutter-z2": "#999",
|
|
18
|
+
"--code-cursor": "#24292e",
|
|
19
|
+
"--code-cursor-block": "rgba(20, 255, 20, 0.5)",
|
|
20
|
+
"--code-linenumbers": "rgba(27, 31, 35, 0.3)"
|
|
21
|
+
},
|
|
22
|
+
"light": {
|
|
23
|
+
"--tab-size": "2",
|
|
24
|
+
"--code-fill": "var(--surface-100)",
|
|
25
|
+
"--code-normal": "#333333",
|
|
26
|
+
"--code-string": "#9D8248",
|
|
27
|
+
"--code-number": "#71A15D",
|
|
28
|
+
"--code-atrule": "var(--code-string)",
|
|
29
|
+
"--code-keyword": "#3080B5",
|
|
30
|
+
"--code-comment": "#969896",
|
|
31
|
+
"--code-property": "#63a35c",
|
|
32
|
+
"--code-selector": "var(--code-keyword)",
|
|
33
|
+
"--code-operator": "#bf5625",
|
|
34
|
+
"--code-function": "#a71d5d",
|
|
35
|
+
"--code-gutter-marker": "black",
|
|
36
|
+
"--code-gutter-z2": "#999",
|
|
37
|
+
"--code-cursor": "#24292e",
|
|
38
|
+
"--code-cursor-block": "rgba(20, 255, 20, 0.5)",
|
|
39
|
+
"--code-linenumbers": "rgba(27, 31, 35, 0.3)"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|