@studiocms/ui 0.3.2 → 0.4.1

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.
Files changed (156) hide show
  1. package/dist/components/Accordion/Accordion.astro +23 -0
  2. package/dist/components/Accordion/Item.astro +21 -0
  3. package/dist/components/Accordion/accordion.css +64 -0
  4. package/dist/components/Accordion/accordion.d.ts +1 -0
  5. package/dist/components/Accordion/accordion.js +70 -0
  6. package/dist/components/Badge/Badge.astro +49 -0
  7. package/dist/components/Badge/badge.css +111 -0
  8. package/dist/components/Breadcrumbs/Breadcrumbs.astro +31 -0
  9. package/dist/components/Breadcrumbs/breadcrumbs.css +15 -0
  10. package/dist/components/Button/Button.astro +75 -0
  11. package/dist/components/Button/button.css +292 -0
  12. package/{src/components → dist/components/Card}/Card.astro +1 -48
  13. package/dist/components/Card/card.css +38 -0
  14. package/dist/components/Center/Center.astro +7 -0
  15. package/dist/components/Center/center.css +8 -0
  16. package/dist/components/Checkbox/Checkbox.astro +95 -0
  17. package/dist/components/Checkbox/checkbox.css +119 -0
  18. package/dist/components/Checkbox/checkbox.d.ts +2 -0
  19. package/dist/components/Checkbox/checkbox.js +20 -0
  20. package/{src/components → dist/components/Divider}/Divider.astro +2 -25
  21. package/dist/components/Divider/divider.css +21 -0
  22. package/dist/components/Dropdown/Dropdown.astro +116 -0
  23. package/dist/components/Dropdown/dropdown.css +180 -0
  24. package/dist/components/Dropdown/dropdown.d.ts +48 -0
  25. package/dist/components/Dropdown/dropdown.js +201 -0
  26. package/dist/components/Footer/Footer.astro +58 -0
  27. package/dist/components/Footer/footer.css +68 -0
  28. package/dist/components/Group/Group.astro +7 -0
  29. package/dist/components/Group/group.css +19 -0
  30. package/{src/utils → dist/components/Icon}/Icon.astro +1 -1
  31. package/{src/utils/iconType.ts → dist/components/Icon/iconType.d.ts} +0 -1
  32. package/dist/components/Icon/iconType.js +0 -0
  33. package/{src/components → dist/components/Input}/Input.astro +2 -48
  34. package/dist/components/Input/input.css +38 -0
  35. package/{src → dist}/components/Modal/Modal.astro +4 -122
  36. package/dist/components/Modal/modal.css +100 -0
  37. package/dist/components/Modal/modal.d.ts +48 -0
  38. package/dist/components/Modal/modal.js +129 -0
  39. package/dist/components/Progress/Progress.astro +21 -0
  40. package/dist/components/Progress/helper.d.ts +13 -0
  41. package/dist/components/Progress/helper.js +32 -0
  42. package/dist/components/Progress/progress.css +29 -0
  43. package/dist/components/Progress/progress.d.ts +1 -0
  44. package/dist/components/Progress/progress.js +10 -0
  45. package/dist/components/RadioGroup/RadioGroup.astro +124 -0
  46. package/dist/components/RadioGroup/radiogroup.css +96 -0
  47. package/dist/components/RadioGroup/radiogroup.d.ts +1 -0
  48. package/dist/components/RadioGroup/radiogroup.js +48 -0
  49. package/{src/components → dist/components/Row}/Row.astro +1 -24
  50. package/dist/components/Row/row.css +18 -0
  51. package/dist/components/SearchSelect/SearchSelect.astro +135 -0
  52. package/dist/components/SearchSelect/searchselect.css +95 -0
  53. package/dist/components/SearchSelect/searchselect.d.ts +6 -0
  54. package/dist/components/SearchSelect/searchselect.js +166 -0
  55. package/dist/components/Select/Select.astro +147 -0
  56. package/dist/components/Select/select.css +110 -0
  57. package/dist/components/Select/select.d.ts +1 -0
  58. package/dist/components/Select/select.js +143 -0
  59. package/dist/components/Sidebar/helpers.d.ts +76 -0
  60. package/dist/components/Sidebar/helpers.js +160 -0
  61. package/{src → dist}/components/Tabs/TabItem.astro +3 -3
  62. package/dist/components/Tabs/Tabs.astro +150 -0
  63. package/dist/components/Tabs/tabs.css +121 -0
  64. package/dist/components/Tabs/tabs.d.ts +1 -0
  65. package/dist/components/Tabs/tabs.js +82 -0
  66. package/{src/components → dist/components/Textarea}/Textarea.astro +2 -61
  67. package/dist/components/Textarea/textarea.css +49 -0
  68. package/dist/components/ThemeToggle/ThemeToggle.astro +21 -0
  69. package/dist/components/ThemeToggle/themetoggle.css +17 -0
  70. package/dist/components/ThemeToggle/themetoggle.d.ts +1 -0
  71. package/dist/components/ThemeToggle/themetoggle.js +4 -0
  72. package/dist/components/Toast/Toaster.astro +69 -0
  73. package/dist/components/Toast/toast.d.ts +8 -0
  74. package/dist/components/Toast/toast.js +9 -0
  75. package/dist/components/Toast/toaster.css +168 -0
  76. package/dist/components/Toast/toaster.d.ts +1 -0
  77. package/dist/components/Toast/toaster.js +160 -0
  78. package/dist/components/Toggle/Toggle.astro +84 -0
  79. package/dist/components/Toggle/toggle.css +93 -0
  80. package/dist/components/Toggle/toggle.d.ts +2 -0
  81. package/dist/components/Toggle/toggle.js +20 -0
  82. package/{src/components → dist/components/User}/User.astro +3 -43
  83. package/dist/components/User/user.css +35 -0
  84. package/dist/css/colors.css +95 -0
  85. package/dist/css/global.css +3 -0
  86. package/dist/css/radii.css +6 -0
  87. package/dist/css/resets.css +46 -0
  88. package/dist/index.d.ts +12 -0
  89. package/dist/index.js +379 -0
  90. package/dist/toolbar/ColorPicker.d.ts +7 -0
  91. package/dist/toolbar/ColorPicker.js +85 -0
  92. package/dist/toolbar/icon.d.ts +1 -0
  93. package/dist/toolbar/icon.js +4 -0
  94. package/dist/toolbar/index.d.ts +2 -0
  95. package/dist/toolbar/index.js +292 -0
  96. package/dist/types/index.d.ts +11 -0
  97. package/dist/types/index.js +0 -0
  98. package/dist/utils/ThemeHelper.d.ts +49 -0
  99. package/dist/utils/ThemeHelper.js +113 -0
  100. package/{src/utils/colors.ts → dist/utils/colors.d.ts} +1 -1
  101. package/dist/utils/colors.js +0 -0
  102. package/dist/utils/generateID.d.ts +2 -0
  103. package/dist/utils/generateID.js +6 -0
  104. package/dist/utils/headers.d.ts +43 -0
  105. package/dist/utils/headers.js +129 -0
  106. package/dist/utils/iconStrings.d.ts +4 -0
  107. package/dist/utils/iconStrings.js +13 -0
  108. package/dist/utils/integration-utils.d.ts +130 -0
  109. package/dist/utils/integration-utils.js +161 -0
  110. package/package.json +26 -10
  111. package/src/components/BaseHead.astro +0 -22
  112. package/src/components/Button.astro +0 -372
  113. package/src/components/Center.astro +0 -16
  114. package/src/components/Checkbox.astro +0 -250
  115. package/src/components/Dropdown/Dropdown.astro +0 -314
  116. package/src/components/Dropdown/dropdown.ts +0 -258
  117. package/src/components/Dropdown/index.ts +0 -2
  118. package/src/components/Footer.astro +0 -137
  119. package/src/components/Modal/index.ts +0 -2
  120. package/src/components/Modal/modal.ts +0 -163
  121. package/src/components/RadioGroup.astro +0 -299
  122. package/src/components/SearchSelect.astro +0 -486
  123. package/src/components/Select.astro +0 -467
  124. package/src/components/Sidebar/helpers.ts +0 -179
  125. package/src/components/Sidebar/index.ts +0 -3
  126. package/src/components/Tabs/Tabs.astro +0 -393
  127. package/src/components/Tabs/index.ts +0 -2
  128. package/src/components/ThemeToggle.astro +0 -46
  129. package/src/components/Toast/Toaster.astro +0 -470
  130. package/src/components/Toast/index.ts +0 -2
  131. package/src/components/Toast/toast.ts +0 -16
  132. package/src/components/Toggle.astro +0 -214
  133. package/src/components/index.ts +0 -27
  134. package/src/components.ts +0 -26
  135. package/src/css/colors.css +0 -106
  136. package/src/css/global.css +0 -2
  137. package/src/css/resets.css +0 -54
  138. package/src/env.d.ts +0 -15
  139. package/src/integration.ts +0 -31
  140. package/src/layouts/RootLayout.astro +0 -33
  141. package/src/layouts/index.ts +0 -2
  142. package/src/layouts.ts +0 -1
  143. package/src/types/index.ts +0 -11
  144. package/src/utils/ThemeHelper.ts +0 -145
  145. package/src/utils/create-resolver.ts +0 -30
  146. package/src/utils/generateID.ts +0 -5
  147. package/src/utils/headers.ts +0 -190
  148. package/src/utils/iconStrings.ts +0 -29
  149. package/src/utils/index.ts +0 -1
  150. package/src/utils/virtual-module-plugin-builder.ts +0 -37
  151. /package/{src → dist}/components/Sidebar/Double.astro +0 -0
  152. /package/{src → dist}/components/Sidebar/Single.astro +0 -0
  153. /package/{src → dist}/icons/Checkmark.astro +0 -0
  154. /package/{src → dist}/icons/ChevronUpDown.astro +0 -0
  155. /package/{src → dist}/icons/User.astro +0 -0
  156. /package/{src → dist}/icons/X-Mark.astro +0 -0
