@rokkit/core 1.0.0-next.11 → 1.0.0-next.111
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/calendar.d.ts +10 -0
- package/dist/colors/index.d.ts +333 -0
- package/dist/connector.d.ts +8 -0
- package/dist/constants.d.ts +39 -0
- package/dist/events.d.ts +12 -0
- package/dist/field-mapper.d.ts +63 -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 +75 -0
- package/dist/nested.d.ts +18 -0
- package/dist/string.d.ts +59 -0
- package/dist/theme.d.ts +52 -0
- package/dist/ticks.d.ts +10 -0
- package/dist/types.d.ts +245 -0
- package/dist/utils.d.ts +70 -0
- package/package.json +13 -38
- package/src/calendar.js +44 -0
- package/src/colors/index.js +19 -0
- package/src/colors/syntax.json +42 -0
- package/src/colors/tailwind.json +289 -0
- package/src/connector.js +34 -0
- package/src/constants.js +67 -94
- package/src/events.js +32 -0
- package/src/field-mapper.js +148 -0
- package/src/index.js +19 -27
- package/src/key-event-map.js +36 -0
- package/src/mapped-items.js +22 -0
- package/src/mapping.js +134 -0
- package/src/nested.js +56 -0
- package/src/string.js +97 -0
- package/src/theme.js +205 -0
- package/src/ticks.js +26 -0
- package/src/types.js +124 -0
- package/src/utils.js +134 -0
- package/LICENSE +0 -21
- package/README.md +0 -1
- package/src/Accordion.svelte +0 -80
- package/src/Alerts.svelte +0 -39
- package/src/DropDown.svelte +0 -79
- package/src/DropSearch.svelte +0 -67
- 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 -87
- 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 -31
- package/src/Tree.svelte +0 -19
- package/src/actions/dismissable.js +0 -24
- package/src/actions/fillable.js +0 -114
- package/src/actions/hierarchy.js +0 -189
- package/src/actions/index.js +0 -7
- package/src/actions/navigable.js +0 -42
- 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 -17
- 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/theme.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate shades for a color using css varuable
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name
|
|
5
|
+
* @param {string} modifier
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function shadesOf(name: string, modifier?: string): {
|
|
9
|
+
DEFAULT: any;
|
|
10
|
+
base: any;
|
|
11
|
+
inset: any;
|
|
12
|
+
subtle: any;
|
|
13
|
+
muted: any;
|
|
14
|
+
raised: any;
|
|
15
|
+
elevated: any;
|
|
16
|
+
floating: any;
|
|
17
|
+
contrast: any;
|
|
18
|
+
overlay: any;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Generate shades for a color using css varuable
|
|
22
|
+
*
|
|
23
|
+
* @param {string} name
|
|
24
|
+
* @param {string} modifier
|
|
25
|
+
* @returns {object}
|
|
26
|
+
*/
|
|
27
|
+
export function stateColors(name: string, modifier?: string): object;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {string} modifier
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export function themeColors(modifier?: string): {};
|
|
34
|
+
/**
|
|
35
|
+
* Generates contrast colors for light and dark modes based on a given palette. Each color variant in the
|
|
36
|
+
* palette is mapped to either a light or dark contrast color depending on the shade's value.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} [light='#ffffff'] - The default light color used when the shade is >= 500 in light mode or <= 500 in dark mode.
|
|
39
|
+
* @param {string} [dark='#000000'] - The default dark color used when the shade is < 500 in light mode or > 500 in dark mode.
|
|
40
|
+
* @param {Array<string>} [palette=defaultPalette] - An array of color variant names to generate contrast colors for.
|
|
41
|
+
* @returns {Array<Object>} An array containing contrast color rules organized by light and dark modes for each variant in the palette.
|
|
42
|
+
*/
|
|
43
|
+
export function contrastColors(light?: string, dark?: string, palette?: Array<string>): Array<Object>;
|
|
44
|
+
/**
|
|
45
|
+
* Constructs and returns the light and dark theme variants based on provided color mapping and color definitions.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} name - The base name for the theme, defaults to 'rokkit' if not provided.
|
|
48
|
+
* @param {Object} [mapping=defaultThemeMapping] - An object mapping variant names to color property names.
|
|
49
|
+
* @param {Object} [colors=defaultColors] - The object containing default color definitions.
|
|
50
|
+
* @returns {Array<Array>} An array containing two arrays, one for the light theme variant and another for the dark theme.
|
|
51
|
+
*/
|
|
52
|
+
export function themeRules(name?: string, mapping?: Object, colors?: Object): Array<any[]>;
|
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,245 @@
|
|
|
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
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the closest ancestor of the given element that has the given attribute.
|
|
3
|
+
*
|
|
4
|
+
* @param {HTMLElement} element
|
|
5
|
+
* @param {string} attribute
|
|
6
|
+
* @returns {HTMLElement|null}
|
|
7
|
+
*/
|
|
8
|
+
export function getClosestAncestorWithAttribute(element: HTMLElement, attribute: string): HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* A function that performs no operations.
|
|
11
|
+
*/
|
|
12
|
+
export function noop(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a random id
|
|
15
|
+
*
|
|
16
|
+
* @returns {string} A random id
|
|
17
|
+
*/
|
|
18
|
+
export function id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a value is a json object
|
|
21
|
+
*
|
|
22
|
+
* @param {*} val
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export function isObject(val: any): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Converts the value to a string. If the value is an object, it will convert it to a JSON string.
|
|
28
|
+
*
|
|
29
|
+
* @param {*} value
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function toString(value: any): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generates icon shortcuts for a collection of icons
|
|
35
|
+
*
|
|
36
|
+
* @param {string[]} icons
|
|
37
|
+
* @param {string} collection
|
|
38
|
+
* @param {string} variants
|
|
39
|
+
* @returns {Object}
|
|
40
|
+
*/
|
|
41
|
+
export function iconShortcuts(icons: string[], collection: string, variants: string): Object;
|
|
42
|
+
/**
|
|
43
|
+
* Scales the path by the size
|
|
44
|
+
*
|
|
45
|
+
* @param {number} size
|
|
46
|
+
* @param {string|number} x
|
|
47
|
+
* @returns {string|number}
|
|
48
|
+
*/
|
|
49
|
+
export function scaledPath(size: number, x: string | number): string | number;
|
|
50
|
+
/**
|
|
51
|
+
* Gets a key string from path
|
|
52
|
+
* @param {string[]} path
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
export function getKeyFromPath(path: string[]): string;
|
|
56
|
+
/**
|
|
57
|
+
* Gets a path array from key string
|
|
58
|
+
* @param {string} key
|
|
59
|
+
* @returns {string[]}
|
|
60
|
+
*/
|
|
61
|
+
export function getPathFromKey(key: string): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Get snippet function from an object
|
|
64
|
+
* @param {Object} obj
|
|
65
|
+
* @param {string} key
|
|
66
|
+
* @param {null|Function} defaultSnippet
|
|
67
|
+
* @returns {Function|undefined}
|
|
68
|
+
*/
|
|
69
|
+
export function getSnippet(obj: Object, key: string, defaultSnippet?: null | Function): Function | undefined;
|
|
70
|
+
export function importIcons(icons: Object): Object;
|
package/package.json
CHANGED
|
@@ -1,59 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-next.111",
|
|
4
|
+
"description": "Contains core utility functions and classes that can be used in various components.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"svelte": "src/index.js",
|
|
9
|
-
"module": "src/index.js",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
7
|
"type": "module",
|
|
12
|
-
"
|
|
8
|
+
"module": "src/index.js",
|
|
13
9
|
"publishConfig": {
|
|
14
10
|
"access": "public"
|
|
15
11
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"@testing-library/svelte": "^3.2.2",
|
|
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"
|
|
12
|
+
"scripts": {
|
|
13
|
+
"prepublishOnly": "tsc --project tsconfig.build.json",
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"build": "bun clean && bun prepublishOnly"
|
|
31
16
|
},
|
|
32
17
|
"files": [
|
|
33
18
|
"src/**/*.js",
|
|
34
|
-
"src/**/*.
|
|
35
|
-
"
|
|
36
|
-
"!src/**/*.spec.js"
|
|
19
|
+
"src/**/*.json",
|
|
20
|
+
"dist/**/*.d.ts"
|
|
37
21
|
],
|
|
38
22
|
"exports": {
|
|
39
23
|
"./src": "./src",
|
|
40
24
|
"./package.json": "./package.json",
|
|
41
|
-
"./stores": "./src/stores/index.js",
|
|
42
|
-
"./actions": "./src/actions/index.js",
|
|
43
|
-
"./constants": "./src/constants.js",
|
|
44
25
|
".": {
|
|
45
26
|
"types": "./dist/index.d.ts",
|
|
46
27
|
"import": "./src/index.js"
|
|
47
28
|
}
|
|
48
29
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"test:ct": "playwright test -c playwright.config.js",
|
|
53
|
-
"test:ci": "vitest run",
|
|
54
|
-
"test:ui": "vitest --ui",
|
|
55
|
-
"test": "vitest",
|
|
56
|
-
"coverage": "vitest run --coverage",
|
|
57
|
-
"upgrade": "pnpm upgrade"
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"date-fns": "^4.1.0",
|
|
32
|
+
"ramda": "^0.30.1"
|
|
58
33
|
}
|
|
59
|
-
}
|
|
34
|
+
}
|
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,19 @@
|
|
|
1
|
+
import defaultTailwindColors from './tailwind.json' with { type: 'json' }
|
|
2
|
+
import syntaxColorPalette from './syntax.json' with { type: 'json' }
|
|
3
|
+
|
|
4
|
+
export const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
|
5
|
+
export const defaultPalette = [
|
|
6
|
+
'neutral',
|
|
7
|
+
'primary',
|
|
8
|
+
'secondary',
|
|
9
|
+
'accent',
|
|
10
|
+
'success',
|
|
11
|
+
'warning',
|
|
12
|
+
'danger',
|
|
13
|
+
'info'
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export const syntaxColors = syntaxColorPalette
|
|
17
|
+
export const defaultColors = {
|
|
18
|
+
...defaultTailwindColors
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"one-dark": {
|
|
3
|
+
"dark": {
|
|
4
|
+
"--tab-size": "2",
|
|
5
|
+
"--code-fill": "var(--neutral-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-subtle": "#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(--neutral-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-subtle": "#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
|
+
}
|