@syware/jlib 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +8 -3
- package/dist/atoms/jl-badge.d.ts +12 -1
- package/dist/atoms/jl-badge.js +15 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +7 -2
- package/dist/lib/time.d.ts +10 -0
- package/dist/lib/time.js +64 -0
- package/dist/molecules/jl-account-button.css_raw.js +3 -0
- package/dist/molecules/jl-account-button.d.ts +46 -0
- package/dist/molecules/jl-account-button.js +97 -0
- package/dist/molecules/jl-load-state.css_raw.js +3 -0
- package/dist/molecules/jl-load-state.d.ts +61 -0
- package/dist/molecules/jl-load-state.js +200 -0
- package/dist/molecules/jl-search-button.css_raw.js +3 -0
- package/dist/molecules/jl-search-button.d.ts +34 -0
- package/dist/molecules/jl-search-button.js +80 -0
- package/dist/molecules/jl-tooltip.css_raw.js +1 -1
- package/dist/molecules/jl-tooltip.d.ts +26 -1
- package/dist/molecules/jl-tooltip.js +132 -5
- package/dist/organisms/jl-confirm.d.ts +7 -1
- package/dist/organisms/jl-confirm.js +22 -1
- package/dist/organisms/jl-toaster.d.ts +4 -1
- package/dist/organisms/jl-toaster.js +9 -2
- package/dist/styles/control.css_raw.js +1 -1
- package/dist/styles/tokens.css_raw.js +1 -1
- package/dist/templates/jl-page.css_raw.js +3 -0
- package/dist/templates/jl-page.d.ts +49 -0
- package/dist/templates/jl-page.js +102 -0
- package/dist/tokens.css +22 -0
- package/dist/types/jl-badge.types.d.ts +11 -0
- package/dist/types/jl-confirm.types.d.ts +15 -0
- package/dist/types/jl-load-state.types.d.ts +10 -0
- package/dist/types/jl-page.types.d.ts +2 -0
- package/dist/types/jl-toaster.types.d.ts +1 -1
- package/package.json +1 -1
package/dist/all.js
CHANGED
|
@@ -8,6 +8,7 @@ import { PLACEMENTS, computePosition, followAnchor, placeFloating } from "./lib/
|
|
|
8
8
|
import { COMMON_ICONS } from "./lib/icon-set.js";
|
|
9
9
|
import { hasIcon, iconElement, iconNames, registerIcons } from "./lib/icons.js";
|
|
10
10
|
import { CONTROL_SIZES, TONES, TONE_ICONS, TONE_ICON_FILLED } from "./lib/options.js";
|
|
11
|
+
import { formatDuration, formatRelativeTime } from "./lib/time.js";
|
|
11
12
|
import { JlIcon } from "./atoms/jl-icon.js";
|
|
12
13
|
import { AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, JlAvatar } from "./atoms/jl-avatar.js";
|
|
13
14
|
import { JlBadge } from "./atoms/jl-badge.js";
|
|
@@ -29,6 +30,7 @@ import { JlSwitch, SWITCH_SIZES } from "./atoms/jl-switch.js";
|
|
|
29
30
|
import { JlTextarea } from "./atoms/jl-textarea.js";
|
|
30
31
|
import { JlAccordionItem } from "./molecules/jl-accordion-item.js";
|
|
31
32
|
import { ACCORDION_VARIANTS, JlAccordion } from "./molecules/jl-accordion.js";
|
|
33
|
+
import { JlAccountButton } from "./molecules/jl-account-button.js";
|
|
32
34
|
import { JlAlert } from "./molecules/jl-alert.js";
|
|
33
35
|
import { JlAvatarGroup } from "./molecules/jl-avatar-group.js";
|
|
34
36
|
import { JlBreadcrumb } from "./molecules/jl-breadcrumb.js";
|
|
@@ -43,11 +45,13 @@ import { EMPTY_SIZES, JlEmpty } from "./molecules/jl-empty.js";
|
|
|
43
45
|
import { FIELD_ORIENTATIONS, JlField } from "./molecules/jl-field.js";
|
|
44
46
|
import { JlFileDrop } from "./molecules/jl-file-drop.js";
|
|
45
47
|
import { JlListItem } from "./molecules/jl-list-item.js";
|
|
48
|
+
import { JlLoadState, LOAD_SKELETONS, LOAD_STATES } from "./molecules/jl-load-state.js";
|
|
46
49
|
import { JlMenu } from "./molecules/jl-menu.js";
|
|
47
50
|
import { JlNumberInput } from "./molecules/jl-number-input.js";
|
|
48
51
|
import { JlPagination } from "./molecules/jl-pagination.js";
|
|
49
52
|
import { JlPopover } from "./molecules/jl-popover.js";
|
|
50
53
|
import { JlRadioGroup, RADIO_GROUP_ORIENTATIONS, RADIO_GROUP_VARIANTS } from "./molecules/jl-radio-group.js";
|
|
54
|
+
import { JlSearchButton } from "./molecules/jl-search-button.js";
|
|
51
55
|
import { JlSearch } from "./molecules/jl-search.js";
|
|
52
56
|
import { JlSegmented } from "./molecules/jl-segmented.js";
|
|
53
57
|
import { JlStat, STAT_TRENDS } from "./molecules/jl-stat.js";
|
|
@@ -60,7 +64,7 @@ import { JlToast, TOAST_TONES } from "./molecules/jl-toast.js";
|
|
|
60
64
|
import { JlTooltip } from "./molecules/jl-tooltip.js";
|
|
61
65
|
import { JlCommandPalette } from "./organisms/jl-command-palette.js";
|
|
62
66
|
import { DIALOG_SIZES, JlDialog } from "./organisms/jl-dialog.js";
|
|
63
|
-
import { CONFIRM_TONES, JlConfirm, confirmDialog } from "./organisms/jl-confirm.js";
|
|
67
|
+
import { CONFIRM_TONES, JlConfirm, confirmDialog, guardLeave } from "./organisms/jl-confirm.js";
|
|
64
68
|
import { DRAWER_PLACEMENTS, DRAWER_SIZES, JlDrawer } from "./organisms/jl-drawer.js";
|
|
65
69
|
import { JlFlow } from "./organisms/jl-flow.js";
|
|
66
70
|
import { JlNavbar } from "./organisms/jl-navbar.js";
|
|
@@ -71,8 +75,9 @@ import { JlTable, TABLE_SORT_DIRECTIONS } from "./organisms/jl-table.js";
|
|
|
71
75
|
import { JlToaster, TOASTER_PLACEMENTS, toast } from "./organisms/jl-toaster.js";
|
|
72
76
|
import { JlTree } from "./organisms/jl-tree.js";
|
|
73
77
|
import { JlAppShell } from "./templates/jl-app-shell.js";
|
|
78
|
+
import { JlPage, PAGE_WIDTHS } from "./templates/jl-page.js";
|
|
74
79
|
import { JlSplitView, SPLIT_ORIENTATIONS } from "./templates/jl-split-view.js";
|
|
75
80
|
// src/all.ts
|
|
76
81
|
registerIcons(COMMON_ICONS);
|
|
77
|
-
define(JlAccordion, JlAccordionItem, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlEmpty, JlField, JlFileDrop, JlFlow, 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, JlTabBar, JlTable, JlTabPanel, JlTabs, JlTagInput, JlTextarea, JlTimeline, JlToast, JlToaster, JlTooltip, JlTree);
|
|
78
|
-
export { ACCORDION_VARIANTS, AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, BASE_STYLES, BUTTON_TYPES, BUTTON_VARIANTS, CARD_PADDINGS, CHIP_SIZES, CODE_LANGUAGES, COMMON_ICONS, CONFIRM_TONES, CONTROL_SIZES, CONTROL_STYLES, DIALOG_SIZES, DIVIDER_ALIGNS, DRAWER_PLACEMENTS, DRAWER_SIZES, EMPTY_SIZES, FIELD_ORIENTATIONS, FLOATING_STYLES, INPUT_TYPES, JlAccordion, JlAccordionItem, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlElement, JlEmpty, JlField, JlFileDrop, JlFlow, 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, JlTabBar, 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, TONE_ICON_FILLED, adoptTokens, clampedNumber, computePosition, confirmDialog, define, followAnchor, hasIcon, iconElement, iconNames, jsonOf, oneOf, placeFloating, registerIcons, toast };
|
|
82
|
+
define(JlAccordion, JlAccordionItem, JlAccountButton, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlEmpty, JlField, JlFileDrop, JlFlow, JlIcon, JlInput, JlKbd, JlLink, JlListItem, JlLoadState, JlMenu, JlNavbar, JlNumberInput, JlPage, JlPageHeader, JlPagination, JlPopover, JlProgress, JlProgressRing, JlRadioGroup, JlRating, JlSearch, JlSearchButton, JlSegmented, JlSelect, JlSideNav, JlSkeleton, JlSlider, JlSpinner, JlSplitView, JlStat, JlSteps, JlSwitch, JlTabBar, JlTable, JlTabPanel, JlTabs, JlTagInput, JlTextarea, JlTimeline, JlToast, JlToaster, JlTooltip, JlTree);
|
|
83
|
+
export { ACCORDION_VARIANTS, AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, BASE_STYLES, BUTTON_TYPES, BUTTON_VARIANTS, CARD_PADDINGS, CHIP_SIZES, CODE_LANGUAGES, COMMON_ICONS, CONFIRM_TONES, CONTROL_SIZES, CONTROL_STYLES, DIALOG_SIZES, DIVIDER_ALIGNS, DRAWER_PLACEMENTS, DRAWER_SIZES, EMPTY_SIZES, FIELD_ORIENTATIONS, FLOATING_STYLES, INPUT_TYPES, JlAccordion, JlAccordionItem, JlAccountButton, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlElement, JlEmpty, JlField, JlFileDrop, JlFlow, JlFormControl, JlIcon, JlInput, JlKbd, JlLink, JlListItem, JlLoadState, JlMenu, JlNavbar, JlNumberInput, JlPage, JlPageHeader, JlPagination, JlPopover, JlProgress, JlProgressRing, JlRadioGroup, JlRating, JlSearch, JlSearchButton, JlSegmented, JlSelect, JlSideNav, JlSkeleton, JlSlider, JlSpinner, JlSplitView, JlStat, JlSteps, JlSwitch, JlTabBar, JlTabPanel, JlTable, JlTabs, JlTagInput, JlTextarea, JlTimeline, JlToast, JlToaster, JlTooltip, JlTree, LINK_VARIANTS, LOAD_SKELETONS, LOAD_STATES, PAGE_WIDTHS, 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, TONE_ICON_FILLED, adoptTokens, clampedNumber, computePosition, confirmDialog, define, followAnchor, formatDuration, formatRelativeTime, guardLeave, hasIcon, iconElement, iconNames, jsonOf, oneOf, placeFloating, registerIcons, toast };
|
package/dist/atoms/jl-badge.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { JlElement } from '../base/jl-element';
|
|
2
|
+
import type { StatusLook } from '../types/jl-badge.types';
|
|
2
3
|
import type { Tone } from '../types/options.types';
|
|
3
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A short status, coloured by its tone: "Active", "3 new", "Failed". A `dot` marks a live state; a `hint` says what
|
|
6
|
+
* the state means, as a tooltip. `showStatus()` takes the look of a state from an app's map of them.
|
|
7
|
+
*/
|
|
4
8
|
export declare class JlBadge extends JlElement {
|
|
5
9
|
static readonly selector = "jl-badge";
|
|
6
10
|
readonly label: Readonly<Readonly<{
|
|
@@ -24,7 +28,14 @@ export declare class JlBadge extends JlElement {
|
|
|
24
28
|
get(): boolean;
|
|
25
29
|
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
26
30
|
}>>;
|
|
31
|
+
/** What the state means, as a tooltip: "Waiting for logistics to prepare it." */
|
|
32
|
+
readonly hint: Readonly<Readonly<{
|
|
33
|
+
get(): string;
|
|
34
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
35
|
+
}>>;
|
|
27
36
|
private readonly _refs;
|
|
37
|
+
/** Shows a state as an app's map of states describes it: its label, tone, icon and hint. */
|
|
38
|
+
showStatus(look: StatusLook): void;
|
|
28
39
|
templateHtml(): Node;
|
|
29
40
|
templateCss(): string;
|
|
30
41
|
/** An icon wins over the dot: a badge shows one marker at most. */
|
package/dist/atoms/jl-badge.js
CHANGED
|
@@ -2,13 +2,17 @@ import { BASE_STYLES } from "../styles/shared.js";
|
|
|
2
2
|
import { JlElement } from "../base/jl-element.js";
|
|
3
3
|
import { oneOf } from "../lib/attributes.js";
|
|
4
4
|
import { TONES } from "../lib/options.js";
|
|
5
|
+
import { setOrRemove } from "../lib/dom.js";
|
|
5
6
|
import { JlIcon } from "./jl-icon.js";
|
|
6
7
|
import jl_badge_default from "./jl-badge.css_raw.js";
|
|
7
8
|
import { css } from "@jadis/core";
|
|
8
9
|
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
9
10
|
// src/atoms/jl-badge.tsx
|
|
10
11
|
var ICON_SIZE = 13;
|
|
11
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* A short status, coloured by its tone: "Active", "3 new", "Failed". A `dot` marks a live state; a `hint` says what
|
|
14
|
+
* the state means, as a tooltip. `showStatus()` takes the look of a state from an app's map of them.
|
|
15
|
+
*/
|
|
12
16
|
var JlBadge = class extends JlElement {
|
|
13
17
|
static selector = "jl-badge";
|
|
14
18
|
label = this.useChange("", (value) => {
|
|
@@ -22,11 +26,21 @@ var JlBadge = class extends JlElement {
|
|
|
22
26
|
dot = this.useChange(false, () => this.renderMarker(), { attribute: "dot" });
|
|
23
27
|
/** Filled with the tone's colour, for what must stand out. */
|
|
24
28
|
solid = this.useChange(false, (value) => this.reflect("solid", value), { attribute: "solid" });
|
|
29
|
+
/** What the state means, as a tooltip: "Waiting for logistics to prepare it." */
|
|
30
|
+
hint = this.useChange("", (value) => setOrRemove(this._refs.badge, "title", value), { attribute: "hint" });
|
|
25
31
|
_refs = this.useRefs((ref) => ({
|
|
32
|
+
badge: ref(".badge"),
|
|
26
33
|
dot: ref(".dot"),
|
|
27
34
|
icon: ref("jl-icon"),
|
|
28
35
|
label: ref(".label")
|
|
29
36
|
}));
|
|
37
|
+
/** Shows a state as an app's map of states describes it: its label, tone, icon and hint. */
|
|
38
|
+
showStatus(look) {
|
|
39
|
+
this.label.set(look.label);
|
|
40
|
+
this.tone.set(look.tone);
|
|
41
|
+
this.icon.set(look.icon ?? "");
|
|
42
|
+
this.hint.set(look.hint ?? "");
|
|
43
|
+
}
|
|
30
44
|
templateHtml() {
|
|
31
45
|
return /* @__PURE__ */ jsxs("span", {
|
|
32
46
|
class: "badge",
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { computePosition, followAnchor, PLACEMENTS, placeFloating } from './lib/
|
|
|
6
6
|
export { COMMON_ICONS } from './lib/icon-set';
|
|
7
7
|
export { hasIcon, iconElement, iconNames, registerIcons } from './lib/icons';
|
|
8
8
|
export { CONTROL_SIZES, TONE_ICON_FILLED, TONE_ICONS, TONES } from './lib/options';
|
|
9
|
+
export { formatDuration, formatRelativeTime } from './lib/time';
|
|
9
10
|
export { adoptTokens } from './lib/tokens';
|
|
10
11
|
export { BASE_STYLES, CONTROL_STYLES, FLOATING_STYLES, TOKEN_STYLES } from './styles/shared';
|
|
11
12
|
export type * from './types/calendar.types';
|
|
@@ -16,6 +17,7 @@ export type * from './types/highlight.types';
|
|
|
16
17
|
export type * from './types/hotkey.types';
|
|
17
18
|
export type * from './types/jl-accordion.types';
|
|
18
19
|
export type * from './types/jl-avatar.types';
|
|
20
|
+
export type * from './types/jl-badge.types';
|
|
19
21
|
export type * from './types/jl-breadcrumb.types';
|
|
20
22
|
export type * from './types/jl-button.types';
|
|
21
23
|
export type * from './types/jl-card.types';
|
|
@@ -32,8 +34,10 @@ export type * from './types/jl-field.types';
|
|
|
32
34
|
export type * from './types/jl-flow.types';
|
|
33
35
|
export type * from './types/jl-input.types';
|
|
34
36
|
export type * from './types/jl-link.types';
|
|
37
|
+
export type * from './types/jl-load-state.types';
|
|
35
38
|
export type * from './types/jl-menu.types';
|
|
36
39
|
export type * from './types/jl-navbar.types';
|
|
40
|
+
export type * from './types/jl-page.types';
|
|
37
41
|
export type * from './types/jl-progress.types';
|
|
38
42
|
export type * from './types/jl-radio-group.types';
|
|
39
43
|
export type * from './types/jl-segmented.types';
|
|
@@ -80,6 +84,7 @@ export * from './atoms/jl-switch';
|
|
|
80
84
|
export * from './atoms/jl-textarea';
|
|
81
85
|
export * from './molecules/jl-accordion-item';
|
|
82
86
|
export * from './molecules/jl-accordion';
|
|
87
|
+
export * from './molecules/jl-account-button';
|
|
83
88
|
export * from './molecules/jl-alert';
|
|
84
89
|
export * from './molecules/jl-avatar-group';
|
|
85
90
|
export * from './molecules/jl-breadcrumb';
|
|
@@ -94,11 +99,13 @@ export * from './molecules/jl-empty';
|
|
|
94
99
|
export * from './molecules/jl-field';
|
|
95
100
|
export * from './molecules/jl-file-drop';
|
|
96
101
|
export * from './molecules/jl-list-item';
|
|
102
|
+
export * from './molecules/jl-load-state';
|
|
97
103
|
export * from './molecules/jl-menu';
|
|
98
104
|
export * from './molecules/jl-number-input';
|
|
99
105
|
export * from './molecules/jl-pagination';
|
|
100
106
|
export * from './molecules/jl-popover';
|
|
101
107
|
export * from './molecules/jl-radio-group';
|
|
108
|
+
export * from './molecules/jl-search-button';
|
|
102
109
|
export * from './molecules/jl-search';
|
|
103
110
|
export * from './molecules/jl-segmented';
|
|
104
111
|
export * from './molecules/jl-stat';
|
|
@@ -122,4 +129,5 @@ export * from './organisms/jl-table';
|
|
|
122
129
|
export * from './organisms/jl-toaster';
|
|
123
130
|
export * from './organisms/jl-tree';
|
|
124
131
|
export * from './templates/jl-app-shell';
|
|
132
|
+
export * from './templates/jl-page';
|
|
125
133
|
export * from './templates/jl-split-view';
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { PLACEMENTS, computePosition, followAnchor, placeFloating } from "./lib/
|
|
|
8
8
|
import { COMMON_ICONS } from "./lib/icon-set.js";
|
|
9
9
|
import { hasIcon, iconElement, iconNames, registerIcons } from "./lib/icons.js";
|
|
10
10
|
import { CONTROL_SIZES, TONES, TONE_ICONS, TONE_ICON_FILLED } from "./lib/options.js";
|
|
11
|
+
import { formatDuration, formatRelativeTime } from "./lib/time.js";
|
|
11
12
|
import { JlIcon } from "./atoms/jl-icon.js";
|
|
12
13
|
import { AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, JlAvatar } from "./atoms/jl-avatar.js";
|
|
13
14
|
import { JlBadge } from "./atoms/jl-badge.js";
|
|
@@ -29,6 +30,7 @@ import { JlSwitch, SWITCH_SIZES } from "./atoms/jl-switch.js";
|
|
|
29
30
|
import { JlTextarea } from "./atoms/jl-textarea.js";
|
|
30
31
|
import { JlAccordionItem } from "./molecules/jl-accordion-item.js";
|
|
31
32
|
import { ACCORDION_VARIANTS, JlAccordion } from "./molecules/jl-accordion.js";
|
|
33
|
+
import { JlAccountButton } from "./molecules/jl-account-button.js";
|
|
32
34
|
import { JlAlert } from "./molecules/jl-alert.js";
|
|
33
35
|
import { JlAvatarGroup } from "./molecules/jl-avatar-group.js";
|
|
34
36
|
import { JlBreadcrumb } from "./molecules/jl-breadcrumb.js";
|
|
@@ -43,11 +45,13 @@ import { EMPTY_SIZES, JlEmpty } from "./molecules/jl-empty.js";
|
|
|
43
45
|
import { FIELD_ORIENTATIONS, JlField } from "./molecules/jl-field.js";
|
|
44
46
|
import { JlFileDrop } from "./molecules/jl-file-drop.js";
|
|
45
47
|
import { JlListItem } from "./molecules/jl-list-item.js";
|
|
48
|
+
import { JlLoadState, LOAD_SKELETONS, LOAD_STATES } from "./molecules/jl-load-state.js";
|
|
46
49
|
import { JlMenu } from "./molecules/jl-menu.js";
|
|
47
50
|
import { JlNumberInput } from "./molecules/jl-number-input.js";
|
|
48
51
|
import { JlPagination } from "./molecules/jl-pagination.js";
|
|
49
52
|
import { JlPopover } from "./molecules/jl-popover.js";
|
|
50
53
|
import { JlRadioGroup, RADIO_GROUP_ORIENTATIONS, RADIO_GROUP_VARIANTS } from "./molecules/jl-radio-group.js";
|
|
54
|
+
import { JlSearchButton } from "./molecules/jl-search-button.js";
|
|
51
55
|
import { JlSearch } from "./molecules/jl-search.js";
|
|
52
56
|
import { JlSegmented } from "./molecules/jl-segmented.js";
|
|
53
57
|
import { JlStat, STAT_TRENDS } from "./molecules/jl-stat.js";
|
|
@@ -60,7 +64,7 @@ import { JlToast, TOAST_TONES } from "./molecules/jl-toast.js";
|
|
|
60
64
|
import { JlTooltip } from "./molecules/jl-tooltip.js";
|
|
61
65
|
import { JlCommandPalette } from "./organisms/jl-command-palette.js";
|
|
62
66
|
import { DIALOG_SIZES, JlDialog } from "./organisms/jl-dialog.js";
|
|
63
|
-
import { CONFIRM_TONES, JlConfirm, confirmDialog } from "./organisms/jl-confirm.js";
|
|
67
|
+
import { CONFIRM_TONES, JlConfirm, confirmDialog, guardLeave } from "./organisms/jl-confirm.js";
|
|
64
68
|
import { DRAWER_PLACEMENTS, DRAWER_SIZES, JlDrawer } from "./organisms/jl-drawer.js";
|
|
65
69
|
import { JlFlow } from "./organisms/jl-flow.js";
|
|
66
70
|
import { JlNavbar } from "./organisms/jl-navbar.js";
|
|
@@ -71,5 +75,6 @@ import { JlTable, TABLE_SORT_DIRECTIONS } from "./organisms/jl-table.js";
|
|
|
71
75
|
import { JlToaster, TOASTER_PLACEMENTS, toast } from "./organisms/jl-toaster.js";
|
|
72
76
|
import { JlTree } from "./organisms/jl-tree.js";
|
|
73
77
|
import { JlAppShell } from "./templates/jl-app-shell.js";
|
|
78
|
+
import { JlPage, PAGE_WIDTHS } from "./templates/jl-page.js";
|
|
74
79
|
import { JlSplitView, SPLIT_ORIENTATIONS } from "./templates/jl-split-view.js";
|
|
75
|
-
export { ACCORDION_VARIANTS, AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, BASE_STYLES, BUTTON_TYPES, BUTTON_VARIANTS, CARD_PADDINGS, CHIP_SIZES, CODE_LANGUAGES, COMMON_ICONS, CONFIRM_TONES, CONTROL_SIZES, CONTROL_STYLES, DIALOG_SIZES, DIVIDER_ALIGNS, DRAWER_PLACEMENTS, DRAWER_SIZES, EMPTY_SIZES, FIELD_ORIENTATIONS, FLOATING_STYLES, INPUT_TYPES, JlAccordion, JlAccordionItem, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlElement, JlEmpty, JlField, JlFileDrop, JlFlow, 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, JlTabBar, 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, TONE_ICON_FILLED, adoptTokens, clampedNumber, computePosition, confirmDialog, define, followAnchor, hasIcon, iconElement, iconNames, jsonOf, oneOf, placeFloating, registerIcons, toast };
|
|
80
|
+
export { ACCORDION_VARIANTS, AVATAR_SHAPES, AVATAR_SIZES, AVATAR_STATUSES, BASE_STYLES, BUTTON_TYPES, BUTTON_VARIANTS, CARD_PADDINGS, CHIP_SIZES, CODE_LANGUAGES, COMMON_ICONS, CONFIRM_TONES, CONTROL_SIZES, CONTROL_STYLES, DIALOG_SIZES, DIVIDER_ALIGNS, DRAWER_PLACEMENTS, DRAWER_SIZES, EMPTY_SIZES, FIELD_ORIENTATIONS, FLOATING_STYLES, INPUT_TYPES, JlAccordion, JlAccordionItem, JlAccountButton, JlAlert, JlAppShell, JlAvatar, JlAvatarGroup, JlBadge, JlBreadcrumb, JlButton, JlCalendar, JlCard, JlCheckbox, JlChip, JlChipGroup, JlCodeBlock, JlCombobox, JlCommandPalette, JlConfirm, JlCopyButton, JlDatePicker, JlDialog, JlDivider, JlDrawer, JlElement, JlEmpty, JlField, JlFileDrop, JlFlow, JlFormControl, JlIcon, JlInput, JlKbd, JlLink, JlListItem, JlLoadState, JlMenu, JlNavbar, JlNumberInput, JlPage, JlPageHeader, JlPagination, JlPopover, JlProgress, JlProgressRing, JlRadioGroup, JlRating, JlSearch, JlSearchButton, JlSegmented, JlSelect, JlSideNav, JlSkeleton, JlSlider, JlSpinner, JlSplitView, JlStat, JlSteps, JlSwitch, JlTabBar, JlTabPanel, JlTable, JlTabs, JlTagInput, JlTextarea, JlTimeline, JlToast, JlToaster, JlTooltip, JlTree, LINK_VARIANTS, LOAD_SKELETONS, LOAD_STATES, PAGE_WIDTHS, 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, TONE_ICON_FILLED, adoptTokens, clampedNumber, computePosition, confirmDialog, define, followAnchor, formatDuration, formatRelativeTime, guardLeave, hasIcon, iconElement, iconNames, jsonOf, oneOf, placeFloating, registerIcons, toast };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A duration in the units that read best: "< 1 sec" under a second (never "0.0 s"), then seconds, minutes, hours
|
|
3
|
+
* and minutes, days and hours.
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatDuration(milliseconds: number, locale?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* When something happened, from `now`: "now", "5 minutes ago", "3 hours ago", "yesterday" within a week, then the
|
|
8
|
+
* date ("12 Mar", with the year when it is not this year's). Times to come read the same way: "in 5 minutes".
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatRelativeTime(date: Date | number | string, now: Date | number, locale?: string): string;
|
package/dist/lib/time.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/lib/time.ts
|
|
2
|
+
var SECOND_MS = 1e3;
|
|
3
|
+
var MINUTES_PER_HOUR = 60;
|
|
4
|
+
var HOURS_PER_DAY = 24;
|
|
5
|
+
var MINUTE_S = 60;
|
|
6
|
+
var HOUR_S = 3600;
|
|
7
|
+
var DAY_S = HOURS_PER_DAY * HOUR_S;
|
|
8
|
+
var NOW_UNDER_S = 45;
|
|
9
|
+
var MINUTES_UNDER_S = 2700;
|
|
10
|
+
var HOURS_UNDER_S = 22 * HOUR_S;
|
|
11
|
+
var DAYS_UNDER_S = 7 * DAY_S;
|
|
12
|
+
/** A number of one unit, as the language writes it short: "33 secs", "3 min", "2 Std.". */
|
|
13
|
+
var unitText = (value, unit, locale) => new Intl.NumberFormat(locale, {
|
|
14
|
+
maximumFractionDigits: 0,
|
|
15
|
+
style: "unit",
|
|
16
|
+
unit,
|
|
17
|
+
unitDisplay: "short"
|
|
18
|
+
}).format(value);
|
|
19
|
+
/** Two units side by side, the second left out at zero: "2 hrs 10 mins", "3 days". */
|
|
20
|
+
function pair(first, second, locale) {
|
|
21
|
+
const parts = [unitText(first[0], first[1], locale)];
|
|
22
|
+
if (second[0] > 0) parts.push(unitText(second[0], second[1], locale));
|
|
23
|
+
return new Intl.ListFormat(locale, {
|
|
24
|
+
style: "narrow",
|
|
25
|
+
type: "unit"
|
|
26
|
+
}).format(parts);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A duration in the units that read best: "< 1 sec" under a second (never "0.0 s"), then seconds, minutes, hours
|
|
30
|
+
* and minutes, days and hours.
|
|
31
|
+
*/
|
|
32
|
+
function formatDuration(milliseconds, locale) {
|
|
33
|
+
const seconds = Math.max(0, milliseconds) / SECOND_MS;
|
|
34
|
+
if (seconds < 1) return `< ${unitText(1, "second", locale)}`;
|
|
35
|
+
if (seconds < MINUTE_S) return unitText(Math.round(seconds), "second", locale);
|
|
36
|
+
if (seconds < HOUR_S) return unitText(Math.round(seconds / MINUTE_S), "minute", locale);
|
|
37
|
+
if (seconds < DAY_S) {
|
|
38
|
+
const minutes = Math.round(seconds / MINUTE_S);
|
|
39
|
+
return pair([Math.floor(minutes / MINUTES_PER_HOUR), "hour"], [minutes % MINUTES_PER_HOUR, "minute"], locale);
|
|
40
|
+
}
|
|
41
|
+
const hours = Math.round(seconds / HOUR_S);
|
|
42
|
+
return pair([Math.floor(hours / HOURS_PER_DAY), "day"], [hours % HOURS_PER_DAY, "hour"], locale);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* When something happened, from `now`: "now", "5 minutes ago", "3 hours ago", "yesterday" within a week, then the
|
|
46
|
+
* date ("12 Mar", with the year when it is not this year's). Times to come read the same way: "in 5 minutes".
|
|
47
|
+
*/
|
|
48
|
+
function formatRelativeTime(date, now, locale) {
|
|
49
|
+
const then = new Date(date);
|
|
50
|
+
const seconds = (then.getTime() - new Date(now).getTime()) / SECOND_MS;
|
|
51
|
+
const distance = Math.abs(seconds);
|
|
52
|
+
const relative = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
53
|
+
if (distance < NOW_UNDER_S) return relative.format(0, "second");
|
|
54
|
+
if (distance < MINUTES_UNDER_S) return relative.format(Math.round(seconds / MINUTE_S), "minute");
|
|
55
|
+
if (distance < HOURS_UNDER_S) return relative.format(Math.round(seconds / HOUR_S), "hour");
|
|
56
|
+
if (distance < DAYS_UNDER_S) return relative.format(Math.round(seconds / DAY_S), "day");
|
|
57
|
+
const sameYear = then.getFullYear() === new Date(now).getFullYear();
|
|
58
|
+
return new Intl.DateTimeFormat(locale, {
|
|
59
|
+
day: "numeric",
|
|
60
|
+
month: "short",
|
|
61
|
+
...sameYear ? {} : { year: "numeric" }
|
|
62
|
+
}).format(then);
|
|
63
|
+
}
|
|
64
|
+
export { formatDuration, formatRelativeTime };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/molecules/jl-account-button.css?raw
|
|
2
|
+
var jl_account_button_default = ":host {\n display: block;\n}\n\n.base {\n display: flex;\n width: 100%;\n padding: 6px 8px;\n border: 0;\n border-radius: var(--jl-radius-sm);\n background: transparent;\n color: var(--jl-text);\n text-align: left;\n text-decoration: none;\n cursor: pointer;\n transition: background var(--jl-fast) var(--jl-ease);\n}\n\n.base:hover {\n background: var(--jl-surface-2);\n}\n\n.content {\n display: flex;\n flex: 1;\n align-items: center;\n gap: 10px;\n min-width: 0;\n}\n\njl-avatar {\n flex: none;\n}\n\n.text {\n display: grid;\n min-width: 0;\n line-height: 1.3;\n}\n\n.name,\n.description {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.name {\n font-size: var(--jl-font-sm);\n font-weight: 650;\n}\n\n.description {\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n/* The avatar alone, round. */\n:host([compact]) {\n display: inline-block;\n}\n\n:host([compact]) .base {\n width: auto;\n padding: 2px;\n border-radius: var(--jl-radius-pill);\n}\n\n:host([compact]) .text {\n display: none;\n}\n";
|
|
3
|
+
export { jl_account_button_default as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JlElement } from '../base/jl-element';
|
|
2
|
+
/**
|
|
3
|
+
* The person signed in, where the frame of an app shows them (the foot of the side nav, a phone's top bar): their
|
|
4
|
+
* avatar, their name, and a line under it such as their role. With an `href` it is a link to their account, else a
|
|
5
|
+
* button that fires `press` (to open a menu). `compact` keeps the avatar alone, the name as its tooltip.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JlAccountButton extends JlElement {
|
|
8
|
+
static readonly selector = "jl-account-button";
|
|
9
|
+
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
10
|
+
press: undefined;
|
|
11
|
+
}>>;
|
|
12
|
+
readonly name: Readonly<Readonly<{
|
|
13
|
+
get(): string;
|
|
14
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
15
|
+
}>>;
|
|
16
|
+
/** The line under the name: their role, their company. */
|
|
17
|
+
readonly description: Readonly<Readonly<{
|
|
18
|
+
get(): string;
|
|
19
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
20
|
+
}>>;
|
|
21
|
+
/** Their picture; their initials without it. */
|
|
22
|
+
readonly src: Readonly<Readonly<{
|
|
23
|
+
get(): string;
|
|
24
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
25
|
+
}>>;
|
|
26
|
+
/** Their account's address: the button becomes a link. */
|
|
27
|
+
readonly href: Readonly<Readonly<{
|
|
28
|
+
get(): string;
|
|
29
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
30
|
+
}>>;
|
|
31
|
+
/** The avatar alone. */
|
|
32
|
+
readonly compact: Readonly<Readonly<{
|
|
33
|
+
get(): boolean;
|
|
34
|
+
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
35
|
+
}>>;
|
|
36
|
+
private readonly _refs;
|
|
37
|
+
focus(options?: FocusOptions): void;
|
|
38
|
+
templateHtml(): Node;
|
|
39
|
+
templateCss(): string;
|
|
40
|
+
onConnect(): void;
|
|
41
|
+
private control;
|
|
42
|
+
/** Moves the content into the link or back into the button. */
|
|
43
|
+
private renderLink;
|
|
44
|
+
/** Its name for screen readers and its tooltip: the name, then the line under it. */
|
|
45
|
+
private renderLabel;
|
|
46
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
|
+
import { JlElement } from "../base/jl-element.js";
|
|
3
|
+
import { setOrRemove } from "../lib/dom.js";
|
|
4
|
+
import { JlAvatar } from "../atoms/jl-avatar.js";
|
|
5
|
+
import jl_account_button_default from "./jl-account-button.css_raw.js";
|
|
6
|
+
import { css } from "@jadis/core";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
8
|
+
// src/molecules/jl-account-button.tsx
|
|
9
|
+
/**
|
|
10
|
+
* The person signed in, where the frame of an app shows them (the foot of the side nav, a phone's top bar): their
|
|
11
|
+
* avatar, their name, and a line under it such as their role. With an `href` it is a link to their account, else a
|
|
12
|
+
* button that fires `press` (to open a menu). `compact` keeps the avatar alone, the name as its tooltip.
|
|
13
|
+
*/
|
|
14
|
+
var JlAccountButton = class extends JlElement {
|
|
15
|
+
static selector = "jl-account-button";
|
|
16
|
+
events = this.useEvents();
|
|
17
|
+
name = this.useChange("", (value) => {
|
|
18
|
+
this._refs.avatar.name.set(value);
|
|
19
|
+
this._refs.name.textContent = value;
|
|
20
|
+
this.renderLabel();
|
|
21
|
+
}, { attribute: "name" });
|
|
22
|
+
/** The line under the name: their role, their company. */
|
|
23
|
+
description = this.useChange("", (value) => {
|
|
24
|
+
this._refs.description.textContent = value;
|
|
25
|
+
this._refs.description.hidden = value === "";
|
|
26
|
+
this.renderLabel();
|
|
27
|
+
}, { attribute: "description" });
|
|
28
|
+
/** Their picture; their initials without it. */
|
|
29
|
+
src = this.useChange("", (value) => this._refs.avatar.src.set(value), { attribute: "src" });
|
|
30
|
+
/** Their account's address: the button becomes a link. */
|
|
31
|
+
href = this.useChange("", () => this.renderLink(), { attribute: "href" });
|
|
32
|
+
/** The avatar alone. */
|
|
33
|
+
compact = this.useChange(false, (value) => this.reflect("compact", value), { attribute: "compact" });
|
|
34
|
+
_refs = this.useRefs((ref) => ({
|
|
35
|
+
avatar: ref("jl-avatar"),
|
|
36
|
+
button: ref("button"),
|
|
37
|
+
content: ref(".content"),
|
|
38
|
+
description: ref(".description"),
|
|
39
|
+
link: ref("a"),
|
|
40
|
+
name: ref(".name")
|
|
41
|
+
}));
|
|
42
|
+
focus(options) {
|
|
43
|
+
this.control().focus(options);
|
|
44
|
+
}
|
|
45
|
+
templateHtml() {
|
|
46
|
+
const avatar = /* @__PURE__ */ jsx(JlAvatar, { size: "md" });
|
|
47
|
+
avatar.setAttribute("aria-hidden", "true");
|
|
48
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
49
|
+
type: "button",
|
|
50
|
+
class: "base",
|
|
51
|
+
attrs: { part: "base" },
|
|
52
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
53
|
+
class: "content",
|
|
54
|
+
children: [avatar, /* @__PURE__ */ jsxs("span", {
|
|
55
|
+
class: "text",
|
|
56
|
+
children: [/* @__PURE__ */ jsx("span", { class: "name" }), /* @__PURE__ */ jsx("span", {
|
|
57
|
+
class: "description",
|
|
58
|
+
hidden: true
|
|
59
|
+
})]
|
|
60
|
+
})]
|
|
61
|
+
})
|
|
62
|
+
}), /* @__PURE__ */ jsx("a", {
|
|
63
|
+
class: "base",
|
|
64
|
+
hidden: true,
|
|
65
|
+
attrs: { part: "base" }
|
|
66
|
+
})] });
|
|
67
|
+
}
|
|
68
|
+
templateCss() {
|
|
69
|
+
return css`${BASE_STYLES}${jl_account_button_default}`;
|
|
70
|
+
}
|
|
71
|
+
onConnect() {
|
|
72
|
+
this.on(this._refs.button, "click", () => this.events.emit("press"));
|
|
73
|
+
this.on(this._refs.link, "click", () => this.events.emit("press"));
|
|
74
|
+
}
|
|
75
|
+
control() {
|
|
76
|
+
return this.href.get() === "" ? this._refs.button : this._refs.link;
|
|
77
|
+
}
|
|
78
|
+
/** Moves the content into the link or back into the button. */
|
|
79
|
+
renderLink() {
|
|
80
|
+
const { button, content, link } = this._refs;
|
|
81
|
+
const href = this.href.get();
|
|
82
|
+
this.control().append(content);
|
|
83
|
+
button.hidden = href !== "";
|
|
84
|
+
link.hidden = href === "";
|
|
85
|
+
setOrRemove(link, "href", href);
|
|
86
|
+
}
|
|
87
|
+
/** Its name for screen readers and its tooltip: the name, then the line under it. */
|
|
88
|
+
renderLabel() {
|
|
89
|
+
const label = [this.name.get(), this.description.get()].filter((part) => part !== "").join(", ");
|
|
90
|
+
for (const control of [this._refs.button, this._refs.link]) {
|
|
91
|
+
setOrRemove(control, "title", this.name.get());
|
|
92
|
+
setOrRemove(control, "aria-label", label);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
JlAccountButton.register();
|
|
97
|
+
export { JlAccountButton };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/molecules/jl-load-state.css?raw
|
|
2
|
+
var jl_load_state_default = ":host {\n display: block;\n}\n\n.bones {\n display: grid;\n gap: 16px;\n padding: 16px;\n}\n\n.bones.lines {\n gap: 10px;\n}\n\n.bones.cards {\n grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));\n gap: 12px;\n padding: 0;\n}\n\n.bone-row {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n\n.bone-lines {\n display: grid;\n flex: 1;\n gap: 6px;\n}\n\n.bone-card {\n display: grid;\n gap: 8px;\n padding: 12px;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius-lg);\n}\n";
|
|
3
|
+
export { jl_load_state_default as default };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { JlElement } from '../base/jl-element';
|
|
2
|
+
import type { LoadSkeleton, LoadState, LoadTask } from '../types/jl-load-state.types';
|
|
3
|
+
export declare const LOAD_STATES: readonly LoadState[];
|
|
4
|
+
export declare const LOAD_SKELETONS: readonly LoadSkeleton[];
|
|
5
|
+
/**
|
|
6
|
+
* What a list or a page shows while its data comes: nothing for a moment, then a skeleton shaped like it; then the
|
|
7
|
+
* data (the default slot), what to say when there is none (slot `empty`, a `jl-empty`), or, when it failed, what
|
|
8
|
+
* failed and Try again. `load()` fetches, draws and moves between the states; a later `load()` keeps what is shown
|
|
9
|
+
* until the new data is there, so live updates do not flash. Or set `state` yourself.
|
|
10
|
+
*/
|
|
11
|
+
export declare class JlLoadState extends JlElement {
|
|
12
|
+
static readonly selector = "jl-load-state";
|
|
13
|
+
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
14
|
+
retry: undefined;
|
|
15
|
+
}>>;
|
|
16
|
+
readonly state: Readonly<Readonly<{
|
|
17
|
+
get(): LoadState;
|
|
18
|
+
set(setter: ((prevState: LoadState) => LoadState) | LoadState): void;
|
|
19
|
+
}>>;
|
|
20
|
+
/** The shape of the skeleton; slot `loading` takes one of the page's own instead. */
|
|
21
|
+
readonly skeleton: Readonly<Readonly<{
|
|
22
|
+
get(): LoadSkeleton;
|
|
23
|
+
set(setter: ((prevState: LoadSkeleton) => LoadSkeleton) | LoadSkeleton): void;
|
|
24
|
+
}>>;
|
|
25
|
+
/** How many rows, cards or lines the skeleton has. */
|
|
26
|
+
readonly count: Readonly<Readonly<{
|
|
27
|
+
get(): number;
|
|
28
|
+
set(setter: number | ((prevState: number) => number)): void;
|
|
29
|
+
}>>;
|
|
30
|
+
/** Milliseconds before the skeleton shows. */
|
|
31
|
+
readonly delay: Readonly<Readonly<{
|
|
32
|
+
get(): number;
|
|
33
|
+
set(setter: number | ((prevState: number) => number)): void;
|
|
34
|
+
}>>;
|
|
35
|
+
readonly errorHeading: Readonly<Readonly<{
|
|
36
|
+
get(): string;
|
|
37
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
38
|
+
}>>;
|
|
39
|
+
readonly errorText: Readonly<Readonly<{
|
|
40
|
+
get(): string;
|
|
41
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
42
|
+
}>>;
|
|
43
|
+
readonly retryLabel: Readonly<Readonly<{
|
|
44
|
+
get(): string;
|
|
45
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
46
|
+
}>>;
|
|
47
|
+
private readonly _work;
|
|
48
|
+
private readonly _refs;
|
|
49
|
+
/**
|
|
50
|
+
* Fetches the data and draws it. The first time, and after a failure, the skeleton shows while it comes; later
|
|
51
|
+
* (a refresh), what is shown stays until the new data is there, and stays too if it fails. Resolves to whether it
|
|
52
|
+
* worked: a refresh that fails says so only here, for the page to tell people.
|
|
53
|
+
*/
|
|
54
|
+
load<Value>(task: LoadTask<Value>): Promise<boolean>;
|
|
55
|
+
templateHtml(): Node;
|
|
56
|
+
templateCss(): string;
|
|
57
|
+
onConnect(): void;
|
|
58
|
+
onDisconnect(): void;
|
|
59
|
+
private renderState;
|
|
60
|
+
private renderSkeleton;
|
|
61
|
+
}
|