@@ -1,486 +0,0 @@
1
- ---
2
- import Icon from '../utils/Icon.astro';
3
- import { generateID } from '../utils/generateID';
4
- import Input from './Input.astro';
5
-
6
- /**
7
- * An option in the select dropdown
8
- */
9
- interface Option {
10
- /**
11
- * The label of the option.
12
- */
13
- label: string;
14
- /**
15
- * The value of the option.
16
- */
17
- value: string;
18
- /**
19
- * Whether the option is disabled.
20
- */
21
- disabled?: boolean;
22
- }
23
-
24
- /**
25
- * The props for the search select component.
26
- */
27
- interface Props {
28
- /**
29
- * The label of the search select.
30
- */
31
- label?: string;
32
- /**
33
- * The default value of the search select. Needs to be one of the values in the options.
34
- */
35
- defaultValue?: string;
36
- /**
37
- * Additional classes to apply to the search select.
38
- */
39
- class?: string;
40
- /**
41
- * The name of the search select.
42
- */
43
- name?: string;
44
- /**
45
- * Whether the search select is required. Defaults to `false`.
46
- */
47
- isRequired?: boolean;
48
- /**
49
- * The options to display in the search select.
50
- */
51
- options: Option[];
52
- /**
53
- * Whether the search select is disabled. Defaults to `false`.
54
- */
55
- disabled?: boolean;
56
- /**
57
- * Whether the search select should take up the full width of its container.
58
- */
59
- fullWidth?: boolean;
60
- /**
61
- * The placeholder of the search select.
62
- */
63
- placeholder?: string;
64
- }
65
-
66
- const {
67
- label,
68
- defaultValue,
69
- class: className,
70
- name = generateID('search-select'),
71
- isRequired,
72
- options = [],
73
- disabled,
74
- fullWidth,
75
- placeholder,
76
- } = Astro.props;
77
- ---
78
-
79
- <div
80
- id={`${name}-container`}
81
- class="sui-search-select-label"
82
- class:list={[disabled && "disabled", className, fullWidth && "full"]}
83
- data-options={JSON.stringify(options)}
84
- data-id={name}
85
- >
86
- <div class="sui-search-input-wrapper" id={`${name}-search-input-wrapper`}>
87
- <Input
88
- placeholder={options.find((x) => x.value === defaultValue)?.label || (placeholder || "Select")}
89
- role='combobox'
90
- aria-controls={`${name}-dropdown`}
91
- aria-expanded="false"
92
- label={label || ''}
93
- isRequired={isRequired || false}
94
- />
95
- <Icon name="chevron-up-down" class="sui-search-select-indicator" width={24} height={24} />
96
- </div>
97
- <ul class="sui-search-select-dropdown" role="listbox" id={`${name}-dropdown`}>
98
- {
99
- options.map((x, i) => (
100
- <li
101
- class="sui-search-select-option"
102
- role="option"
103
- value={x.value}
104
- class:list={[
105
- x.disabled && "disabled",
106
- i === 0 && 'focused',
107
- ]}
108
- id={defaultValue === x.value ? `${name}-selected` : ""}
109
- data-option-index={i}
110
- data-value={x.value}
111
- >
112
- {x.label}
113
- </li>
114
- ))
115
- }
116
- </ul>
117
- <select class="sui-hidden-select" id={name} name={name} required={isRequired} hidden tabindex="-1">
118
- <option value={""}> Select </option>
119
- {
120
- options.map((x) => (
121
- <option
122
- value={x.value}
123
- selected={defaultValue === x.value}
124
- disabled={x.disabled}
125
- >
126
- {x.label}
127
- </option>
128
- ))
129
- }
130
- </select>
131
- </div>
132
- <script>
133
- interface Option {
134
- label: string;
135
- value: string;
136
- disabled?: boolean;
137
- }
138
- // id: name, options, defaultValue
139
- const searchSelects = document.querySelectorAll<HTMLDivElement>('.sui-search-select-label');
140
-
141
- for (const container of searchSelects) {
142
- const hiddenSelect = container.querySelector<HTMLSelectElement>('select')!;
143
- const searchWrapper = container.querySelector<HTMLDivElement>(`.sui-search-input-wrapper`)!;
144
- const searchInput = searchWrapper.querySelector('input')!;
145
- const dropdown = container.querySelector(`.sui-search-select-dropdown`)!;
146
- let optionElements = container.querySelectorAll("li");
147
-
148
- let active = false;
149
-
150
- const options = JSON.parse(container.dataset.options!) as Option[];
151
- const id = container.dataset.id!;
152
- let filteredOptions = options;
153
-
154
- searchWrapper.addEventListener("click", () => {
155
- const { bottom, left, right, width, x, y, height } = searchWrapper.getBoundingClientRect();
156
-
157
- const optionHeight = 36;
158
- const totalBorderSize = 2;
159
- const margin = 4;
160
-
161
- const dropdownHeight = options.length * optionHeight + totalBorderSize + margin;
162
-
163
- const CustomRect = {
164
- top: bottom + margin,
165
- left,
166
- right,
167
- bottom: bottom + margin + dropdownHeight,
168
- width,
169
- height: dropdownHeight,
170
- x,
171
- y: y + height + margin,
172
- };
173
-
174
- if (active) {
175
- searchInput.ariaExpanded = 'false';
176
- dropdown.classList.remove("active", "above");
177
- active = false;
178
- return;
179
- }
180
-
181
- active = true;
182
- searchInput.ariaExpanded = 'true';
183
-
184
- if (
185
- CustomRect.top >= 0 &&
186
- CustomRect.left >= 0 &&
187
- CustomRect.bottom <=
188
- (window.innerHeight || document.documentElement.clientHeight) &&
189
- CustomRect.right <=
190
- (window.innerWidth || document.documentElement.clientWidth)
191
- ) {
192
- dropdown.classList.add("active");
193
- } else {
194
- dropdown.classList.add("active", "above");
195
- }
196
- });
197
-
198
- const handleSelection = (e: MouseEvent, option: HTMLLIElement) => {
199
- e.stopImmediatePropagation();
200
-
201
- if (option.id === `${id}-selected` || !id) return;
202
-
203
- const currentlySelected = document.getElementById(`${id}-selected`);
204
-
205
- if (currentlySelected) {
206
- currentlySelected.classList.remove("selected");
207
- currentlySelected.id = "";
208
- }
209
-
210
- option.id = `${id}-selected`;
211
- option.classList.add("selected");
212
-
213
- const index = options.findIndex((x) => x.value === option.dataset.value);
214
- focusIndex = index;
215
-
216
- const opt = options[index]!;
217
- hiddenSelect.value = opt.value;
218
-
219
- searchInput.placeholder = opt.label;
220
- dropdown.classList.remove("active", "above");
221
- // searchInput.blur();
222
-
223
- searchInput.value = "";
224
- filteredOptions = options;
225
- constructOptionsBasedOnOptions(options);
226
-
227
- active = false;
228
- }
229
-
230
- optionElements.forEach((option) => {
231
- option.addEventListener("click", (e) => handleSelection(e, option));
232
- });
233
-
234
- window.addEventListener("scroll", () => {
235
- dropdown.classList.remove("active", "above");
236
- active = false;
237
- });
238
-
239
- hideOnClickOutside(container);
240
-
241
- function hideOnClickOutside(element: HTMLElement) {
242
- const outsideClickListener = (event: MouseEvent) => {
243
- if (
244
- !element.contains(event.target! as Element) &&
245
- isVisible(element) &&
246
- active === true
247
- ) {
248
- // or use: event.target.closest(selector) === null
249
- dropdown.classList.remove("active", "above");
250
- active = false;
251
- }
252
- };
253
-
254
- document.addEventListener("click", outsideClickListener);
255
- }
256
-
257
- // source (2018-03-11): https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js
258
- const isVisible = (elem: HTMLElement) =>
259
- !!elem &&
260
- !!(
261
- elem.offsetWidth ||
262
- elem.offsetHeight ||
263
- elem.getClientRects().length
264
- );
265
-
266
- let focusIndex = 0;
267
-
268
- const recomputeOptions = () => {
269
- for (const entry of optionElements) {
270
- if (Number.parseInt(entry.dataset.optionIndex!) == focusIndex) {
271
- entry.classList.add('focused');
272
- } else {
273
- entry.classList.remove('focused');
274
- }
275
- }
276
- }
277
-
278
- searchInput.addEventListener('keydown', (e) => {
279
- if (e.key === "Escape") {
280
- e.preventDefault();
281
- e.stopImmediatePropagation();
282
-
283
- active = false;
284
- dropdown.classList.remove("active", "above");
285
- searchInput.blur();
286
-
287
- return;
288
- }
289
-
290
- if (e.key === "ArrowUp" && focusIndex > 0) {
291
- e.preventDefault();
292
- e.stopImmediatePropagation();
293
-
294
- focusIndex--;
295
- recomputeOptions();
296
-
297
- return;
298
- }
299
-
300
- if (e.key === "ArrowDown" && focusIndex + 1 < filteredOptions.filter(x => !x.disabled).length) {
301
- e.preventDefault();
302
- e.stopImmediatePropagation();
303
-
304
- focusIndex++;
305
- recomputeOptions();
306
-
307
- return;
308
- }
309
-
310
- if (e.key === "Enter") {
311
- e.preventDefault();
312
- e.stopImmediatePropagation();
313
-
314
- for (const entry of optionElements) {
315
- if (Number.parseInt(entry.dataset.optionIndex!) === focusIndex) {
316
- entry.click();
317
- }
318
- }
319
-
320
- return;
321
- }
322
- });
323
-
324
- searchInput.addEventListener('keyup', (e) => {
325
- if (["Enter", "ArrowUp", "ArrowDown"].includes(e.key)) return;
326
-
327
- if (searchInput.value.trim().length === 0) {
328
- constructOptionsBasedOnOptions(options);
329
- filteredOptions = options;
330
- return;
331
- };
332
-
333
- filteredOptions = options.filter(x => x.label.includes(searchInput.value));
334
- focusIndex = 0;
335
-
336
- constructOptionsBasedOnOptions(filteredOptions);
337
- });
338
-
339
- function constructOptionsBasedOnOptions(options: Option[]) {
340
- dropdown.innerHTML = '';
341
-
342
- if (options.length === 0) {
343
- const element = document.createElement('li');
344
- element.classList.add('empty-search-results');
345
- element.textContent = "No results found.";
346
-
347
- dropdown.appendChild(element);
348
- }
349
-
350
- let i = 0;
351
-
352
- for (const option of options) {
353
- const element = document.createElement('li');
354
- element.classList.add(...[
355
- 'sui-search-select-option',
356
- option.disabled && "disabled",
357
- focusIndex === i && 'focused',
358
- ].filter((x) => typeof x === 'string'));
359
- element.role = "option";
360
- element.value = Number.parseInt(option.value);
361
- element.id = "";
362
- element.dataset.optionIndex = i.toString();
363
- element.dataset.value = option.value;
364
- element.textContent = option.label;
365
-
366
- element.addEventListener("click", (e) => handleSelection(e, element));
367
-
368
- dropdown.appendChild(element);
369
-
370
- i++;
371
- }
372
-
373
- optionElements = container.querySelectorAll("li");
374
- }
375
- }
376
- </script>
377
- <style is:global>
378
- .sui-search-select-label {
379
- width: fit-content;
380
- display: flex;
381
- flex-direction: column;
382
- gap: 0.25rem;
383
- min-width: 200px;
384
- position: relative;
385
- }
386
-
387
- .sui-search-select-label.full {
388
- width: 100%;
389
- }
390
-
391
- .sui-search-select-label.disabled {
392
- opacity: 0.5;
393
- pointer-events: none;
394
- color: hsl(var(--text-muted));
395
- }
396
-
397
- .label {
398
- font-size: 14px;
399
- }
400
-
401
- .req-star {
402
- color: hsl(var(--danger-base));
403
- font-weight: 700;
404
- }
405
-
406
- .sui-search-select-dropdown {
407
- position: absolute;
408
- width: 100%;
409
- border: 1px solid hsl(var(--border));
410
- list-style: none;
411
- margin: 0;
412
- padding: 0;
413
- flex-direction: column;
414
- border-radius: 0.5rem;
415
- background-color: hsl(var(--background-step-2));
416
- overflow: hidden;
417
- top: calc(100% + 0.25rem);
418
- left: 0;
419
- display: none;
420
- z-index: 90;
421
- box-shadow: 0px 4px 8px hsl(var(--shadow), 0.5);
422
- }
423
-
424
- .sui-search-select-dropdown.above {
425
- top: auto;
426
- bottom: calc(100% - 18px + 0.25rem);
427
- }
428
-
429
- .sui-search-select-option, .empty-search-results {
430
- padding: 0.5rem;
431
- cursor: pointer;
432
- font-size: 0.975em;
433
- transition: all 0.15s ease;
434
- }
435
-
436
- .sui-search-select-option.disabled {
437
- pointer-events: none;
438
- color: hsl(var(--text-muted));
439
- }
440
-
441
- .sui-search-select-option:hover, .sui-search-select-option.focused {
442
- background-color: hsl(var(--background-step-3));
443
- }
444
-
445
- .sui-search-select-option.selected {
446
- background-color: hsl(var(--primary-base));
447
- color: hsl(var(--text-inverted));
448
- cursor: default;
449
- }
450
-
451
- .sui-hidden-select {
452
- height: 0;
453
- width: 0;
454
- border: none;
455
- outline: none;
456
- position: absolute;
457
- background-color: transparent;
458
- pointer-events: none;
459
- opacity: 0;
460
- }
461
-
462
- .sui-search-input-wrapper {
463
- width: 100%;
464
- position: relative;
465
- height: fit-content;
466
- cursor: pointer;
467
- }
468
-
469
- .sui-search-input-wrapper input {
470
- padding-right: 2.5rem;
471
- }
472
-
473
- .sui-search-select-indicator {
474
- position: absolute;
475
- bottom: .675rem;
476
- right: .675rem;
477
- }
478
-
479
- .sui-search-input-wrapper:has(input:focus) + .sui-search-select-dropdown {
480
- display: flex;
481
- }
482
-
483
- .sui-search-select-dropdown.active, .sui-search-select-dropdown:has(> li:active) {
484
- display: flex;
485
- }
486
- </style>