@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { TOKEN_STYLES } from "./styles/shared.js";
|
|
2
|
+
import { adoptTokens } from "./lib/tokens.js";
|
|
3
|
+
import { JlElement } from "./base/jl-element.js";
|
|
4
|
+
import { JlFormControl } from "./base/jl-form-control.js";
|
|
5
|
+
import { clampedNumber, jsonOf, oneOf } from "./lib/attributes.js";
|
|
6
|
+
import { define } from "./lib/define.js";
|
|
7
|
+
import { PLACEMENTS, computePosition, followAnchor, placeFloating } from "./lib/floating.js";
|
|
8
|
+
import { COMMON_ICONS } from "./lib/icon-set.js";
|
|
9
|
+
import { hasIcon, iconElement, iconNames, registerIcons } from "./lib/icons.js";
|
|
10
|
+
import { CONTROL_SIZES, TONES, TONE_ICONS } from "./lib/options.js";
|
|
11
|
+
import { JlIcon } from "./atoms/jl-icon.js";
|
|
12
|
+
import { AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, JlAvatar } from "./atoms/jl-avatar.js";
|
|
13
|
+
import { JlBadge } from "./atoms/jl-badge.js";
|
|
14
|
+
import { JlSpinner } from "./atoms/jl-spinner.js";
|
|
15
|
+
import { BUTTON_TYPES, BUTTON_VARIANTS, JlButton } from "./atoms/jl-button.js";
|
|
16
|
+
import { JlCheckbox } from "./atoms/jl-checkbox.js";
|
|
17
|
+
import { CHIP_SIZES, JlChip } from "./atoms/jl-chip.js";
|
|
18
|
+
import { DIVIDER_ALIGNS, JlDivider } from "./atoms/jl-divider.js";
|
|
19
|
+
import { INPUT_TYPES, JlInput } from "./atoms/jl-input.js";
|
|
20
|
+
import { JlKbd } from "./atoms/jl-kbd.js";
|
|
21
|
+
import { JlLink, LINK_VARIANTS } from "./atoms/jl-link.js";
|
|
22
|
+
import { JlProgress, PROGRESS_SIZES, PROGRESS_TONES } from "./atoms/jl-progress.js";
|
|
23
|
+
import { JlProgressRing } from "./atoms/jl-progress-ring.js";
|
|
24
|
+
import { JlRating } from "./atoms/jl-rating.js";
|
|
25
|
+
import { JlSelect } from "./atoms/jl-select.js";
|
|
26
|
+
import { JlSkeleton, SKELETON_SHAPES } from "./atoms/jl-skeleton.js";
|
|
27
|
+
import { JlSlider } from "./atoms/jl-slider.js";
|
|
28
|
+
import { JlSwitch, SWITCH_SIZES } from "./atoms/jl-switch.js";
|
|
29
|
+
import { JlTextarea } from "./atoms/jl-textarea.js";
|
|
30
|
+
import { JlAccordionItem } from "./molecules/jl-accordion-item.js";
|
|
31
|
+
import { ACCORDION_VARIANTS, JlAccordion } from "./molecules/jl-accordion.js";
|
|
32
|
+
import { JlAlert } from "./molecules/jl-alert.js";
|
|
33
|
+
import { JlAvatarGroup } from "./molecules/jl-avatar-group.js";
|
|
34
|
+
import { JlBreadcrumb } from "./molecules/jl-breadcrumb.js";
|
|
35
|
+
import { JlCalendar } from "./molecules/jl-calendar.js";
|
|
36
|
+
import { CARD_PADDINGS, JlCard } from "./molecules/jl-card.js";
|
|
37
|
+
import { JlCopyButton } from "./molecules/jl-copy-button.js";
|
|
38
|
+
import { CODE_LANGUAGES, JlCodeBlock } from "./molecules/jl-code-block.js";
|
|
39
|
+
import { JlCombobox } from "./molecules/jl-combobox.js";
|
|
40
|
+
import { JlDatePicker } from "./molecules/jl-date-picker.js";
|
|
41
|
+
import { EMPTY_SIZES, JlEmpty } from "./molecules/jl-empty.js";
|
|
42
|
+
import { FIELD_ORIENTATIONS, JlField } from "./molecules/jl-field.js";
|
|
43
|
+
import { JlFileDrop } from "./molecules/jl-file-drop.js";
|
|
44
|
+
import { JlListItem } from "./molecules/jl-list-item.js";
|
|
45
|
+
import { JlMenu } from "./molecules/jl-menu.js";
|
|
46
|
+
import { JlNumberInput } from "./molecules/jl-number-input.js";
|
|
47
|
+
import { JlPagination } from "./molecules/jl-pagination.js";
|
|
48
|
+
import { JlPopover } from "./molecules/jl-popover.js";
|
|
49
|
+
import { JlRadioGroup, RADIO_GROUP_ORIENTATIONS, RADIO_GROUP_VARIANTS } from "./molecules/jl-radio-group.js";
|
|
50
|
+
import { JlSearch } from "./molecules/jl-search.js";
|
|
51
|
+
import { JlSegmented } from "./molecules/jl-segmented.js";
|
|
52
|
+
import { JlStat, STAT_TRENDS } from "./molecules/jl-stat.js";
|
|
53
|
+
import { JlSteps, STEPS_ORIENTATIONS } from "./molecules/jl-steps.js";
|
|
54
|
+
import { JlTabPanel } from "./molecules/jl-tab-panel.js";
|
|
55
|
+
import { JlTabs, TAB_VARIANTS } from "./molecules/jl-tabs.js";
|
|
56
|
+
import { JlTagInput } from "./molecules/jl-tag-input.js";
|
|
57
|
+
import { JlTimeline } from "./molecules/jl-timeline.js";
|
|
58
|
+
import { JlToast, TOAST_TONES } from "./molecules/jl-toast.js";
|
|
59
|
+
import { JlTooltip } from "./molecules/jl-tooltip.js";
|
|
60
|
+
import { JlCommandPalette } from "./organisms/jl-command-palette.js";
|
|
61
|
+
import { DIALOG_SIZES, JlDialog } from "./organisms/jl-dialog.js";
|
|
62
|
+
import { CONFIRM_TONES, JlConfirm, confirmDialog } from "./organisms/jl-confirm.js";
|
|
63
|
+
import { DRAWER_PLACEMENTS, DRAWER_SIZES, JlDrawer } from "./organisms/jl-drawer.js";
|
|
64
|
+
import { JlNavbar } from "./organisms/jl-navbar.js";
|
|
65
|
+
import { JlPageHeader } from "./organisms/jl-page-header.js";
|
|
66
|
+
import { JlSideNav } from "./organisms/jl-side-nav.js";
|
|
67
|
+
import { JlTable, TABLE_SORT_DIRECTIONS } from "./organisms/jl-table.js";
|
|
68
|
+
import { JlToaster, TOASTER_PLACEMENTS, toast } from "./organisms/jl-toaster.js";
|
|
69
|
+
import { JlTree } from "./organisms/jl-tree.js";
|
|
70
|
+
import { JlAppShell } from "./templates/jl-app-shell.js";
|
|
71
|
+
import { JlSplitView, SPLIT_ORIENTATIONS } from "./templates/jl-split-view.js";
|
|
72
|
+
export { ACCORDION_VARIANTS, AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, BUTTON_TYPES, BUTTON_VARIANTS, CARD_PADDINGS, CHIP_SIZES, CODE_LANGUAGES, COMMON_ICONS, CONFIRM_TONES, CONTROL_SIZES, DIALOG_SIZES, DIVIDER_ALIGNS, DRAWER_PLACEMENTS, DRAWER_SIZES, EMPTY_SIZES, FIELD_ORIENTATIONS, INPUT_TYPES, JlAccordion, JlAccordionItem, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlElement, JlEmpty, JlField, JlFileDrop, JlFormControl, JlIcon, JlInput, JlKbd, JlLink, JlListItem, JlMenu, JlNavbar, JlNumberInput, JlPageHeader, JlPagination, JlPopover, JlProgress, JlProgressRing, JlRadioGroup, JlRating, JlSearch, JlSegmented, JlSelect, JlSideNav, JlSkeleton, JlSlider, JlSpinner, JlSplitView, JlStat, JlSteps, JlSwitch, JlTabPanel, JlTable, JlTabs, JlTagInput, JlTextarea, JlTimeline, JlToast, JlToaster, JlTooltip, JlTree, LINK_VARIANTS, PLACEMENTS, PROGRESS_SIZES, PROGRESS_TONES, RADIO_GROUP_ORIENTATIONS, RADIO_GROUP_VARIANTS, SKELETON_SHAPES, SPLIT_ORIENTATIONS, STAT_TRENDS, STEPS_ORIENTATIONS, SWITCH_SIZES, TABLE_SORT_DIRECTIONS, TAB_VARIANTS, TOASTER_PLACEMENTS, TOAST_TONES, TOKEN_STYLES, TONES, TONE_ICONS, adoptTokens, clampedNumber, computePosition, confirmDialog, define, followAnchor, hasIcon, iconElement, iconNames, jsonOf, oneOf, placeFloating, registerIcons, toast };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Rect, Side } from '../types/floating.types';
|
|
2
|
+
/**
|
|
3
|
+
* Where a floating element's arrow goes along the edge that faces its anchor, in pixels from that edge's start: in
|
|
4
|
+
* front of the anchor's centre, kept `margin` pixels away from the corners.
|
|
5
|
+
*/
|
|
6
|
+
export declare function arrowOffset(anchor: Rect, floating: Rect, side: Side, margin: number): number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/lib/arrow.ts
|
|
2
|
+
var isVertical = (side) => side === "top" || side === "bottom";
|
|
3
|
+
/**
|
|
4
|
+
* Where a floating element's arrow goes along the edge that faces its anchor, in pixels from that edge's start: in
|
|
5
|
+
* front of the anchor's centre, kept `margin` pixels away from the corners.
|
|
6
|
+
*/
|
|
7
|
+
function arrowOffset(anchor, floating, side, margin) {
|
|
8
|
+
const vertical = isVertical(side);
|
|
9
|
+
const anchorCentre = vertical ? anchor.left + anchor.width / 2 : anchor.top + anchor.height / 2;
|
|
10
|
+
const start = vertical ? floating.left : floating.top;
|
|
11
|
+
const length = vertical ? floating.width : floating.height;
|
|
12
|
+
const offset = anchorCentre - start;
|
|
13
|
+
return Math.min(Math.max(offset, margin), Math.max(margin, length - margin));
|
|
14
|
+
}
|
|
15
|
+
export { arrowOffset };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** An attribute's value when it is one of the allowed ones, otherwise the fallback. */
|
|
2
|
+
export declare const oneOf: <Value extends string>(allowed: readonly Value[], fallback: Value) => (value: string | null) => Value;
|
|
3
|
+
/**
|
|
4
|
+
* An attribute holding JSON, for the lists and objects a page writes in HTML:
|
|
5
|
+
* `<jl-select options='[{"value":"a","label":"A"}]'>`. Unreadable JSON gives the fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare const jsonOf: <Value>(fallback: Value) => (value: string | null) => Value;
|
|
8
|
+
/** A number attribute kept within bounds; a missing or unreadable one gives the fallback. */
|
|
9
|
+
export declare const clampedNumber: (fallback: number, min: number, max: number) => (value: string | null) => number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/lib/attributes.ts
|
|
2
|
+
/** An attribute's value when it is one of the allowed ones, otherwise the fallback. */
|
|
3
|
+
var oneOf = (allowed, fallback) => (value) => allowed.find((candidate) => candidate === value) ?? fallback;
|
|
4
|
+
/**
|
|
5
|
+
* An attribute holding JSON, for the lists and objects a page writes in HTML:
|
|
6
|
+
* `<jl-select options='[{"value":"a","label":"A"}]'>`. Unreadable JSON gives the fallback.
|
|
7
|
+
*/
|
|
8
|
+
var jsonOf = (fallback) => (value) => {
|
|
9
|
+
if (value === null || value.trim() === "") return fallback;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(value);
|
|
12
|
+
} catch {
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** A number attribute kept within bounds; a missing or unreadable one gives the fallback. */
|
|
17
|
+
var clampedNumber = (fallback, min, max) => (value) => {
|
|
18
|
+
const parsed = value === null || value.trim() === "" ? NaN : Number(value);
|
|
19
|
+
if (Number.isNaN(parsed)) return fallback;
|
|
20
|
+
return Math.min(max, Math.max(min, parsed));
|
|
21
|
+
};
|
|
22
|
+
export { clampedNumber, jsonOf, oneOf };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A name's initials, at most two: "Ada Lovelace" gives AL, "Grace" gives G, "Jean-Luc Picard" gives JP. */
|
|
2
|
+
export declare function initialsOf(name: string): string;
|
|
3
|
+
/** A number for a text, always the same for the same text. */
|
|
4
|
+
export declare function stableHash(text: string): number;
|
|
5
|
+
/** One of the options, chosen by the key: the same key always gets the same option. */
|
|
6
|
+
export declare function pickStable<Option>(key: string, options: readonly [Option, ...Option[]]): Option;
|
|
7
|
+
/** The items a group shows, and those it only counts ("+3"); a `max` of 0 or less shows them all. */
|
|
8
|
+
export declare function splitVisible<Item>(items: readonly Item[], max: number): {
|
|
9
|
+
shown: Item[];
|
|
10
|
+
hidden: Item[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/lib/avatar.ts
|
|
2
|
+
var HASH_SEED = 2166136261;
|
|
3
|
+
var HASH_PRIME = 16777619;
|
|
4
|
+
var MAX_INITIALS = 2;
|
|
5
|
+
var WORDS = /\s+/;
|
|
6
|
+
var LETTER_OR_DIGIT = /[\p{L}\p{N}]/u;
|
|
7
|
+
/** The first letter or digit of a word, whole even outside the basic plane; its first character otherwise. */
|
|
8
|
+
var firstLetter = (word) => {
|
|
9
|
+
const characters = Array.from(word);
|
|
10
|
+
return characters.find((character) => LETTER_OR_DIGIT.test(character)) ?? characters[0] ?? "";
|
|
11
|
+
};
|
|
12
|
+
/** A name's initials, at most two: "Ada Lovelace" gives AL, "Grace" gives G, "Jean-Luc Picard" gives JP. */
|
|
13
|
+
function initialsOf(name) {
|
|
14
|
+
const words = name.trim().split(WORDS).filter((word) => word !== "");
|
|
15
|
+
if (words.length === 0) return "";
|
|
16
|
+
return (words.length === 1 ? words : [words[0] ?? "", words.at(-1) ?? ""]).slice(0, MAX_INITIALS).map(firstLetter).join("").toLocaleUpperCase();
|
|
17
|
+
}
|
|
18
|
+
/** A number for a text, always the same for the same text. */
|
|
19
|
+
function stableHash(text) {
|
|
20
|
+
return Array.from(text).reduce((hash, character) => Math.imul(hash ^ (character.codePointAt(0) ?? 0), HASH_PRIME) >>> 0, HASH_SEED);
|
|
21
|
+
}
|
|
22
|
+
/** One of the options, chosen by the key: the same key always gets the same option. */
|
|
23
|
+
function pickStable(key, options) {
|
|
24
|
+
return options[stableHash(key) % options.length] ?? options[0];
|
|
25
|
+
}
|
|
26
|
+
/** The items a group shows, and those it only counts ("+3"); a `max` of 0 or less shows them all. */
|
|
27
|
+
function splitVisible(items, max) {
|
|
28
|
+
if (max <= 0 || items.length <= max) return {
|
|
29
|
+
hidden: [],
|
|
30
|
+
shown: [...items]
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
hidden: items.slice(max),
|
|
34
|
+
shown: items.slice(0, max)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export { initialsOf, pickStable, splitVisible, stableHash };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CalendarDate, Weekday, WeekdayWidth } from '../types/calendar.types';
|
|
2
|
+
/** A month grid always has six weeks, so the calendar keeps its height from one month to the next. */
|
|
3
|
+
export declare const WEEKS_PER_GRID = 6;
|
|
4
|
+
export declare const isLeapYear: (year: number) => boolean;
|
|
5
|
+
export declare function daysInMonth(year: number, month: number): number;
|
|
6
|
+
/** A date from its ISO text (`2026-10-25`); null for anything else, including days that do not exist. */
|
|
7
|
+
export declare function parseIsoDate(text: string): CalendarDate | null;
|
|
8
|
+
export declare const toIsoDate: (date: CalendarDate) => string;
|
|
9
|
+
/** Today, or the day of any moment, as the person's clock shows it. */
|
|
10
|
+
export declare const calendarDateOf: (moment: Date) => CalendarDate;
|
|
11
|
+
export declare const addDays: (date: CalendarDate, days: number) => CalendarDate;
|
|
12
|
+
/** The same day some months later or earlier; the 31st becomes the last day of a shorter month. */
|
|
13
|
+
export declare function addMonths(date: CalendarDate, months: number): CalendarDate;
|
|
14
|
+
export declare const addYears: (date: CalendarDate, years: number) => CalendarDate;
|
|
15
|
+
export declare const dayOfWeek: (date: CalendarDate) => Weekday;
|
|
16
|
+
/** Negative when a comes first, positive when b does, 0 for the same day. */
|
|
17
|
+
export declare const compareDates: (a: CalendarDate, b: CalendarDate) => number;
|
|
18
|
+
export declare const isSameDate: (a: CalendarDate | null, b: CalendarDate | null) => boolean;
|
|
19
|
+
/** Whether the date is within the bounds, both included; a null bound does not limit. */
|
|
20
|
+
export declare const isWithin: (date: CalendarDate, min: CalendarDate | null, max: CalendarDate | null) => boolean;
|
|
21
|
+
/** The nearest date within the bounds. */
|
|
22
|
+
export declare function clampDate(date: CalendarDate, min: CalendarDate | null, max: CalendarDate | null): CalendarDate;
|
|
23
|
+
/** The weekdays in the order a week shows them, from its first day. */
|
|
24
|
+
export declare const weekdayOrder: (firstDay: Weekday) => Weekday[];
|
|
25
|
+
export declare const startOfWeek: (date: CalendarDate, firstDay: Weekday) => CalendarDate;
|
|
26
|
+
export declare const endOfWeek: (date: CalendarDate, firstDay: Weekday) => CalendarDate;
|
|
27
|
+
export declare const startOfMonth: (date: CalendarDate) => CalendarDate;
|
|
28
|
+
export declare const isSameMonth: (a: CalendarDate, b: CalendarDate) => boolean;
|
|
29
|
+
/** Six weeks of days around a month, starting on the week's first day: the days of a calendar page. */
|
|
30
|
+
export declare function monthGrid(year: number, month: number, firstDay: Weekday): CalendarDate[][];
|
|
31
|
+
/** Whether any day of the month is within the bounds: a month entirely outside them is not worth showing. */
|
|
32
|
+
export declare function monthHasDaysWithin(year: number, month: number, min: CalendarDate | null, max: CalendarDate | null): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Where a key moves the focus of a date grid: arrows by day and week, Home and End to the ends of the week,
|
|
35
|
+
* Page Up and Page Down by month (by year with Shift). Null for a key that does not move it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function dateAfterKey(date: CalendarDate, key: string, firstDay: Weekday, shift?: boolean): CalendarDate | null;
|
|
38
|
+
/**
|
|
39
|
+
* A function that writes dates for people, in a locale: `Oct 25, 2026` by default, any Intl date style with
|
|
40
|
+
* `options`. Made once and used for many dates, as a calendar page does.
|
|
41
|
+
*/
|
|
42
|
+
export declare function dateFormatter(locale: string | undefined, options?: Intl.DateTimeFormatOptions): (date: CalendarDate) => string;
|
|
43
|
+
/** One date written for people, in a locale: `Oct 25, 2026` by default. */
|
|
44
|
+
export declare const formatDate: (date: CalendarDate, locale: string | undefined, options?: Intl.DateTimeFormatOptions) => string;
|
|
45
|
+
/** The title of a calendar page: `October 2026`. */
|
|
46
|
+
export declare const formatMonthTitle: (year: number, month: number, locale: string | undefined) => string;
|
|
47
|
+
/** The names of the weekdays, in the order a week shows them from its first day. */
|
|
48
|
+
export declare const weekdayNames: (locale: string | undefined, firstDay: Weekday, width: WeekdayWidth) => string[];
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// src/lib/calendar.ts
|
|
2
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
3
|
+
var MS_PER_DAY = 864e5;
|
|
4
|
+
var MONTHS_PER_YEAR = 12;
|
|
5
|
+
var DAYS_PER_WEEK = 7;
|
|
6
|
+
var FEBRUARY = 2;
|
|
7
|
+
var LEAP_FEBRUARY_DAYS = 29;
|
|
8
|
+
var MONTH_LENGTHS = [
|
|
9
|
+
31,
|
|
10
|
+
28,
|
|
11
|
+
31,
|
|
12
|
+
30,
|
|
13
|
+
31,
|
|
14
|
+
30,
|
|
15
|
+
31,
|
|
16
|
+
31,
|
|
17
|
+
30,
|
|
18
|
+
31,
|
|
19
|
+
30,
|
|
20
|
+
31
|
|
21
|
+
];
|
|
22
|
+
var YEAR_DIGITS = 4;
|
|
23
|
+
var MONTH_DIGITS = 2;
|
|
24
|
+
var A_SUNDAY = {
|
|
25
|
+
day: 1,
|
|
26
|
+
month: 1,
|
|
27
|
+
year: 2023
|
|
28
|
+
};
|
|
29
|
+
var UTC = "UTC";
|
|
30
|
+
var isLeapYear = (year) => year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
31
|
+
function daysInMonth(year, month) {
|
|
32
|
+
if (month === FEBRUARY && isLeapYear(year)) return LEAP_FEBRUARY_DAYS;
|
|
33
|
+
return MONTH_LENGTHS[month - 1] ?? 0;
|
|
34
|
+
}
|
|
35
|
+
/** A date from its ISO text (`2026-10-25`); null for anything else, including days that do not exist. */
|
|
36
|
+
function parseIsoDate(text) {
|
|
37
|
+
const match = ISO_DATE.exec(text.trim());
|
|
38
|
+
if (match === null) return null;
|
|
39
|
+
const year = Number(match[1]);
|
|
40
|
+
const month = Number(match[2]);
|
|
41
|
+
const day = Number(match[3]);
|
|
42
|
+
if (month < 1 || month > MONTHS_PER_YEAR || day < 1 || day > daysInMonth(year, month)) return null;
|
|
43
|
+
return {
|
|
44
|
+
day,
|
|
45
|
+
month,
|
|
46
|
+
year
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var pad = (value, digits) => String(value).padStart(digits, "0");
|
|
50
|
+
var toIsoDate = (date) => `${pad(date.year, YEAR_DIGITS)}-${pad(date.month, MONTH_DIGITS)}-${pad(date.day, MONTH_DIGITS)}`;
|
|
51
|
+
/** The date's midnight in UTC. `setUTCFullYear` keeps years under 100 as they are, where `Date.UTC` would not. */
|
|
52
|
+
function utcTime(date) {
|
|
53
|
+
const time = /* @__PURE__ */ new Date(0);
|
|
54
|
+
time.setUTCFullYear(date.year, date.month - 1, date.day);
|
|
55
|
+
return time.getTime();
|
|
56
|
+
}
|
|
57
|
+
function fromUtcTime(time) {
|
|
58
|
+
const moment = new Date(time);
|
|
59
|
+
return {
|
|
60
|
+
day: moment.getUTCDate(),
|
|
61
|
+
month: moment.getUTCMonth() + 1,
|
|
62
|
+
year: moment.getUTCFullYear()
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Today, or the day of any moment, as the person's clock shows it. */
|
|
66
|
+
var calendarDateOf = (moment) => ({
|
|
67
|
+
day: moment.getDate(),
|
|
68
|
+
month: moment.getMonth() + 1,
|
|
69
|
+
year: moment.getFullYear()
|
|
70
|
+
});
|
|
71
|
+
var addDays = (date, days) => fromUtcTime(utcTime(date) + days * MS_PER_DAY);
|
|
72
|
+
/** The same day some months later or earlier; the 31st becomes the last day of a shorter month. */
|
|
73
|
+
function addMonths(date, months) {
|
|
74
|
+
const index = date.year * MONTHS_PER_YEAR + (date.month - 1) + months;
|
|
75
|
+
const year = Math.floor(index / MONTHS_PER_YEAR);
|
|
76
|
+
const month = index - year * MONTHS_PER_YEAR + 1;
|
|
77
|
+
return {
|
|
78
|
+
day: Math.min(date.day, daysInMonth(year, month)),
|
|
79
|
+
month,
|
|
80
|
+
year
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
var addYears = (date, years) => addMonths(date, years * MONTHS_PER_YEAR);
|
|
84
|
+
var dayOfWeek = (date) => new Date(utcTime(date)).getUTCDay();
|
|
85
|
+
/** Negative when a comes first, positive when b does, 0 for the same day. */
|
|
86
|
+
var compareDates = (a, b) => a.year - b.year || a.month - b.month || a.day - b.day;
|
|
87
|
+
var isSameDate = (a, b) => a !== null && b !== null && compareDates(a, b) === 0;
|
|
88
|
+
/** Whether the date is within the bounds, both included; a null bound does not limit. */
|
|
89
|
+
var isWithin = (date, min, max) => (min === null || compareDates(date, min) >= 0) && (max === null || compareDates(date, max) <= 0);
|
|
90
|
+
/** The nearest date within the bounds. */
|
|
91
|
+
function clampDate(date, min, max) {
|
|
92
|
+
if (min !== null && compareDates(date, min) < 0) return min;
|
|
93
|
+
if (max !== null && compareDates(date, max) > 0) return max;
|
|
94
|
+
return date;
|
|
95
|
+
}
|
|
96
|
+
/** The weekdays in the order a week shows them, from its first day. */
|
|
97
|
+
var weekdayOrder = (firstDay) => Array.from({ length: DAYS_PER_WEEK }, (_, index) => (firstDay + index) % DAYS_PER_WEEK);
|
|
98
|
+
var startOfWeek = (date, firstDay) => addDays(date, -((dayOfWeek(date) - firstDay + DAYS_PER_WEEK) % DAYS_PER_WEEK));
|
|
99
|
+
var endOfWeek = (date, firstDay) => addDays(startOfWeek(date, firstDay), 6);
|
|
100
|
+
var isSameMonth = (a, b) => a.year === b.year && a.month === b.month;
|
|
101
|
+
/** Six weeks of days around a month, starting on the week's first day: the days of a calendar page. */
|
|
102
|
+
function monthGrid(year, month, firstDay) {
|
|
103
|
+
const start = startOfWeek({
|
|
104
|
+
day: 1,
|
|
105
|
+
month,
|
|
106
|
+
year
|
|
107
|
+
}, firstDay);
|
|
108
|
+
return Array.from({ length: 6 }, (_, week) => Array.from({ length: DAYS_PER_WEEK }, (_, day) => addDays(start, week * DAYS_PER_WEEK + day)));
|
|
109
|
+
}
|
|
110
|
+
/** Whether any day of the month is within the bounds: a month entirely outside them is not worth showing. */
|
|
111
|
+
function monthHasDaysWithin(year, month, min, max) {
|
|
112
|
+
const first = {
|
|
113
|
+
day: 1,
|
|
114
|
+
month,
|
|
115
|
+
year
|
|
116
|
+
};
|
|
117
|
+
const last = {
|
|
118
|
+
day: daysInMonth(year, month),
|
|
119
|
+
month,
|
|
120
|
+
year
|
|
121
|
+
};
|
|
122
|
+
return (max === null || compareDates(first, max) <= 0) && (min === null || compareDates(last, min) >= 0);
|
|
123
|
+
}
|
|
124
|
+
var DAY_MOVES = /* @__PURE__ */ new Map([
|
|
125
|
+
["ArrowDown", (date) => addDays(date, DAYS_PER_WEEK)],
|
|
126
|
+
["ArrowLeft", (date) => addDays(date, -1)],
|
|
127
|
+
["ArrowRight", (date) => addDays(date, 1)],
|
|
128
|
+
["ArrowUp", (date) => addDays(date, -7)],
|
|
129
|
+
["End", (date, firstDay) => endOfWeek(date, firstDay)],
|
|
130
|
+
["Home", (date, firstDay) => startOfWeek(date, firstDay)],
|
|
131
|
+
["PageDown", (date, _, shift) => shift ? addYears(date, 1) : addMonths(date, 1)],
|
|
132
|
+
["PageUp", (date, _, shift) => shift ? addYears(date, -1) : addMonths(date, -1)]
|
|
133
|
+
]);
|
|
134
|
+
/**
|
|
135
|
+
* Where a key moves the focus of a date grid: arrows by day and week, Home and End to the ends of the week,
|
|
136
|
+
* Page Up and Page Down by month (by year with Shift). Null for a key that does not move it.
|
|
137
|
+
*/
|
|
138
|
+
function dateAfterKey(date, key, firstDay, shift = false) {
|
|
139
|
+
const move = DAY_MOVES.get(key);
|
|
140
|
+
return move === void 0 ? null : move(date, firstDay, shift);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A function that writes dates for people, in a locale: `Oct 25, 2026` by default, any Intl date style with
|
|
144
|
+
* `options`. Made once and used for many dates, as a calendar page does.
|
|
145
|
+
*/
|
|
146
|
+
function dateFormatter(locale, options = { dateStyle: "medium" }) {
|
|
147
|
+
const format = new Intl.DateTimeFormat(locale, {
|
|
148
|
+
...options,
|
|
149
|
+
timeZone: UTC
|
|
150
|
+
});
|
|
151
|
+
return (date) => format.format(new Date(utcTime(date)));
|
|
152
|
+
}
|
|
153
|
+
/** One date written for people, in a locale: `Oct 25, 2026` by default. */
|
|
154
|
+
var formatDate = (date, locale, options) => dateFormatter(locale, options)(date);
|
|
155
|
+
/** The title of a calendar page: `October 2026`. */
|
|
156
|
+
var formatMonthTitle = (year, month, locale) => formatDate({
|
|
157
|
+
day: 1,
|
|
158
|
+
month,
|
|
159
|
+
year
|
|
160
|
+
}, locale, {
|
|
161
|
+
month: "long",
|
|
162
|
+
year: "numeric"
|
|
163
|
+
});
|
|
164
|
+
/** The names of the weekdays, in the order a week shows them from its first day. */
|
|
165
|
+
var weekdayNames = (locale, firstDay, width) => weekdayOrder(firstDay).map((weekday) => formatDate(addDays(A_SUNDAY, weekday), locale, { weekday: width }));
|
|
166
|
+
export { addDays, addMonths, addYears, calendarDateOf, clampDate, compareDates, dateAfterKey, dateFormatter, dayOfWeek, daysInMonth, endOfWeek, formatDate, formatMonthTitle, isLeapYear, isSameDate, isSameMonth, isWithin, monthGrid, monthHasDaysWithin, parseIsoDate, startOfWeek, toIsoDate, weekdayNames, weekdayOrder };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/lib/css-length.ts
|
|
2
|
+
var PLAIN_NUMBER = /^-?\d+(\.\d+)?$/;
|
|
3
|
+
/** A size for CSS: a plain number is in pixels ("120" gives "120px"); anything else is kept ("50%", "8rem"). */
|
|
4
|
+
function cssLength(value) {
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
return PLAIN_NUMBER.test(trimmed) ? `${trimmed}px` : trimmed;
|
|
7
|
+
}
|
|
8
|
+
export { cssLength };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Registrable = {
|
|
2
|
+
register(): void;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Defines components for use as HTML tags: `define(JlButton, JlDialog)`. A component also defines itself when its
|
|
6
|
+
* class is used; naming it here is what keeps it in the bundle when the page only writes its tag.
|
|
7
|
+
*/
|
|
8
|
+
export declare function define(...components: Registrable[]): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/lib/define.ts
|
|
2
|
+
/**
|
|
3
|
+
* Defines components for use as HTML tags: `define(JlButton, JlDialog)`. A component also defines itself when its
|
|
4
|
+
* class is used; naming it here is what keeps it in the bundle when the page only writes its tag.
|
|
5
|
+
*/
|
|
6
|
+
function define(...components) {
|
|
7
|
+
for (const component of components) component.register();
|
|
8
|
+
}
|
|
9
|
+
export { define };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Sets an attribute, or removes it when the value is empty. */
|
|
2
|
+
export declare function setOrRemove(element: Element, name: string, value: string): void;
|
|
3
|
+
/** A unique id within the page, for wiring `aria-controls`, `aria-labelledby` and the like inside a shadow root. */
|
|
4
|
+
export declare function uniqueId(prefix: string): string;
|
package/dist/lib/dom.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/lib/dom.ts
|
|
2
|
+
/** Sets an attribute, or removes it when the value is empty. */
|
|
3
|
+
function setOrRemove(element, name, value) {
|
|
4
|
+
if (value === "") {
|
|
5
|
+
element.removeAttribute(name);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
element.setAttribute(name, value);
|
|
9
|
+
}
|
|
10
|
+
var sequence = { next: 0 };
|
|
11
|
+
/** A unique id within the page, for wiring `aria-controls`, `aria-labelledby` and the like inside a shadow root. */
|
|
12
|
+
function uniqueId(prefix) {
|
|
13
|
+
sequence.next += 1;
|
|
14
|
+
return `${prefix}-${sequence.next}`;
|
|
15
|
+
}
|
|
16
|
+
export { setOrRemove, uniqueId };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FileCheck, FileLike, FileRules } from '../types/files.types';
|
|
2
|
+
/** A size in bytes as people read it: `512 B`, `1.5 KB`, `12 MB`, in powers of 1024. */
|
|
3
|
+
export declare function formatFileSize(bytes: number, locale?: string): string;
|
|
4
|
+
/** Whether a file is of a type the `accept` list allows, as `<input type="file" accept>` reads it. Empty allows all. */
|
|
5
|
+
export declare function matchesAccept(file: Pick<FileLike, 'name' | 'type'>, accept: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Sorts files into those a field takes and those it refuses, with the reason. A single-file field takes the first
|
|
8
|
+
* good file and refuses the other good ones as one too many.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkFiles<Item extends FileLike>(files: readonly Item[], rules: FileRules): FileCheck<Item>;
|
|
11
|
+
/** An `accept` list as people read it, without repeats: `.png,.jpg,image/png` gives `PNG, JPG`. */
|
|
12
|
+
export declare const describeAccept: (accept: string) => string;
|
|
13
|
+
/** Whether two files are the same one picked twice: same name, size and modification time. */
|
|
14
|
+
export declare const isSameFile: (a: FileLike & {
|
|
15
|
+
lastModified?: number;
|
|
16
|
+
}, b: FileLike & {
|
|
17
|
+
lastModified?: number;
|
|
18
|
+
}) => boolean;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// src/lib/files.ts
|
|
2
|
+
var SIZE_UNITS = [
|
|
3
|
+
"B",
|
|
4
|
+
"KB",
|
|
5
|
+
"MB",
|
|
6
|
+
"GB",
|
|
7
|
+
"TB"
|
|
8
|
+
];
|
|
9
|
+
var SIZE_STEP = 1024;
|
|
10
|
+
var DECIMALS_BELOW = 10;
|
|
11
|
+
var WILDCARD = "/*";
|
|
12
|
+
var EXTENSION_MARK = ".";
|
|
13
|
+
/** A size in bytes as people read it: `512 B`, `1.5 KB`, `12 MB`, in powers of 1024. */
|
|
14
|
+
function formatFileSize(bytes, locale) {
|
|
15
|
+
const safe = Number.isFinite(bytes) && bytes > 0 ? bytes : 0;
|
|
16
|
+
const exponent = unitExponent(safe);
|
|
17
|
+
const value = safe / SIZE_STEP ** exponent;
|
|
18
|
+
const decimals = exponent === 0 || value >= DECIMALS_BELOW ? 0 : 1;
|
|
19
|
+
return `${new Intl.NumberFormat(locale, {
|
|
20
|
+
maximumFractionDigits: decimals,
|
|
21
|
+
useGrouping: false
|
|
22
|
+
}).format(value)} ${SIZE_UNITS[exponent]}`;
|
|
23
|
+
}
|
|
24
|
+
/** The unit a size is written in; a value that would round up to 1024 of a unit moves to the next one. */
|
|
25
|
+
function unitExponent(bytes) {
|
|
26
|
+
const last = SIZE_UNITS.length - 1;
|
|
27
|
+
const exponent = bytes < 1 ? 0 : Math.min(last, Math.floor(Math.log(bytes) / Math.log(SIZE_STEP)));
|
|
28
|
+
return Math.round(bytes / SIZE_STEP ** exponent) >= SIZE_STEP && exponent < last ? exponent + 1 : exponent;
|
|
29
|
+
}
|
|
30
|
+
var acceptTokens = (accept) => accept.split(",").map((token) => token.trim().toLowerCase()).filter((token) => token !== "");
|
|
31
|
+
/** Whether one entry of an `accept` list takes the file: an extension, a MIME type, or a family such as `image/*`. */
|
|
32
|
+
function acceptsToken(token, name, type) {
|
|
33
|
+
if (token.startsWith(EXTENSION_MARK)) return name.endsWith(token);
|
|
34
|
+
if (token.endsWith(WILDCARD)) return type.startsWith(token.slice(0, -1));
|
|
35
|
+
return type === token;
|
|
36
|
+
}
|
|
37
|
+
/** Whether a file is of a type the `accept` list allows, as `<input type="file" accept>` reads it. Empty allows all. */
|
|
38
|
+
function matchesAccept(file, accept) {
|
|
39
|
+
const tokens = acceptTokens(accept);
|
|
40
|
+
const name = file.name.toLowerCase();
|
|
41
|
+
const type = file.type.toLowerCase();
|
|
42
|
+
return tokens.length === 0 || tokens.some((token) => acceptsToken(token, name, type));
|
|
43
|
+
}
|
|
44
|
+
/** Why a file is refused on its own, before counting: its type, then its size; null when it is fine. */
|
|
45
|
+
function refusalOf(file, rules) {
|
|
46
|
+
if (!matchesAccept(file, rules.accept)) return "type";
|
|
47
|
+
if (rules.maxSize > 0 && file.size > rules.maxSize) return "size";
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sorts files into those a field takes and those it refuses, with the reason. A single-file field takes the first
|
|
52
|
+
* good file and refuses the other good ones as one too many.
|
|
53
|
+
*/
|
|
54
|
+
function checkFiles(files, rules) {
|
|
55
|
+
const result = {
|
|
56
|
+
accepted: [],
|
|
57
|
+
refused: []
|
|
58
|
+
};
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const reason = refusalOf(file, rules);
|
|
61
|
+
if (reason !== null) {
|
|
62
|
+
result.refused.push({
|
|
63
|
+
file,
|
|
64
|
+
reason
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!rules.multiple && result.accepted.length > 0) {
|
|
69
|
+
result.refused.push({
|
|
70
|
+
file,
|
|
71
|
+
reason: "count"
|
|
72
|
+
});
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
result.accepted.push(file);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
/** One entry of an `accept` list as people read it: `.png` and `image/png` give `PNG`, `image/*` gives `images`. */
|
|
80
|
+
function describeToken(token) {
|
|
81
|
+
if (token.startsWith(EXTENSION_MARK)) return token.slice(1).toUpperCase();
|
|
82
|
+
if (token.endsWith(WILDCARD)) return `${token.slice(0, -2)}s`;
|
|
83
|
+
return (token.split("/").at(-1) ?? token).toUpperCase();
|
|
84
|
+
}
|
|
85
|
+
/** An `accept` list as people read it, without repeats: `.png,.jpg,image/png` gives `PNG, JPG`. */
|
|
86
|
+
var describeAccept = (accept) => [...new Set(acceptTokens(accept).map(describeToken))].join(", ");
|
|
87
|
+
/** Whether two files are the same one picked twice: same name, size and modification time. */
|
|
88
|
+
var isSameFile = (a, b) => a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;
|
|
89
|
+
export { checkFiles, describeAccept, formatFileSize, isSameFile, matchesAccept };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Placement, Point, Rect, Size } from '../types/floating.types';
|
|
2
|
+
export declare const PLACEMENTS: readonly Placement[];
|
|
3
|
+
/**
|
|
4
|
+
* Where to put a floating element next to its anchor, in window coordinates: on the asked side when it fits,
|
|
5
|
+
* otherwise on the opposite side if that leaves more of it visible; then kept inside the window.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computePosition(anchor: Rect, floating: Size, viewport: Size, placement: Placement, gap?: number): Point & {
|
|
8
|
+
placement: Placement;
|
|
9
|
+
};
|
|
10
|
+
/** Puts a fixed-position element next to its anchor; returns the placement it got after flipping. */
|
|
11
|
+
export declare function placeFloating(anchor: Element, floating: HTMLElement, placement: Placement, gap?: number): Placement;
|
|
12
|
+
/** Keeps a floating element by its anchor while the page scrolls or resizes, until the signal aborts. */
|
|
13
|
+
export declare function followAnchor(anchor: Element, floating: HTMLElement, placement: Placement, signal: AbortSignal, gap?: number): void;
|