@syware/jlib 0.0.0-stage → 0.1.3
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 +21 -0
- package/README.md +133 -2
- package/dist/all.d.ts +1 -0
- package/dist/all.js +75 -0
- package/dist/atoms/jl-avatar.css_raw.js +3 -0
- package/dist/atoms/jl-avatar.d.ts +52 -0
- package/dist/atoms/jl-avatar.js +167 -0
- package/dist/atoms/jl-badge.css_raw.js +3 -0
- package/dist/atoms/jl-badge.d.ts +32 -0
- package/dist/atoms/jl-badge.js +60 -0
- package/dist/atoms/jl-button.css_raw.js +3 -0
- package/dist/atoms/jl-button.d.ts +70 -0
- package/dist/atoms/jl-button.js +146 -0
- package/dist/atoms/jl-checkbox.css_raw.js +3 -0
- package/dist/atoms/jl-checkbox.d.ts +61 -0
- package/dist/atoms/jl-checkbox.js +149 -0
- package/dist/atoms/jl-chip.css_raw.js +3 -0
- package/dist/atoms/jl-chip.d.ts +59 -0
- package/dist/atoms/jl-chip.js +164 -0
- package/dist/atoms/jl-divider.css_raw.js +3 -0
- package/dist/atoms/jl-divider.d.ts +26 -0
- package/dist/atoms/jl-divider.js +59 -0
- package/dist/atoms/jl-icon.css_raw.js +3 -0
- package/dist/atoms/jl-icon.d.ts +25 -0
- package/dist/atoms/jl-icon.js +41 -0
- package/dist/atoms/jl-input.css_raw.js +3 -0
- package/dist/atoms/jl-input.d.ts +112 -0
- package/dist/atoms/jl-input.js +202 -0
- package/dist/atoms/jl-kbd.css_raw.js +3 -0
- package/dist/atoms/jl-kbd.d.ts +17 -0
- package/dist/atoms/jl-kbd.js +62 -0
- package/dist/atoms/jl-link.css_raw.js +3 -0
- package/dist/atoms/jl-link.d.ts +37 -0
- package/dist/atoms/jl-link.js +86 -0
- package/dist/atoms/jl-progress-ring.css_raw.js +3 -0
- package/dist/atoms/jl-progress-ring.d.ts +49 -0
- package/dist/atoms/jl-progress-ring.js +132 -0
- package/dist/atoms/jl-progress.css_raw.js +3 -0
- package/dist/atoms/jl-progress.d.ts +43 -0
- package/dist/atoms/jl-progress.js +109 -0
- package/dist/atoms/jl-rating.css_raw.js +3 -0
- package/dist/atoms/jl-rating.d.ts +73 -0
- package/dist/atoms/jl-rating.js +184 -0
- package/dist/atoms/jl-select.css_raw.js +3 -0
- package/dist/atoms/jl-select.d.ts +70 -0
- package/dist/atoms/jl-select.js +146 -0
- package/dist/atoms/jl-skeleton.css_raw.js +3 -0
- package/dist/atoms/jl-skeleton.d.ts +34 -0
- package/dist/atoms/jl-skeleton.js +63 -0
- package/dist/atoms/jl-slider.css_raw.js +3 -0
- package/dist/atoms/jl-slider.d.ts +65 -0
- package/dist/atoms/jl-slider.js +143 -0
- package/dist/atoms/jl-spinner.css_raw.js +3 -0
- package/dist/atoms/jl-spinner.d.ts +16 -0
- package/dist/atoms/jl-spinner.js +26 -0
- package/dist/atoms/jl-switch.css_raw.js +3 -0
- package/dist/atoms/jl-switch.d.ts +57 -0
- package/dist/atoms/jl-switch.js +125 -0
- package/dist/atoms/jl-textarea.css_raw.js +3 -0
- package/dist/atoms/jl-textarea.d.ts +81 -0
- package/dist/atoms/jl-textarea.js +148 -0
- package/dist/base/jl-element.d.ts +16 -0
- package/dist/base/jl-element.js +35 -0
- package/dist/base/jl-form-control.d.ts +29 -0
- package/dist/base/jl-form-control.js +44 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +72 -0
- package/dist/lib/arrow.d.ts +6 -0
- package/dist/lib/arrow.js +15 -0
- package/dist/lib/attributes.d.ts +9 -0
- package/dist/lib/attributes.js +22 -0
- package/dist/lib/avatar.d.ts +11 -0
- package/dist/lib/avatar.js +37 -0
- package/dist/lib/calendar.d.ts +48 -0
- package/dist/lib/calendar.js +166 -0
- package/dist/lib/css-length.d.ts +2 -0
- package/dist/lib/css-length.js +8 -0
- package/dist/lib/define.d.ts +9 -0
- package/dist/lib/define.js +9 -0
- package/dist/lib/dom.d.ts +4 -0
- package/dist/lib/dom.js +16 -0
- package/dist/lib/files.d.ts +18 -0
- package/dist/lib/files.js +89 -0
- package/dist/lib/floating.d.ts +13 -0
- package/dist/lib/floating.js +127 -0
- package/dist/lib/fuzzy.d.ts +26 -0
- package/dist/lib/fuzzy.js +149 -0
- package/dist/lib/highlight.d.ts +5 -0
- package/dist/lib/highlight.js +267 -0
- package/dist/lib/hotkey.d.ts +9 -0
- package/dist/lib/hotkey.js +101 -0
- package/dist/lib/icon-set.d.ts +95 -0
- package/dist/lib/icon-set.js +97 -0
- package/dist/lib/icons.d.ts +12 -0
- package/dist/lib/icons.js +39 -0
- package/dist/lib/indicator.d.ts +6 -0
- package/dist/lib/indicator.js +18 -0
- package/dist/lib/keep-in-view.d.ts +5 -0
- package/dist/lib/keep-in-view.js +15 -0
- package/dist/lib/key-shortcut.d.ts +20 -0
- package/dist/lib/key-shortcut.js +100 -0
- package/dist/lib/keycaps.d.ts +8 -0
- package/dist/lib/keycaps.js +162 -0
- package/dist/lib/locale.d.ts +4 -0
- package/dist/lib/locale.js +13 -0
- package/dist/lib/nav-tree.d.ts +9 -0
- package/dist/lib/nav-tree.js +30 -0
- package/dist/lib/numeric.d.ts +20 -0
- package/dist/lib/numeric.js +50 -0
- package/dist/lib/option-filter.d.ts +29 -0
- package/dist/lib/option-filter.js +108 -0
- package/dist/lib/option-groups.d.ts +6 -0
- package/dist/lib/option-groups.js +26 -0
- package/dist/lib/options.d.ts +5 -0
- package/dist/lib/options.js +24 -0
- package/dist/lib/pagination.d.ts +9 -0
- package/dist/lib/pagination.js +52 -0
- package/dist/lib/palette.d.ts +8 -0
- package/dist/lib/palette.js +46 -0
- package/dist/lib/progress.d.ts +20 -0
- package/dist/lib/progress.js +33 -0
- package/dist/lib/rating.d.ts +7 -0
- package/dist/lib/rating.js +26 -0
- package/dist/lib/roving-index.d.ts +10 -0
- package/dist/lib/roving-index.js +32 -0
- package/dist/lib/roving.d.ts +11 -0
- package/dist/lib/roving.js +21 -0
- package/dist/lib/slots.d.ts +2 -0
- package/dist/lib/slots.js +6 -0
- package/dist/lib/sparkline.d.ts +11 -0
- package/dist/lib/sparkline.js +42 -0
- package/dist/lib/split.d.ts +12 -0
- package/dist/lib/split.js +37 -0
- package/dist/lib/surface.d.ts +7 -0
- package/dist/lib/surface.js +28 -0
- package/dist/lib/table.d.ts +30 -0
- package/dist/lib/table.js +110 -0
- package/dist/lib/tags.d.ts +14 -0
- package/dist/lib/tags.js +29 -0
- package/dist/lib/text.d.ts +5 -0
- package/dist/lib/text.js +13 -0
- package/dist/lib/tokens.d.ts +5 -0
- package/dist/lib/tokens.js +15 -0
- package/dist/lib/tree.d.ts +16 -0
- package/dist/lib/tree.js +89 -0
- package/dist/lib/trend.d.ts +3 -0
- package/dist/lib/trend.js +15 -0
- package/dist/lib/trigger.d.ts +11 -0
- package/dist/lib/trigger.js +34 -0
- package/dist/molecules/jl-accordion-item.css_raw.js +3 -0
- package/dist/molecules/jl-accordion-item.d.ts +34 -0
- package/dist/molecules/jl-accordion-item.js +82 -0
- package/dist/molecules/jl-accordion.css_raw.js +3 -0
- package/dist/molecules/jl-accordion.d.ts +27 -0
- package/dist/molecules/jl-accordion.js +61 -0
- package/dist/molecules/jl-alert.css_raw.js +3 -0
- package/dist/molecules/jl-alert.d.ts +38 -0
- package/dist/molecules/jl-alert.js +131 -0
- package/dist/molecules/jl-avatar-group.css_raw.js +3 -0
- package/dist/molecules/jl-avatar-group.d.ts +28 -0
- package/dist/molecules/jl-avatar-group.js +69 -0
- package/dist/molecules/jl-breadcrumb.css_raw.js +3 -0
- package/dist/molecules/jl-breadcrumb.d.ts +35 -0
- package/dist/molecules/jl-breadcrumb.js +126 -0
- package/dist/molecules/jl-calendar.css_raw.js +3 -0
- package/dist/molecules/jl-calendar.d.ts +101 -0
- package/dist/molecules/jl-calendar.js +314 -0
- package/dist/molecules/jl-card.css_raw.js +3 -0
- package/dist/molecules/jl-card.d.ts +46 -0
- package/dist/molecules/jl-card.js +172 -0
- package/dist/molecules/jl-code-block.css_raw.js +3 -0
- package/dist/molecules/jl-code-block.d.ts +44 -0
- package/dist/molecules/jl-code-block.js +106 -0
- package/dist/molecules/jl-combobox.css_raw.js +3 -0
- package/dist/molecules/jl-combobox.d.ts +120 -0
- package/dist/molecules/jl-combobox.js +450 -0
- package/dist/molecules/jl-copy-button.css_raw.js +3 -0
- package/dist/molecules/jl-copy-button.d.ts +31 -0
- package/dist/molecules/jl-copy-button.js +69 -0
- package/dist/molecules/jl-date-picker.css_raw.js +3 -0
- package/dist/molecules/jl-date-picker.d.ts +109 -0
- package/dist/molecules/jl-date-picker.js +322 -0
- package/dist/molecules/jl-empty.css_raw.js +3 -0
- package/dist/molecules/jl-empty.d.ts +32 -0
- package/dist/molecules/jl-empty.js +94 -0
- package/dist/molecules/jl-field.css_raw.js +3 -0
- package/dist/molecules/jl-field.d.ts +49 -0
- package/dist/molecules/jl-field.js +147 -0
- package/dist/molecules/jl-file-drop.css_raw.js +3 -0
- package/dist/molecules/jl-file-drop.d.ts +93 -0
- package/dist/molecules/jl-file-drop.js +366 -0
- package/dist/molecules/jl-list-item.css_raw.js +3 -0
- package/dist/molecules/jl-list-item.d.ts +56 -0
- package/dist/molecules/jl-list-item.js +176 -0
- package/dist/molecules/jl-menu.css_raw.js +3 -0
- package/dist/molecules/jl-menu.d.ts +62 -0
- package/dist/molecules/jl-menu.js +288 -0
- package/dist/molecules/jl-number-input.css_raw.js +3 -0
- package/dist/molecules/jl-number-input.d.ts +81 -0
- package/dist/molecules/jl-number-input.js +220 -0
- package/dist/molecules/jl-pagination.css_raw.js +3 -0
- package/dist/molecules/jl-pagination.d.ts +59 -0
- package/dist/molecules/jl-pagination.js +172 -0
- package/dist/molecules/jl-popover.css_raw.js +3 -0
- package/dist/molecules/jl-popover.d.ts +49 -0
- package/dist/molecules/jl-popover.js +152 -0
- package/dist/molecules/jl-radio-group.css_raw.js +3 -0
- package/dist/molecules/jl-radio-group.d.ts +71 -0
- package/dist/molecules/jl-radio-group.js +202 -0
- package/dist/molecules/jl-search.css_raw.js +3 -0
- package/dist/molecules/jl-search.d.ts +71 -0
- package/dist/molecules/jl-search.js +210 -0
- package/dist/molecules/jl-segmented.css_raw.js +3 -0
- package/dist/molecules/jl-segmented.d.ts +65 -0
- package/dist/molecules/jl-segmented.js +187 -0
- package/dist/molecules/jl-stat.css_raw.js +3 -0
- package/dist/molecules/jl-stat.d.ts +55 -0
- package/dist/molecules/jl-stat.js +169 -0
- package/dist/molecules/jl-steps.css_raw.js +3 -0
- package/dist/molecules/jl-steps.d.ts +44 -0
- package/dist/molecules/jl-steps.js +118 -0
- package/dist/molecules/jl-tab-panel.css_raw.js +3 -0
- package/dist/molecules/jl-tab-panel.d.ts +35 -0
- package/dist/molecules/jl-tab-panel.js +35 -0
- package/dist/molecules/jl-tabs.css_raw.js +3 -0
- package/dist/molecules/jl-tabs.d.ts +51 -0
- package/dist/molecules/jl-tabs.js +198 -0
- package/dist/molecules/jl-tag-input.css_raw.js +3 -0
- package/dist/molecules/jl-tag-input.d.ts +103 -0
- package/dist/molecules/jl-tag-input.js +429 -0
- package/dist/molecules/jl-timeline.css_raw.js +3 -0
- package/dist/molecules/jl-timeline.d.ts +28 -0
- package/dist/molecules/jl-timeline.js +81 -0
- package/dist/molecules/jl-toast.css_raw.js +3 -0
- package/dist/molecules/jl-toast.d.ts +75 -0
- package/dist/molecules/jl-toast.js +274 -0
- package/dist/molecules/jl-tooltip.css_raw.js +3 -0
- package/dist/molecules/jl-tooltip.d.ts +44 -0
- package/dist/molecules/jl-tooltip.js +160 -0
- package/dist/organisms/jl-command-palette.css_raw.js +3 -0
- package/dist/organisms/jl-command-palette.d.ts +60 -0
- package/dist/organisms/jl-command-palette.js +285 -0
- package/dist/organisms/jl-confirm.css_raw.js +3 -0
- package/dist/organisms/jl-confirm.d.ts +56 -0
- package/dist/organisms/jl-confirm.js +132 -0
- package/dist/organisms/jl-dialog.css_raw.js +3 -0
- package/dist/organisms/jl-dialog.d.ts +43 -0
- package/dist/organisms/jl-dialog.js +120 -0
- package/dist/organisms/jl-drawer.css_raw.js +3 -0
- package/dist/organisms/jl-drawer.d.ts +50 -0
- package/dist/organisms/jl-drawer.js +141 -0
- package/dist/organisms/jl-navbar.css_raw.js +3 -0
- package/dist/organisms/jl-navbar.d.ts +32 -0
- package/dist/organisms/jl-navbar.js +121 -0
- package/dist/organisms/jl-page-header.css_raw.js +3 -0
- package/dist/organisms/jl-page-header.d.ts +26 -0
- package/dist/organisms/jl-page-header.js +85 -0
- package/dist/organisms/jl-side-nav.css_raw.js +3 -0
- package/dist/organisms/jl-side-nav.d.ts +60 -0
- package/dist/organisms/jl-side-nav.js +269 -0
- package/dist/organisms/jl-table.css_raw.js +3 -0
- package/dist/organisms/jl-table.d.ts +109 -0
- package/dist/organisms/jl-table.js +318 -0
- package/dist/organisms/jl-toaster.css_raw.js +3 -0
- package/dist/organisms/jl-toaster.d.ts +48 -0
- package/dist/organisms/jl-toaster.js +142 -0
- package/dist/organisms/jl-tree.css_raw.js +3 -0
- package/dist/organisms/jl-tree.d.ts +59 -0
- package/dist/organisms/jl-tree.js +198 -0
- package/dist/styles/base.css_raw.js +3 -0
- package/dist/styles/control.css_raw.js +3 -0
- package/dist/styles/floating.css_raw.js +3 -0
- package/dist/styles/shared.d.ts +8 -0
- package/dist/styles/shared.js +14 -0
- package/dist/styles/tokens.css_raw.js +3 -0
- package/dist/templates/jl-app-shell.css_raw.js +3 -0
- package/dist/templates/jl-app-shell.d.ts +37 -0
- package/dist/templates/jl-app-shell.js +150 -0
- package/dist/templates/jl-split-view.css_raw.js +3 -0
- package/dist/templates/jl-split-view.d.ts +49 -0
- package/dist/templates/jl-split-view.js +149 -0
- package/dist/tokens.css +188 -0
- package/dist/types/calendar.types.d.ts +11 -0
- package/dist/types/files.types.d.ts +23 -0
- package/dist/types/floating.types.d.ts +13 -0
- package/dist/types/fuzzy.types.d.ts +10 -0
- package/dist/types/highlight.types.d.ts +6 -0
- package/dist/types/hotkey.types.d.ts +19 -0
- package/dist/types/jl-accordion.types.d.ts +2 -0
- package/dist/types/jl-avatar.types.d.ts +10 -0
- package/dist/types/jl-breadcrumb.types.d.ts +6 -0
- package/dist/types/jl-button.types.d.ts +3 -0
- package/dist/types/jl-card.types.d.ts +2 -0
- package/dist/types/jl-chip.types.d.ts +1 -0
- package/dist/types/jl-combobox.types.d.ts +8 -0
- package/dist/types/jl-command-palette.types.d.ts +22 -0
- package/dist/types/jl-confirm.types.d.ts +10 -0
- package/dist/types/jl-dialog.types.d.ts +1 -0
- package/dist/types/jl-divider.types.d.ts +2 -0
- package/dist/types/jl-drawer.types.d.ts +4 -0
- package/dist/types/jl-empty.types.d.ts +2 -0
- package/dist/types/jl-field.types.d.ts +2 -0
- package/dist/types/jl-input.types.d.ts +1 -0
- package/dist/types/jl-link.types.d.ts +2 -0
- package/dist/types/jl-menu.types.d.ts +22 -0
- package/dist/types/jl-navbar.types.d.ts +6 -0
- package/dist/types/jl-progress.types.d.ts +3 -0
- package/dist/types/jl-radio-group.types.d.ts +10 -0
- package/dist/types/jl-segmented.types.d.ts +7 -0
- package/dist/types/jl-select.types.d.ts +12 -0
- package/dist/types/jl-side-nav.types.d.ts +17 -0
- package/dist/types/jl-skeleton.types.d.ts +2 -0
- package/dist/types/jl-slider.types.d.ts +5 -0
- package/dist/types/jl-split-view.types.d.ts +2 -0
- package/dist/types/jl-stat.types.d.ts +2 -0
- package/dist/types/jl-steps.types.d.ts +8 -0
- package/dist/types/jl-switch.types.d.ts +1 -0
- package/dist/types/jl-table.types.d.ts +30 -0
- package/dist/types/jl-tabs.types.d.ts +2 -0
- package/dist/types/jl-timeline.types.d.ts +10 -0
- package/dist/types/jl-toast.types.d.ts +2 -0
- package/dist/types/jl-toaster.types.d.ts +23 -0
- package/dist/types/jl-tree.types.d.ts +26 -0
- package/dist/types/key-shortcut.types.d.ts +9 -0
- package/dist/types/keycaps.types.d.ts +7 -0
- package/dist/types/option-filter.types.d.ts +10 -0
- package/dist/types/options.types.d.ts +4 -0
- package/dist/types/pagination.types.d.ts +8 -0
- package/dist/types/roving-index.types.d.ts +2 -0
- package/dist/types/sparkline.types.d.ts +11 -0
- package/package.json +102 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { IconNode } from 'lucide';
|
|
2
|
+
/**
|
|
3
|
+
* The usual icons of an interface, by name: `registerIcons(COMMON_ICONS)` lets pages write any of them
|
|
4
|
+
* (`<jl-icon name="settings">`, `<jl-button icon="plus">`). It costs about 5 kB compressed; an app that names a few
|
|
5
|
+
* icons registers just those instead. `@syware/jlib/all` registers them all.
|
|
6
|
+
*/
|
|
7
|
+
export declare const COMMON_ICONS: {
|
|
8
|
+
'arrow-down': IconNode;
|
|
9
|
+
'arrow-left': IconNode;
|
|
10
|
+
'arrow-right': IconNode;
|
|
11
|
+
'arrow-up': IconNode;
|
|
12
|
+
'arrow-up-down': IconNode;
|
|
13
|
+
bell: IconNode;
|
|
14
|
+
bookmark: IconNode;
|
|
15
|
+
box: IconNode;
|
|
16
|
+
calendar: IconNode;
|
|
17
|
+
chart: IconNode;
|
|
18
|
+
check: IconNode;
|
|
19
|
+
'chevron-down': IconNode;
|
|
20
|
+
'chevron-left': IconNode;
|
|
21
|
+
'chevron-right': IconNode;
|
|
22
|
+
'chevron-up': IconNode;
|
|
23
|
+
'chevrons-left': IconNode;
|
|
24
|
+
'chevrons-right': IconNode;
|
|
25
|
+
'chevrons-up-down': IconNode;
|
|
26
|
+
'circle-alert': IconNode;
|
|
27
|
+
'circle-check': IconNode;
|
|
28
|
+
'circle-help': IconNode;
|
|
29
|
+
'circle-x': IconNode;
|
|
30
|
+
clock: IconNode;
|
|
31
|
+
code: IconNode;
|
|
32
|
+
command: IconNode;
|
|
33
|
+
copy: IconNode;
|
|
34
|
+
'corner-down-left': IconNode;
|
|
35
|
+
'credit-card': IconNode;
|
|
36
|
+
database: IconNode;
|
|
37
|
+
download: IconNode;
|
|
38
|
+
ellipsis: IconNode;
|
|
39
|
+
'ellipsis-vertical': IconNode;
|
|
40
|
+
'external-link': IconNode;
|
|
41
|
+
eye: IconNode;
|
|
42
|
+
'eye-off': IconNode;
|
|
43
|
+
file: IconNode;
|
|
44
|
+
'file-text': IconNode;
|
|
45
|
+
filter: IconNode;
|
|
46
|
+
folder: IconNode;
|
|
47
|
+
'folder-open': IconNode;
|
|
48
|
+
'git-branch': IconNode;
|
|
49
|
+
'git-merge': IconNode;
|
|
50
|
+
globe: IconNode;
|
|
51
|
+
grip: IconNode;
|
|
52
|
+
heart: IconNode;
|
|
53
|
+
house: IconNode;
|
|
54
|
+
image: IconNode;
|
|
55
|
+
inbox: IconNode;
|
|
56
|
+
info: IconNode;
|
|
57
|
+
layers: IconNode;
|
|
58
|
+
'layout-grid': IconNode;
|
|
59
|
+
link: IconNode;
|
|
60
|
+
list: IconNode;
|
|
61
|
+
loader: IconNode;
|
|
62
|
+
lock: IconNode;
|
|
63
|
+
'log-out': IconNode;
|
|
64
|
+
mail: IconNode;
|
|
65
|
+
menu: IconNode;
|
|
66
|
+
message: IconNode;
|
|
67
|
+
minus: IconNode;
|
|
68
|
+
monitor: IconNode;
|
|
69
|
+
moon: IconNode;
|
|
70
|
+
package: IconNode;
|
|
71
|
+
palette: IconNode;
|
|
72
|
+
'panel-left': IconNode;
|
|
73
|
+
pencil: IconNode;
|
|
74
|
+
plus: IconNode;
|
|
75
|
+
puzzle: IconNode;
|
|
76
|
+
refresh: IconNode;
|
|
77
|
+
rocket: IconNode;
|
|
78
|
+
search: IconNode;
|
|
79
|
+
settings: IconNode;
|
|
80
|
+
share: IconNode;
|
|
81
|
+
'shield-check': IconNode;
|
|
82
|
+
sparkles: IconNode;
|
|
83
|
+
star: IconNode;
|
|
84
|
+
sun: IconNode;
|
|
85
|
+
terminal: IconNode;
|
|
86
|
+
trash: IconNode;
|
|
87
|
+
'trending-down': IconNode;
|
|
88
|
+
'trending-up': IconNode;
|
|
89
|
+
'triangle-alert': IconNode;
|
|
90
|
+
upload: IconNode;
|
|
91
|
+
user: IconNode;
|
|
92
|
+
users: IconNode;
|
|
93
|
+
x: IconNode;
|
|
94
|
+
zap: IconNode;
|
|
95
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ArrowUpDown, Bell, Bookmark, Box, Calendar, ChartBar, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsLeft, ChevronsRight, ChevronsUpDown, CircleAlert, CircleCheck, CircleQuestionMark, CircleX, Clock, Code, Command, Copy, CornerDownLeft, CreditCard, Database, Download, Ellipsis, EllipsisVertical, ExternalLink, Eye, EyeOff, File, FileText, Folder, FolderOpen, Funnel, GitBranch, GitMerge, Globe, GripVertical, Heart, House, Image, Inbox, Info, Layers, LayoutGrid, Link, List, LoaderCircle, Lock, LogOut, Mail, Menu, MessageSquare, Minus, Monitor, Moon, Package, Palette, PanelLeft, Pencil, Plus, Puzzle, RefreshCw, Rocket, Search, Settings, Share2, ShieldCheck, Sparkles, Star, Sun, Terminal, Trash, TrendingDown, TrendingUp, TriangleAlert, Upload, User, Users, X, Zap } from "lucide";
|
|
2
|
+
// src/lib/icon-set.ts
|
|
3
|
+
/**
|
|
4
|
+
* The usual icons of an interface, by name: `registerIcons(COMMON_ICONS)` lets pages write any of them
|
|
5
|
+
* (`<jl-icon name="settings">`, `<jl-button icon="plus">`). It costs about 5 kB compressed; an app that names a few
|
|
6
|
+
* icons registers just those instead. `@syware/jlib/all` registers them all.
|
|
7
|
+
*/
|
|
8
|
+
var COMMON_ICONS = {
|
|
9
|
+
"arrow-down": ArrowDown,
|
|
10
|
+
"arrow-left": ArrowLeft,
|
|
11
|
+
"arrow-right": ArrowRight,
|
|
12
|
+
"arrow-up": ArrowUp,
|
|
13
|
+
"arrow-up-down": ArrowUpDown,
|
|
14
|
+
bell: Bell,
|
|
15
|
+
bookmark: Bookmark,
|
|
16
|
+
box: Box,
|
|
17
|
+
calendar: Calendar,
|
|
18
|
+
chart: ChartBar,
|
|
19
|
+
check: Check,
|
|
20
|
+
"chevron-down": ChevronDown,
|
|
21
|
+
"chevron-left": ChevronLeft,
|
|
22
|
+
"chevron-right": ChevronRight,
|
|
23
|
+
"chevron-up": ChevronUp,
|
|
24
|
+
"chevrons-left": ChevronsLeft,
|
|
25
|
+
"chevrons-right": ChevronsRight,
|
|
26
|
+
"chevrons-up-down": ChevronsUpDown,
|
|
27
|
+
"circle-alert": CircleAlert,
|
|
28
|
+
"circle-check": CircleCheck,
|
|
29
|
+
"circle-help": CircleQuestionMark,
|
|
30
|
+
"circle-x": CircleX,
|
|
31
|
+
clock: Clock,
|
|
32
|
+
code: Code,
|
|
33
|
+
command: Command,
|
|
34
|
+
copy: Copy,
|
|
35
|
+
"corner-down-left": CornerDownLeft,
|
|
36
|
+
"credit-card": CreditCard,
|
|
37
|
+
database: Database,
|
|
38
|
+
download: Download,
|
|
39
|
+
ellipsis: Ellipsis,
|
|
40
|
+
"ellipsis-vertical": EllipsisVertical,
|
|
41
|
+
"external-link": ExternalLink,
|
|
42
|
+
eye: Eye,
|
|
43
|
+
"eye-off": EyeOff,
|
|
44
|
+
file: File,
|
|
45
|
+
"file-text": FileText,
|
|
46
|
+
filter: Funnel,
|
|
47
|
+
folder: Folder,
|
|
48
|
+
"folder-open": FolderOpen,
|
|
49
|
+
"git-branch": GitBranch,
|
|
50
|
+
"git-merge": GitMerge,
|
|
51
|
+
globe: Globe,
|
|
52
|
+
grip: GripVertical,
|
|
53
|
+
heart: Heart,
|
|
54
|
+
house: House,
|
|
55
|
+
image: Image,
|
|
56
|
+
inbox: Inbox,
|
|
57
|
+
info: Info,
|
|
58
|
+
layers: Layers,
|
|
59
|
+
"layout-grid": LayoutGrid,
|
|
60
|
+
link: Link,
|
|
61
|
+
list: List,
|
|
62
|
+
loader: LoaderCircle,
|
|
63
|
+
lock: Lock,
|
|
64
|
+
"log-out": LogOut,
|
|
65
|
+
mail: Mail,
|
|
66
|
+
menu: Menu,
|
|
67
|
+
message: MessageSquare,
|
|
68
|
+
minus: Minus,
|
|
69
|
+
monitor: Monitor,
|
|
70
|
+
moon: Moon,
|
|
71
|
+
package: Package,
|
|
72
|
+
palette: Palette,
|
|
73
|
+
"panel-left": PanelLeft,
|
|
74
|
+
pencil: Pencil,
|
|
75
|
+
plus: Plus,
|
|
76
|
+
puzzle: Puzzle,
|
|
77
|
+
refresh: RefreshCw,
|
|
78
|
+
rocket: Rocket,
|
|
79
|
+
search: Search,
|
|
80
|
+
settings: Settings,
|
|
81
|
+
share: Share2,
|
|
82
|
+
"shield-check": ShieldCheck,
|
|
83
|
+
sparkles: Sparkles,
|
|
84
|
+
star: Star,
|
|
85
|
+
sun: Sun,
|
|
86
|
+
terminal: Terminal,
|
|
87
|
+
trash: Trash,
|
|
88
|
+
"trending-down": TrendingDown,
|
|
89
|
+
"trending-up": TrendingUp,
|
|
90
|
+
"triangle-alert": TriangleAlert,
|
|
91
|
+
upload: Upload,
|
|
92
|
+
user: User,
|
|
93
|
+
users: Users,
|
|
94
|
+
x: X,
|
|
95
|
+
zap: Zap
|
|
96
|
+
};
|
|
97
|
+
export { COMMON_ICONS };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IconNode } from 'lucide';
|
|
2
|
+
/**
|
|
3
|
+
* Adds icons to the ones `jl-icon` knows, by name. Any lucide icon works:
|
|
4
|
+
* `registerIcons({ rocket: Rocket })` after `import { Rocket } from 'lucide'`, or all the usual ones at once with
|
|
5
|
+
* `registerIcons(COMMON_ICONS)`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerIcons(icons: Record<string, IconNode>): void;
|
|
8
|
+
/** The names `jl-icon` can draw now, in alphabetical order. */
|
|
9
|
+
export declare const iconNames: () => string[];
|
|
10
|
+
export declare const hasIcon: (name: string) => boolean;
|
|
11
|
+
/** An icon as an SVG element; a name nobody registered draws a neutral mark instead of nothing. */
|
|
12
|
+
export declare function iconElement(name: string, size: number): SVGElement;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CircleAlert, createElement } from "lucide";
|
|
2
|
+
// src/lib/icons.ts
|
|
3
|
+
var FALLBACK = CircleAlert;
|
|
4
|
+
var STROKE_WIDTH = 1.9;
|
|
5
|
+
/**
|
|
6
|
+
* The icons `jl-icon` can draw, by name. It starts empty: each component registers the icons it draws itself, and
|
|
7
|
+
* a page registers the names it writes, so a bundle holds only the icons in use.
|
|
8
|
+
*/
|
|
9
|
+
var registry = /* @__PURE__ */ new Map();
|
|
10
|
+
var warned = /* @__PURE__ */ new Set();
|
|
11
|
+
/**
|
|
12
|
+
* Adds icons to the ones `jl-icon` knows, by name. Any lucide icon works:
|
|
13
|
+
* `registerIcons({ rocket: Rocket })` after `import { Rocket } from 'lucide'`, or all the usual ones at once with
|
|
14
|
+
* `registerIcons(COMMON_ICONS)`.
|
|
15
|
+
*/
|
|
16
|
+
function registerIcons(icons) {
|
|
17
|
+
for (const [name, node] of Object.entries(icons)) registry.set(name, node);
|
|
18
|
+
}
|
|
19
|
+
/** The names `jl-icon` can draw now, in alphabetical order. */
|
|
20
|
+
var iconNames = () => [...registry.keys()].sort();
|
|
21
|
+
var hasIcon = (name) => registry.has(name);
|
|
22
|
+
/** The fallback for a name nobody registered, with a warning once per name to say how to fix it. */
|
|
23
|
+
function missing(name) {
|
|
24
|
+
if (!warned.has(name)) {
|
|
25
|
+
warned.add(name);
|
|
26
|
+
console.warn(`jl-icon: no icon named "${name}". Register it: registerIcons({ '${name}': … }) with an icon from lucide, or registerIcons(COMMON_ICONS).`);
|
|
27
|
+
}
|
|
28
|
+
return FALLBACK;
|
|
29
|
+
}
|
|
30
|
+
/** An icon as an SVG element; a name nobody registered draws a neutral mark instead of nothing. */
|
|
31
|
+
function iconElement(name, size) {
|
|
32
|
+
return createElement(registry.get(name) ?? missing(name), {
|
|
33
|
+
"aria-hidden": "true",
|
|
34
|
+
height: size,
|
|
35
|
+
"stroke-width": STROKE_WIDTH,
|
|
36
|
+
width: size
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export { hasIcon, iconElement, iconNames, registerIcons };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts a sliding indicator (the underline of a tab, the thumb of a segmented control) over the chosen element:
|
|
3
|
+
* its offset and size become `--x`, `--y`, `--w` and `--h`, which the component's styles use. The indicator gets
|
|
4
|
+
* `data-placed` once it has a first position, so the styles can animate its later moves only.
|
|
5
|
+
*/
|
|
6
|
+
export declare function moveIndicator(indicator: HTMLElement, target: HTMLElement | null): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/lib/indicator.ts
|
|
2
|
+
/**
|
|
3
|
+
* Puts a sliding indicator (the underline of a tab, the thumb of a segmented control) over the chosen element:
|
|
4
|
+
* its offset and size become `--x`, `--y`, `--w` and `--h`, which the component's styles use. The indicator gets
|
|
5
|
+
* `data-placed` once it has a first position, so the styles can animate its later moves only.
|
|
6
|
+
*/
|
|
7
|
+
function moveIndicator(indicator, target) {
|
|
8
|
+
indicator.hidden = target === null;
|
|
9
|
+
if (target === null) return;
|
|
10
|
+
indicator.style.setProperty("--x", `${target.offsetLeft}px`);
|
|
11
|
+
indicator.style.setProperty("--y", `${target.offsetTop}px`);
|
|
12
|
+
indicator.style.setProperty("--w", `${target.offsetWidth}px`);
|
|
13
|
+
indicator.style.setProperty("--h", `${target.offsetHeight}px`);
|
|
14
|
+
if (target.offsetWidth > 0 && indicator.dataset.placed === void 0) requestAnimationFrame(() => {
|
|
15
|
+
indicator.dataset.placed = "";
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { moveIndicator };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/lib/keep-in-view.ts
|
|
2
|
+
/**
|
|
3
|
+
* Scrolls a list just enough to show one of its items, without scrolling the page as `scrollIntoView` may. The
|
|
4
|
+
* list must be the item's offset parent (`position: relative`).
|
|
5
|
+
*/
|
|
6
|
+
function keepInView(list, item) {
|
|
7
|
+
const top = item.offsetTop;
|
|
8
|
+
const bottom = top + item.offsetHeight;
|
|
9
|
+
if (top < list.scrollTop) {
|
|
10
|
+
list.scrollTop = top;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (bottom > list.scrollTop + list.clientHeight) list.scrollTop = bottom - list.clientHeight;
|
|
14
|
+
}
|
|
15
|
+
export { keepInView };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KeyShortcut } from '../types/key-shortcut.types';
|
|
2
|
+
/** The keys a shortcut's state must match, from the pressed key's modifiers. */
|
|
3
|
+
type PressedKey = Pick<KeyboardEvent, 'key' | 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey'>;
|
|
4
|
+
/**
|
|
5
|
+
* A shortcut from text such as "/", "mod+k" or "ctrl+shift+p". Returns null for empty text or a shortcut without
|
|
6
|
+
* a key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseShortcut(text: string): KeyShortcut | null;
|
|
9
|
+
/** Whether the shortcut asks for a modifier other than Shift: such a shortcut is not typing. */
|
|
10
|
+
export declare const hasCommandModifier: (shortcut: KeyShortcut) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether a key press is the shortcut. `mod` is ⌘ on a Mac and Ctrl elsewhere. Shift is only compared when the
|
|
13
|
+
* shortcut has another modifier or names it: "/" needs Shift on some keyboards, and the key already says "/".
|
|
14
|
+
*/
|
|
15
|
+
export declare function matchesShortcut(event: PressedKey, shortcut: KeyShortcut, mac: boolean): boolean;
|
|
16
|
+
/** The keys to draw for a shortcut, one label per key: ["⌘", "K"] on a Mac, ["Ctrl", "K"] elsewhere. */
|
|
17
|
+
export declare function shortcutLabels(shortcut: KeyShortcut, mac: boolean): string[];
|
|
18
|
+
/** The shortcut as `aria-keyshortcuts` writes it: "Control+K", "/". */
|
|
19
|
+
export declare function shortcutAria(shortcut: KeyShortcut, mac: boolean): string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// src/lib/key-shortcut.ts
|
|
2
|
+
/** The words a shortcut may use for each modifier: "mod+k", "cmd+shift+p", "ctrl+/". */
|
|
3
|
+
var MODIFIER_WORDS = {
|
|
4
|
+
alt: "alt",
|
|
5
|
+
cmd: "meta",
|
|
6
|
+
command: "meta",
|
|
7
|
+
control: "ctrl",
|
|
8
|
+
ctrl: "ctrl",
|
|
9
|
+
meta: "meta",
|
|
10
|
+
mod: "mod",
|
|
11
|
+
option: "alt",
|
|
12
|
+
shift: "shift"
|
|
13
|
+
};
|
|
14
|
+
var SEPARATOR = "+";
|
|
15
|
+
var isModifierWord = (word) => Object.hasOwn(MODIFIER_WORDS, word);
|
|
16
|
+
var MAC_SYMBOLS = {
|
|
17
|
+
alt: "⌥",
|
|
18
|
+
ctrl: "⌃",
|
|
19
|
+
meta: "⌘",
|
|
20
|
+
mod: "⌘",
|
|
21
|
+
shift: "⇧"
|
|
22
|
+
};
|
|
23
|
+
var PC_NAMES = {
|
|
24
|
+
alt: "Alt",
|
|
25
|
+
ctrl: "Ctrl",
|
|
26
|
+
meta: "Meta",
|
|
27
|
+
mod: "Ctrl",
|
|
28
|
+
shift: "Shift"
|
|
29
|
+
};
|
|
30
|
+
var ARIA_NAMES = {
|
|
31
|
+
alt: "Alt",
|
|
32
|
+
ctrl: "Control",
|
|
33
|
+
meta: "Meta",
|
|
34
|
+
mod: "Control",
|
|
35
|
+
shift: "Shift"
|
|
36
|
+
};
|
|
37
|
+
var MODIFIER_ORDER = [
|
|
38
|
+
"ctrl",
|
|
39
|
+
"alt",
|
|
40
|
+
"shift",
|
|
41
|
+
"mod",
|
|
42
|
+
"meta"
|
|
43
|
+
];
|
|
44
|
+
/** Names of keys that read better than their `KeyboardEvent.key`. */
|
|
45
|
+
var KEY_LABELS = {
|
|
46
|
+
" ": "Space",
|
|
47
|
+
arrowdown: "↓",
|
|
48
|
+
arrowleft: "←",
|
|
49
|
+
arrowright: "→",
|
|
50
|
+
arrowup: "↑",
|
|
51
|
+
enter: "↵",
|
|
52
|
+
escape: "Esc"
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A shortcut from text such as "/", "mod+k" or "ctrl+shift+p". Returns null for empty text or a shortcut without
|
|
56
|
+
* a key.
|
|
57
|
+
*/
|
|
58
|
+
function parseShortcut(text) {
|
|
59
|
+
const parts = text.trim().toLowerCase().split(SEPARATOR).map((part) => part.trim());
|
|
60
|
+
const key = parts.at(-1) ?? "";
|
|
61
|
+
if (key === "" || isModifierWord(key)) return null;
|
|
62
|
+
const modifiers = new Set(parts.slice(0, -1).filter(isModifierWord).map((part) => MODIFIER_WORDS[part]));
|
|
63
|
+
return {
|
|
64
|
+
alt: modifiers.has("alt"),
|
|
65
|
+
ctrl: modifiers.has("ctrl"),
|
|
66
|
+
key,
|
|
67
|
+
meta: modifiers.has("meta"),
|
|
68
|
+
mod: modifiers.has("mod"),
|
|
69
|
+
shift: modifiers.has("shift")
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Whether the shortcut asks for a modifier other than Shift: such a shortcut is not typing. */
|
|
73
|
+
var hasCommandModifier = (shortcut) => shortcut.mod || shortcut.ctrl || shortcut.meta || shortcut.alt;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a key press is the shortcut. `mod` is ⌘ on a Mac and Ctrl elsewhere. Shift is only compared when the
|
|
76
|
+
* shortcut has another modifier or names it: "/" needs Shift on some keyboards, and the key already says "/".
|
|
77
|
+
*/
|
|
78
|
+
function matchesShortcut(event, shortcut, mac) {
|
|
79
|
+
const wantsCtrl = shortcut.ctrl || shortcut.mod && !mac;
|
|
80
|
+
const wantsMeta = shortcut.meta || shortcut.mod && mac;
|
|
81
|
+
const shiftMatters = shortcut.shift || hasCommandModifier(shortcut);
|
|
82
|
+
return event.key.toLowerCase() === shortcut.key && event.ctrlKey === wantsCtrl && event.metaKey === wantsMeta && event.altKey === shortcut.alt && (!shiftMatters || event.shiftKey === shortcut.shift);
|
|
83
|
+
}
|
|
84
|
+
var activeModifiers = (shortcut) => MODIFIER_ORDER.filter((modifier) => shortcut[modifier]);
|
|
85
|
+
var keyLabel = (key) => KEY_LABELS[key] ?? (key.length === 1 ? key.toUpperCase() : key);
|
|
86
|
+
/** The keys to draw for a shortcut, one label per key: ["⌘", "K"] on a Mac, ["Ctrl", "K"] elsewhere. */
|
|
87
|
+
function shortcutLabels(shortcut, mac) {
|
|
88
|
+
const names = mac ? MAC_SYMBOLS : PC_NAMES;
|
|
89
|
+
return [...activeModifiers(shortcut).map((modifier) => names[modifier]), keyLabel(shortcut.key)];
|
|
90
|
+
}
|
|
91
|
+
/** The shortcut as `aria-keyshortcuts` writes it: "Control+K", "/". */
|
|
92
|
+
function shortcutAria(shortcut, mac) {
|
|
93
|
+
const names = {
|
|
94
|
+
...ARIA_NAMES,
|
|
95
|
+
mod: mac ? "Meta" : "Control"
|
|
96
|
+
};
|
|
97
|
+
const key = shortcut.key.length === 1 ? shortcut.key.toUpperCase() : shortcut.key;
|
|
98
|
+
return [...activeModifiers(shortcut).map((modifier) => names[modifier]), key].join(SEPARATOR);
|
|
99
|
+
}
|
|
100
|
+
export { hasCommandModifier, matchesShortcut, parseShortcut, shortcutAria, shortcutLabels };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Keycap, KeyPlatform } from '../types/keycaps.types';
|
|
2
|
+
/**
|
|
3
|
+
* The keycaps of a shortcut written as "mod+shift+k", in its order: ⌘ ⇧ K on Apple platforms, Ctrl Shift K
|
|
4
|
+
* elsewhere. `mod` is the command key of the platform.
|
|
5
|
+
*/
|
|
6
|
+
export declare function keycapsOf(keys: string, platform: KeyPlatform): Keycap[];
|
|
7
|
+
/** A shortcut as a screen reader should say it: "Command+Shift+K". */
|
|
8
|
+
export declare const spokenKeys: (keycaps: readonly Keycap[]) => string;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// src/lib/keycaps.ts
|
|
2
|
+
var same = (label, name) => ({
|
|
3
|
+
apple: {
|
|
4
|
+
label,
|
|
5
|
+
name
|
|
6
|
+
},
|
|
7
|
+
other: {
|
|
8
|
+
label,
|
|
9
|
+
name
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
/** The keys drawn differently from their name, by canonical name. */
|
|
13
|
+
var NAMED_KEYS = {
|
|
14
|
+
alt: {
|
|
15
|
+
apple: {
|
|
16
|
+
label: "⌥",
|
|
17
|
+
name: "Option"
|
|
18
|
+
},
|
|
19
|
+
other: {
|
|
20
|
+
label: "Alt",
|
|
21
|
+
name: "Alt"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
backspace: {
|
|
25
|
+
apple: {
|
|
26
|
+
label: "⌫",
|
|
27
|
+
name: "Delete"
|
|
28
|
+
},
|
|
29
|
+
other: {
|
|
30
|
+
label: "Backspace",
|
|
31
|
+
name: "Backspace"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
capslock: {
|
|
35
|
+
apple: {
|
|
36
|
+
label: "⇪",
|
|
37
|
+
name: "Caps Lock"
|
|
38
|
+
},
|
|
39
|
+
other: {
|
|
40
|
+
label: "Caps",
|
|
41
|
+
name: "Caps Lock"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
cmd: {
|
|
45
|
+
apple: {
|
|
46
|
+
label: "⌘",
|
|
47
|
+
name: "Command"
|
|
48
|
+
},
|
|
49
|
+
other: {
|
|
50
|
+
label: "Win",
|
|
51
|
+
name: "Windows"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
ctrl: {
|
|
55
|
+
apple: {
|
|
56
|
+
label: "⌃",
|
|
57
|
+
name: "Control"
|
|
58
|
+
},
|
|
59
|
+
other: {
|
|
60
|
+
label: "Ctrl",
|
|
61
|
+
name: "Control"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
delete: {
|
|
65
|
+
apple: {
|
|
66
|
+
label: "⌦",
|
|
67
|
+
name: "Forward Delete"
|
|
68
|
+
},
|
|
69
|
+
other: {
|
|
70
|
+
label: "Del",
|
|
71
|
+
name: "Delete"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
down: same("↓", "Down Arrow"),
|
|
75
|
+
end: same("End", "End"),
|
|
76
|
+
enter: {
|
|
77
|
+
apple: {
|
|
78
|
+
label: "↩",
|
|
79
|
+
name: "Return"
|
|
80
|
+
},
|
|
81
|
+
other: {
|
|
82
|
+
label: "Enter",
|
|
83
|
+
name: "Enter"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
esc: same("Esc", "Escape"),
|
|
87
|
+
home: same("Home", "Home"),
|
|
88
|
+
left: same("←", "Left Arrow"),
|
|
89
|
+
mod: {
|
|
90
|
+
apple: {
|
|
91
|
+
label: "⌘",
|
|
92
|
+
name: "Command"
|
|
93
|
+
},
|
|
94
|
+
other: {
|
|
95
|
+
label: "Ctrl",
|
|
96
|
+
name: "Control"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
pagedown: same("PgDn", "Page Down"),
|
|
100
|
+
pageup: same("PgUp", "Page Up"),
|
|
101
|
+
right: same("→", "Right Arrow"),
|
|
102
|
+
shift: {
|
|
103
|
+
apple: {
|
|
104
|
+
label: "⇧",
|
|
105
|
+
name: "Shift"
|
|
106
|
+
},
|
|
107
|
+
other: {
|
|
108
|
+
label: "Shift",
|
|
109
|
+
name: "Shift"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
space: same("Space", "Space"),
|
|
113
|
+
tab: {
|
|
114
|
+
apple: {
|
|
115
|
+
label: "⇥",
|
|
116
|
+
name: "Tab"
|
|
117
|
+
},
|
|
118
|
+
other: {
|
|
119
|
+
label: "Tab",
|
|
120
|
+
name: "Tab"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
up: same("↑", "Up Arrow")
|
|
124
|
+
};
|
|
125
|
+
/** Other words for the same keys, as `KeyboardEvent.key` and people write them. */
|
|
126
|
+
var ALIASES = {
|
|
127
|
+
arrowdown: "down",
|
|
128
|
+
arrowleft: "left",
|
|
129
|
+
arrowright: "right",
|
|
130
|
+
arrowup: "up",
|
|
131
|
+
command: "cmd",
|
|
132
|
+
control: "ctrl",
|
|
133
|
+
del: "delete",
|
|
134
|
+
escape: "esc",
|
|
135
|
+
meta: "cmd",
|
|
136
|
+
opt: "alt",
|
|
137
|
+
option: "alt",
|
|
138
|
+
return: "enter"
|
|
139
|
+
};
|
|
140
|
+
var KEY_SEPARATOR = /\+(?=.)/;
|
|
141
|
+
var SPOKEN_SEPARATOR = "+";
|
|
142
|
+
var capitalize = (word) => word.charAt(0).toLocaleUpperCase() + word.slice(1);
|
|
143
|
+
function keycapOf(key, platform) {
|
|
144
|
+
const word = key.toLowerCase();
|
|
145
|
+
const named = NAMED_KEYS[ALIASES[word] ?? word];
|
|
146
|
+
if (named !== void 0) return named[platform];
|
|
147
|
+
const label = capitalize(key);
|
|
148
|
+
return {
|
|
149
|
+
label,
|
|
150
|
+
name: label
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The keycaps of a shortcut written as "mod+shift+k", in its order: ⌘ ⇧ K on Apple platforms, Ctrl Shift K
|
|
155
|
+
* elsewhere. `mod` is the command key of the platform.
|
|
156
|
+
*/
|
|
157
|
+
function keycapsOf(keys, platform) {
|
|
158
|
+
return keys.split(KEY_SEPARATOR).map((key) => key.trim()).filter((key) => key !== "").map((key) => keycapOf(key, platform));
|
|
159
|
+
}
|
|
160
|
+
/** A shortcut as a screen reader should say it: "Command+Shift+K". */
|
|
161
|
+
var spokenKeys = (keycaps) => keycaps.map((keycap) => keycap.name).join(SPOKEN_SEPARATOR);
|
|
162
|
+
export { keycapsOf, spokenKeys };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A locale Intl accepts, in its canonical form; undefined (the runtime's own) for an empty or malformed one. */
|
|
2
|
+
export declare function safeLocale(locale: string): string | undefined;
|
|
3
|
+
/** The locale to write dates and numbers in: the one asked for, else the page's language, else the runtime's. */
|
|
4
|
+
export declare const pageLocale: (preferred?: string) => string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/locale.ts
|
|
2
|
+
/** A locale Intl accepts, in its canonical form; undefined (the runtime's own) for an empty or malformed one. */
|
|
3
|
+
function safeLocale(locale) {
|
|
4
|
+
if (locale.trim() === "") return;
|
|
5
|
+
try {
|
|
6
|
+
return Intl.getCanonicalLocales(locale)[0];
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** The locale to write dates and numbers in: the one asked for, else the page's language, else the runtime's. */
|
|
12
|
+
var pageLocale = (preferred = "") => safeLocale(preferred) ?? safeLocale(document.documentElement.lang);
|
|
13
|
+
export { pageLocale, safeLocale };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SideNavItem, SideNavSection } from '../types/jl-side-nav.types';
|
|
2
|
+
/** The ids from the top of the tree down to the item, the item included; empty when no item has that id. */
|
|
3
|
+
export declare function pathTo(items: readonly SideNavItem[], id: string): string[];
|
|
4
|
+
/** The path to an item, looked for in every section. */
|
|
5
|
+
export declare const pathInSections: (sections: readonly SideNavSection[], id: string) => string[];
|
|
6
|
+
/** The item itself when it has no children, otherwise its first leaf: where a parent leads in the icon rail. */
|
|
7
|
+
export declare function firstLeaf(item: SideNavItem): SideNavItem;
|
|
8
|
+
/** Finds an item by id anywhere in the sections. */
|
|
9
|
+
export declare function findItem(sections: readonly SideNavSection[], id: string): SideNavItem | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/lib/nav-tree.ts
|
|
2
|
+
var hasChildren = (item) => (item.children?.length ?? 0) > 0;
|
|
3
|
+
/** The ids from the top of the tree down to the item, the item included; empty when no item has that id. */
|
|
4
|
+
function pathTo(items, id) {
|
|
5
|
+
for (const item of items) {
|
|
6
|
+
if (item.id === id) return [item.id];
|
|
7
|
+
const below = pathTo(item.children ?? [], id);
|
|
8
|
+
if (below.length > 0) return [item.id, ...below];
|
|
9
|
+
}
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
/** The path to an item, looked for in every section. */
|
|
13
|
+
var pathInSections = (sections, id) => pathTo(sections.flatMap((section) => section.items), id);
|
|
14
|
+
/** The item itself when it has no children, otherwise its first leaf: where a parent leads in the icon rail. */
|
|
15
|
+
function firstLeaf(item) {
|
|
16
|
+
const first = item.children?.[0];
|
|
17
|
+
return hasChildren(item) && first !== void 0 ? firstLeaf(first) : item;
|
|
18
|
+
}
|
|
19
|
+
/** Finds an item by id anywhere in the sections. */
|
|
20
|
+
function findItem(sections, id) {
|
|
21
|
+
const search = (items) => {
|
|
22
|
+
for (const item of items) {
|
|
23
|
+
const found = item.id === id ? item : search(item.children ?? []);
|
|
24
|
+
if (found !== null) return found;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
return search(sections.flatMap((section) => section.items));
|
|
29
|
+
}
|
|
30
|
+
export { findItem, firstLeaf, pathInSections, pathTo };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SliderMark } from '../types/jl-slider.types';
|
|
2
|
+
/** A number written in a field or an attribute; empty or unreadable text gives null. */
|
|
3
|
+
export declare function parseNumber(text: string | null): number | null;
|
|
4
|
+
/** A number kept within bounds; a null bound does not limit that side. */
|
|
5
|
+
export declare function clamp(value: number, min: number | null, max: number | null): number;
|
|
6
|
+
/** How many decimals a number has as written: 0.25 has 2, so sums of steps print without float noise. */
|
|
7
|
+
export declare function decimalsOf(value: number): number;
|
|
8
|
+
export declare function roundTo(value: number, decimals: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* The value one step up or down, within bounds, rounded to the decimals of the step and the value. An empty value
|
|
11
|
+
* counts as zero.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stepValue(value: number | null, step: number, direction: 1 | -1, min: number | null, max: number | null): number;
|
|
14
|
+
/** Where a value sits between min and max, from 0 to 1; an empty range gives 0. */
|
|
15
|
+
export declare function fractionOf(value: number, min: number, max: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* The marks of a slider from what a page wrote: numbers (`[0, 50, 100]`) or objects with a label
|
|
18
|
+
* (`[{ "value": 0, "label": "Off" }]`). Marks outside the range and unreadable entries are left out.
|
|
19
|
+
*/
|
|
20
|
+
export declare function marksOf(raw: unknown, min: number, max: number): SliderMark[];
|