seblify 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +145 -49
  2. package/dist/components/AppShell.svelte +1 -1
  3. package/dist/components/Banner.svelte +3 -3
  4. package/dist/components/Button.svelte +4 -4
  5. package/dist/components/action/button/button/Button.svelte +1041 -0
  6. package/dist/components/action/button/button/Button.svelte.d.ts +28 -0
  7. package/dist/components/action/button/button-group/ButtonGroup.svelte +146 -0
  8. package/dist/components/action/button/button-group/ButtonGroup.svelte.d.ts +14 -0
  9. package/dist/components/action/button/floating-action-button/FloatingActionButton.svelte +1102 -0
  10. package/dist/components/action/button/floating-action-button/FloatingActionButton.svelte.d.ts +26 -0
  11. package/dist/components/action/button/icon-button/IconButton.svelte +954 -0
  12. package/dist/components/action/button/icon-button/IconButton.svelte.d.ts +22 -0
  13. package/dist/components/action/button/timed-button/TimedButton.svelte +1143 -0
  14. package/dist/components/action/button/timed-button/TimedButton.svelte.d.ts +32 -0
  15. package/dist/components/action/button/toggle-button/ToggleButton.svelte +1109 -0
  16. package/dist/components/action/button/toggle-button/ToggleButton.svelte.d.ts +28 -0
  17. package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.svelte +242 -0
  18. package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.svelte.d.ts +19 -0
  19. package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.test.svelte +36 -0
  20. package/dist/components/action/button/toggle-button-group/ToggleButtonGroup.test.svelte.d.ts +11 -0
  21. package/dist/components/action/button/toggle-button-group/context.d.ts +8 -0
  22. package/dist/components/action/button/toggle-button-group/context.js +8 -0
  23. package/dist/components/action/input/field/pin-input/PinInput.svelte +4 -4
  24. package/dist/components/action/input/select/checkbox/Checkbox.svelte +4704 -25
  25. package/dist/components/action/input/select/checkbox/Checkbox.svelte.d.ts +28 -0
  26. package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.d.ts +46 -0
  27. package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.js +202 -0
  28. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.d.ts +1 -0
  29. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.html +27 -0
  30. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bounce.js +13 -0
  31. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.d.ts +1 -0
  32. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.html +12 -0
  33. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/bump.js +13 -0
  34. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.d.ts +1 -0
  35. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.html +12 -0
  36. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/draw.js +12 -0
  37. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.d.ts +1 -0
  38. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.html +12 -0
  39. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/fade.js +12 -0
  40. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.d.ts +1 -0
  41. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.html +12 -0
  42. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/pop.js +13 -0
  43. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.d.ts +1 -0
  44. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.html +27 -0
  45. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/rise.js +13 -0
  46. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.d.ts +1 -0
  47. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.html +27 -0
  48. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/scale.js +13 -0
  49. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.d.ts +1 -0
  50. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.html +12 -0
  51. package/dist/components/action/input/select/checkbox/tests/visual-fixtures/visual-state.js +278 -0
  52. package/dist/components/action/input/select/{theme-switch/ThemeSwitch.svelte → color-mode-switch/ColorModeSwitch.svelte} +8 -8
  53. package/dist/components/action/input/select/color-mode-switch/ColorModeSwitch.svelte.d.ts +10 -0
  54. package/dist/components/action/input/select/segment-control/SegmentControl.svelte +2 -2
  55. package/dist/components/action/input/select/slider/Slider.svelte +1 -1
  56. package/dist/components/action/input/select/switch/Switch.svelte +1004 -99
  57. package/dist/components/action/input/select/switch/Switch.svelte.d.ts +8 -3
  58. package/dist/components/display/annotation/badge/Badge.svelte +732 -63
  59. package/dist/components/display/annotation/badge/Badge.svelte.d.ts +1 -1
  60. package/dist/components/display/annotation/tag/Tag.svelte +670 -58
  61. package/dist/components/display/annotation/tag/Tag.svelte.d.ts +3 -1
  62. package/dist/components/display/data-display/metric/date-time/DateTimeValue.svelte +59 -0
  63. package/dist/components/display/data-display/metric/date-time/DateTimeValue.svelte.d.ts +13 -0
  64. package/dist/components/display/data-display/metric/date-time/DateValue.svelte +52 -0
  65. package/dist/components/display/data-display/metric/date-time/DateValue.svelte.d.ts +11 -0
  66. package/dist/components/display/data-display/metric/date-time/TimeValue.svelte +55 -0
  67. package/dist/components/display/data-display/metric/date-time/TimeValue.svelte.d.ts +12 -0
  68. package/dist/components/display/data-display/metric/duration/Duration.svelte +64 -0
  69. package/dist/components/display/data-display/metric/duration/Duration.svelte.d.ts +16 -0
  70. package/dist/components/display/data-display/metric/relative-time/RelativeTime.svelte +121 -0
  71. package/dist/components/display/data-display/metric/relative-time/RelativeTime.svelte.d.ts +21 -0
  72. package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte +121 -0
  73. package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte.d.ts +25 -0
  74. package/dist/components/display/data-display/visual/timeline/TimelineItem.svelte +660 -51
  75. package/dist/components/display/data-display/visual/timeline/context.d.ts +1 -1
  76. package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte +657 -48
  77. package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte.d.ts +1 -1
  78. package/dist/components/display/feedback/loading/spinner/Spinner.svelte +657 -48
  79. package/dist/components/display/feedback/loading/spinner/Spinner.svelte.d.ts +1 -1
  80. package/dist/components/display/motion/collapse/Collapse.svelte +115 -0
  81. package/dist/components/display/motion/collapse/Collapse.svelte.d.ts +17 -0
  82. package/dist/components/display/typography/accordion/Accordion.svelte +347 -0
  83. package/dist/components/display/typography/accordion/Accordion.svelte.d.ts +13 -0
  84. package/dist/components/display/typography/accordion/AccordionGroup.svelte +132 -0
  85. package/dist/components/display/typography/accordion/AccordionGroup.svelte.d.ts +11 -0
  86. package/dist/components/display/typography/accordion/context.d.ts +8 -0
  87. package/dist/components/display/typography/accordion/context.js +8 -0
  88. package/dist/components/display/typography/code-snippet/CodeSnippet.svelte +3 -3
  89. package/dist/components/display/typography/eyebrow/Eyebrow.svelte +2 -2
  90. package/dist/components/display/typography/highlight/Highlight.svelte +719 -59
  91. package/dist/components/display/typography/highlight/Highlight.svelte.d.ts +1 -1
  92. package/dist/components/framework/layout/container/app-shell/AppShell.svelte +16 -2
  93. package/dist/components/framework/navigation/context/breadcrumb/Breadcrumb.svelte +1 -1
  94. package/dist/components/framework/navigation/sidebar/sidebar/Sidebar.svelte +35 -10
  95. package/dist/components/framework/navigation/sidebar/sidenav/Sidenav.svelte +5 -5
  96. package/dist/components/framework/overlay/tooltip/Tooltip.svelte +1011 -0
  97. package/dist/components/framework/overlay/tooltip/Tooltip.svelte.d.ts +31 -0
  98. package/dist/components/framework/surface/paper/Paper.svelte +730 -87
  99. package/dist/components/framework/surface/paper/Paper.svelte.d.ts +1 -1
  100. package/dist/components/utility/format/date-time/formatDateTime.d.ts +23 -0
  101. package/dist/components/utility/format/date-time/formatDateTime.js +33 -0
  102. package/dist/components/utility/format/duration/formatDuration.d.ts +15 -0
  103. package/dist/components/utility/format/duration/formatDuration.js +218 -0
  104. package/dist/components/utility/format/relative-time/formatRelativeTime.d.ts +42 -0
  105. package/dist/components/utility/format/relative-time/formatRelativeTime.js +530 -0
  106. package/dist/design-system/inheritance/tokens.js +6 -0
  107. package/dist/design-system/reserved-props/allowed-options.d.ts +9 -4
  108. package/dist/design-system/theme/tokens.d.ts +72 -2
  109. package/dist/design-system/theme/tokens.js +173 -134
  110. package/dist/icons/generated/check-thick.svelte +16 -0
  111. package/dist/icons/generated/check-thick.svelte.d.ts +7 -0
  112. package/dist/icons/generated/check.svelte +16 -0
  113. package/dist/icons/generated/check.svelte.d.ts +7 -0
  114. package/dist/icons/generated/close-thick.svelte +16 -0
  115. package/dist/icons/generated/close-thick.svelte.d.ts +7 -0
  116. package/dist/icons/generated/close.svelte +16 -0
  117. package/dist/icons/generated/close.svelte.d.ts +7 -0
  118. package/dist/icons/generated/index.d.ts +4 -0
  119. package/dist/icons/generated/index.js +4 -0
  120. package/dist/icons/generated/manifest.js +28 -0
  121. package/dist/index.d.ts +22 -2
  122. package/dist/index.js +22 -2
  123. package/dist/styles/tone-context.css +656 -46
  124. package/dist/theme.css +1 -161
  125. package/dist/themes/canopy.css +373 -0
  126. package/dist/themes/cobalt.css +373 -0
  127. package/dist/themes/iris.css +373 -0
  128. package/dist/themes/lumen.css +373 -0
  129. package/dist/themes/mono.css +373 -0
  130. package/dist/themes/moss.css +373 -0
  131. package/dist/themes/noir.css +373 -0
  132. package/dist/themes/plain.css +373 -0
  133. package/dist/themes/pulse.css +373 -0
  134. package/dist/themes/signal.css +373 -0
  135. package/dist/themes/slate.css +373 -0
  136. package/dist/themes/solar.css +373 -0
  137. package/dist/themes/sorbet.css +373 -0
  138. package/dist/themes/studio.css +369 -0
  139. package/dist/themes/vesper.css +373 -0
  140. package/package.json +32 -4
  141. package/dist/components/action/input/select/theme-switch/ThemeSwitch.svelte.d.ts +0 -10
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  type TagBorder = 'none' | 'solid' | 'dash';
3
3
  type TagRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
4
- type TagTone = 'neutral' | 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'inverse';
4
+ type TagTone = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
5
+ type TagSurface = 'default' | 'inverse';
5
6
  type TagVariant = 'solid' | 'soft' | 'tint' | 'plain';
6
7
  declare const Tag: import("svelte").Component<{
7
8
  border?: TagBorder | undefined;
@@ -9,6 +10,7 @@ declare const Tag: import("svelte").Component<{
9
10
  end?: Snippet | undefined;
10
11
  radius?: TagRadius | undefined;
11
12
  start?: Snippet | undefined;
13
+ surface?: TagSurface | undefined;
12
14
  tone?: TagTone | undefined;
13
15
  variant?: TagVariant | undefined;
14
16
  }, {}, "">;
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DateTimeDateStyle,
4
+ DateTimeInput,
5
+ DateTimeTimeStyle,
6
+ FormatDateTimeOptions,
7
+ } from '../../../../utility/format/date-time/formatDateTime';
8
+ import {
9
+ dateTimeIsoString,
10
+ formatDateTime,
11
+ } from '../../../../utility/format/date-time/formatDateTime';
12
+ import type { SeblifyProps } from 'seblify';
13
+
14
+ type Props = SeblifyProps<{
15
+ [key: string]: unknown;
16
+ class?: string;
17
+ dateStyle?: DateTimeDateStyle;
18
+ hour12?: boolean;
19
+ locale?: Intl.LocalesArgument;
20
+ timestamp: DateTimeInput;
21
+ timeStyle?: DateTimeTimeStyle;
22
+ timeZone?: string;
23
+ }>;
24
+
25
+ let {
26
+ class: className,
27
+ dateStyle = 'medium',
28
+ hour12,
29
+ locale,
30
+ timestamp,
31
+ timeStyle = 'short',
32
+ timeZone,
33
+ ...restProps
34
+ }: Props = $props();
35
+
36
+ const formatterOptions = $derived<FormatDateTimeOptions>({
37
+ dateStyle,
38
+ hour12,
39
+ locale,
40
+ timeStyle,
41
+ timeZone,
42
+ });
43
+ const text = $derived(formatDateTime(timestamp, formatterOptions));
44
+ const dateTime = $derived(dateTimeIsoString(timestamp));
45
+ </script>
46
+
47
+ <time
48
+ {...restProps}
49
+ class={`date-time-value${className ? ` ${className}` : ''}`}
50
+ datetime={dateTime}
51
+ >
52
+ {text}
53
+ </time>
54
+
55
+ <style>
56
+ .date-time-value {
57
+ white-space: nowrap;
58
+ }
59
+ </style>
@@ -0,0 +1,13 @@
1
+ import type { DateTimeDateStyle, DateTimeInput, DateTimeTimeStyle } from '../../../../utility/format/date-time/formatDateTime';
2
+ declare const DateTimeValue: import("svelte").Component<{
3
+ [x: string]: unknown;
4
+ class?: string | undefined;
5
+ dateStyle?: DateTimeDateStyle | undefined;
6
+ hour12?: boolean | undefined;
7
+ locale?: Intl.LocalesArgument;
8
+ timestamp: DateTimeInput;
9
+ timeStyle?: DateTimeTimeStyle | undefined;
10
+ timeZone?: string | undefined;
11
+ }, {}, "">;
12
+ type DateTimeValue = ReturnType<typeof DateTimeValue>;
13
+ export default DateTimeValue;
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DateTimeDateStyle,
4
+ DateTimeInput,
5
+ FormatDateOptions,
6
+ } from '../../../../utility/format/date-time/formatDateTime';
7
+ import {
8
+ dateTimeIsoString,
9
+ formatDate,
10
+ } from '../../../../utility/format/date-time/formatDateTime';
11
+ import type { SeblifyProps } from 'seblify';
12
+
13
+ type Props = SeblifyProps<{
14
+ [key: string]: unknown;
15
+ class?: string;
16
+ dateStyle?: DateTimeDateStyle;
17
+ locale?: Intl.LocalesArgument;
18
+ timestamp: DateTimeInput;
19
+ timeZone?: string;
20
+ }>;
21
+
22
+ let {
23
+ class: className,
24
+ dateStyle = 'medium',
25
+ locale,
26
+ timestamp,
27
+ timeZone,
28
+ ...restProps
29
+ }: Props = $props();
30
+
31
+ const formatterOptions = $derived<FormatDateOptions>({
32
+ dateStyle,
33
+ locale,
34
+ timeZone,
35
+ });
36
+ const text = $derived(formatDate(timestamp, formatterOptions));
37
+ const dateTime = $derived(dateTimeIsoString(timestamp));
38
+ </script>
39
+
40
+ <time
41
+ {...restProps}
42
+ class={`date-value${className ? ` ${className}` : ''}`}
43
+ datetime={dateTime}
44
+ >
45
+ {text}
46
+ </time>
47
+
48
+ <style>
49
+ .date-value {
50
+ white-space: nowrap;
51
+ }
52
+ </style>
@@ -0,0 +1,11 @@
1
+ import type { DateTimeDateStyle, DateTimeInput } from '../../../../utility/format/date-time/formatDateTime';
2
+ declare const DateValue: import("svelte").Component<{
3
+ [x: string]: unknown;
4
+ class?: string | undefined;
5
+ dateStyle?: DateTimeDateStyle | undefined;
6
+ locale?: Intl.LocalesArgument;
7
+ timestamp: DateTimeInput;
8
+ timeZone?: string | undefined;
9
+ }, {}, "">;
10
+ type DateValue = ReturnType<typeof DateValue>;
11
+ export default DateValue;
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DateTimeInput,
4
+ DateTimeTimeStyle,
5
+ FormatTimeOptions,
6
+ } from '../../../../utility/format/date-time/formatDateTime';
7
+ import {
8
+ dateTimeIsoString,
9
+ formatTime,
10
+ } from '../../../../utility/format/date-time/formatDateTime';
11
+ import type { SeblifyProps } from 'seblify';
12
+
13
+ type Props = SeblifyProps<{
14
+ [key: string]: unknown;
15
+ class?: string;
16
+ hour12?: boolean;
17
+ locale?: Intl.LocalesArgument;
18
+ timestamp: DateTimeInput;
19
+ timeStyle?: DateTimeTimeStyle;
20
+ timeZone?: string;
21
+ }>;
22
+
23
+ let {
24
+ class: className,
25
+ hour12,
26
+ locale,
27
+ timestamp,
28
+ timeStyle = 'short',
29
+ timeZone,
30
+ ...restProps
31
+ }: Props = $props();
32
+
33
+ const formatterOptions = $derived<FormatTimeOptions>({
34
+ hour12,
35
+ locale,
36
+ timeStyle,
37
+ timeZone,
38
+ });
39
+ const text = $derived(formatTime(timestamp, formatterOptions));
40
+ const dateTime = $derived(dateTimeIsoString(timestamp));
41
+ </script>
42
+
43
+ <time
44
+ {...restProps}
45
+ class={`time-value${className ? ` ${className}` : ''}`}
46
+ datetime={dateTime}
47
+ >
48
+ {text}
49
+ </time>
50
+
51
+ <style>
52
+ .time-value {
53
+ white-space: nowrap;
54
+ }
55
+ </style>
@@ -0,0 +1,12 @@
1
+ import type { DateTimeInput, DateTimeTimeStyle } from '../../../../utility/format/date-time/formatDateTime';
2
+ declare const TimeValue: import("svelte").Component<{
3
+ [x: string]: unknown;
4
+ class?: string | undefined;
5
+ hour12?: boolean | undefined;
6
+ locale?: Intl.LocalesArgument;
7
+ timestamp: DateTimeInput;
8
+ timeStyle?: DateTimeTimeStyle | undefined;
9
+ timeZone?: string | undefined;
10
+ }, {}, "">;
11
+ type TimeValue = ReturnType<typeof TimeValue>;
12
+ export default TimeValue;
@@ -0,0 +1,64 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DurationFormat,
4
+ DurationRounding,
5
+ DurationStyle,
6
+ DurationUnit,
7
+ FormatDurationOptions,
8
+ } from '../../../../utility/format/duration/formatDuration';
9
+ import { formatDuration } from '../../../../utility/format/duration/formatDuration';
10
+ import type { SeblifyProps } from 'seblify';
11
+
12
+ type Props = SeblifyProps<{
13
+ [key: string]: unknown;
14
+ class?: string;
15
+ format?: DurationFormat;
16
+ largestUnit?: DurationUnit;
17
+ locale?: Intl.LocalesArgument;
18
+ maxUnits?: number;
19
+ minUnits?: number;
20
+ rounding?: DurationRounding;
21
+ smallestUnit?: DurationUnit;
22
+ unitStyle?: DurationStyle;
23
+ value: number;
24
+ }>;
25
+
26
+ let {
27
+ class: className,
28
+ format = 'unit',
29
+ largestUnit = 'day',
30
+ locale,
31
+ maxUnits = 2,
32
+ minUnits = 1,
33
+ rounding,
34
+ smallestUnit = 'second',
35
+ unitStyle = 'long',
36
+ value,
37
+ ...restProps
38
+ }: Props = $props();
39
+
40
+ const formatterOptions = $derived<FormatDurationOptions>({
41
+ format,
42
+ largestUnit,
43
+ locale,
44
+ maxUnits,
45
+ minUnits,
46
+ rounding,
47
+ smallestUnit,
48
+ style: unitStyle,
49
+ });
50
+ const text = $derived(formatDuration(value, formatterOptions));
51
+ </script>
52
+
53
+ <span
54
+ {...restProps}
55
+ class={`duration${className ? ` ${className}` : ''}`}
56
+ >
57
+ {text}
58
+ </span>
59
+
60
+ <style>
61
+ .duration {
62
+ white-space: nowrap;
63
+ }
64
+ </style>
@@ -0,0 +1,16 @@
1
+ import type { DurationFormat, DurationRounding, DurationStyle, DurationUnit } from '../../../../utility/format/duration/formatDuration';
2
+ declare const Duration: import("svelte").Component<{
3
+ [x: string]: unknown;
4
+ class?: string | undefined;
5
+ format?: DurationFormat | undefined;
6
+ largestUnit?: DurationUnit | undefined;
7
+ locale?: Intl.LocalesArgument;
8
+ maxUnits?: number | undefined;
9
+ minUnits?: number | undefined;
10
+ rounding?: DurationRounding | undefined;
11
+ smallestUnit?: DurationUnit | undefined;
12
+ unitStyle?: DurationStyle | undefined;
13
+ value: number;
14
+ }, {}, "">;
15
+ type Duration = ReturnType<typeof Duration>;
16
+ export default Duration;
@@ -0,0 +1,121 @@
1
+ <script lang="ts">
2
+ import type {
3
+ FormatRelativeTimeOptions,
4
+ RelativeTimeInput,
5
+ RelativeTimeLabel,
6
+ RelativeTimeUnit,
7
+ RelativeTimeMode,
8
+ RelativeTimePresentation,
9
+ RelativeTimeRounding,
10
+ RelativeTimeStyle,
11
+ RelativeTimeUnitSteps,
12
+ } from '../../../../utility/format/relative-time/formatRelativeTime';
13
+ import {
14
+ formatRelativeTime,
15
+ getRelativeTimeState,
16
+ relativeTimeDateTime,
17
+ } from '../../../../utility/format/relative-time/formatRelativeTime';
18
+ import type { SeblifyProps } from 'seblify';
19
+
20
+ type Props = SeblifyProps<{
21
+ [key: string]: unknown;
22
+ class?: string;
23
+ from?: RelativeTimeInput;
24
+ labels?: readonly RelativeTimeLabel[];
25
+ largestUnit?: RelativeTimeUnit;
26
+ locale?: Intl.LocalesArgument;
27
+ maxUnits?: number;
28
+ minUnits?: number;
29
+ mode?: RelativeTimeMode;
30
+ presentation?: RelativeTimePresentation;
31
+ rounding?: RelativeTimeRounding;
32
+ smallestUnit?: RelativeTimeUnit;
33
+ unitStyle?: RelativeTimeStyle;
34
+ unitSteps?: RelativeTimeUnitSteps;
35
+ update?: 'auto' | false | number;
36
+ value: RelativeTimeInput;
37
+ }>;
38
+
39
+ let {
40
+ class: className,
41
+ from,
42
+ labels,
43
+ largestUnit,
44
+ locale,
45
+ maxUnits,
46
+ minUnits,
47
+ mode = 'time',
48
+ presentation = 'relative',
49
+ rounding,
50
+ smallestUnit,
51
+ unitStyle = 'long',
52
+ unitSteps = 'detailed',
53
+ update = 'auto',
54
+ value,
55
+ ...restProps
56
+ }: Props = $props();
57
+
58
+ let currentFrom = $state(new Date());
59
+ let updateTimer: ReturnType<typeof window.setTimeout> | undefined;
60
+
61
+ const formatterOptions = $derived<FormatRelativeTimeOptions>({
62
+ from: from ?? currentFrom,
63
+ labels,
64
+ largestUnit,
65
+ locale,
66
+ maxUnits,
67
+ minUnits,
68
+ mode,
69
+ presentation,
70
+ rounding,
71
+ smallestUnit,
72
+ style: unitStyle,
73
+ unitSteps,
74
+ });
75
+ const text = $derived(formatRelativeTime(value, formatterOptions));
76
+ const dateTime = $derived(relativeTimeDateTime(value));
77
+
78
+ function clearUpdateTimer(): void {
79
+ if (updateTimer === undefined) {
80
+ return;
81
+ }
82
+
83
+ window.clearTimeout(updateTimer);
84
+ updateTimer = undefined;
85
+ }
86
+
87
+ function updateCurrentFrom(): void {
88
+ currentFrom = new Date();
89
+ }
90
+
91
+ $effect(() => {
92
+ clearUpdateTimer();
93
+
94
+ if (from !== undefined || update === false) {
95
+ return;
96
+ }
97
+
98
+ const delay =
99
+ update === 'auto'
100
+ ? getRelativeTimeState(value, formatterOptions).updateInMilliseconds
101
+ : Math.max(1, update);
102
+
103
+ updateTimer = window.setTimeout(updateCurrentFrom, delay);
104
+
105
+ return clearUpdateTimer;
106
+ });
107
+ </script>
108
+
109
+ <time
110
+ {...restProps}
111
+ class={`relative-time${className ? ` ${className}` : ''}`}
112
+ datetime={dateTime}
113
+ >
114
+ {text}
115
+ </time>
116
+
117
+ <style>
118
+ .relative-time {
119
+ white-space: nowrap;
120
+ }
121
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { RelativeTimeInput, RelativeTimeLabel, RelativeTimeUnit, RelativeTimeMode, RelativeTimePresentation, RelativeTimeRounding, RelativeTimeStyle, RelativeTimeUnitSteps } from '../../../../utility/format/relative-time/formatRelativeTime';
2
+ declare const RelativeTime: import("svelte").Component<{
3
+ [x: string]: unknown;
4
+ class?: string | undefined;
5
+ from?: RelativeTimeInput | undefined;
6
+ labels?: readonly RelativeTimeLabel[] | undefined;
7
+ largestUnit?: RelativeTimeUnit | undefined;
8
+ locale?: Intl.LocalesArgument;
9
+ maxUnits?: number | undefined;
10
+ minUnits?: number | undefined;
11
+ mode?: RelativeTimeMode | undefined;
12
+ presentation?: RelativeTimePresentation | undefined;
13
+ rounding?: RelativeTimeRounding | undefined;
14
+ smallestUnit?: RelativeTimeUnit | undefined;
15
+ unitStyle?: RelativeTimeStyle | undefined;
16
+ unitSteps?: RelativeTimeUnitSteps | undefined;
17
+ update?: "auto" | false | number | undefined;
18
+ value: RelativeTimeInput;
19
+ }, {}, "">;
20
+ type RelativeTime = ReturnType<typeof RelativeTime>;
21
+ export default RelativeTime;
@@ -0,0 +1,121 @@
1
+ <script lang="ts">
2
+ import type {
3
+ DateTimeDateStyle,
4
+ DateTimeInput,
5
+ DateTimeTimeStyle,
6
+ } from '../../../../utility/format/date-time/formatDateTime';
7
+ import type {
8
+ RelativeTimeInput,
9
+ RelativeTimeLabel,
10
+ RelativeTimeMode,
11
+ RelativeTimeRounding,
12
+ RelativeTimeStyle,
13
+ RelativeTimeUnit,
14
+ RelativeTimeUnitSteps,
15
+ } from '../../../../utility/format/relative-time/formatRelativeTime';
16
+ import type { SeblifyProps } from 'seblify';
17
+ import DateValue from '../date-time/DateValue.svelte';
18
+ import RelativeTime from '../relative-time/RelativeTime.svelte';
19
+ import TimeValue from '../date-time/TimeValue.svelte';
20
+
21
+ type Props = SeblifyProps<{
22
+ [key: string]: unknown;
23
+ class?: string;
24
+ dateStyle?: DateTimeDateStyle;
25
+ hour12?: boolean;
26
+ locale?: Intl.LocalesArgument;
27
+ relativeFrom?: RelativeTimeInput;
28
+ relativeLabels?: readonly RelativeTimeLabel[];
29
+ relativeLargestUnit?: RelativeTimeUnit;
30
+ relativeMaxUnits?: number;
31
+ relativeMinUnits?: number;
32
+ relativeMode?: RelativeTimeMode;
33
+ relativeRounding?: RelativeTimeRounding;
34
+ relativeSmallestUnit?: RelativeTimeUnit;
35
+ relativeUnitSteps?: RelativeTimeUnitSteps;
36
+ relativeUnitStyle?: RelativeTimeStyle;
37
+ relativeUpdate?: 'auto' | false | number;
38
+ timestamp: DateTimeInput;
39
+ timeStyle?: DateTimeTimeStyle;
40
+ timeZone?: string;
41
+ }>;
42
+
43
+ let {
44
+ class: className,
45
+ dateStyle = 'long',
46
+ hour12,
47
+ locale,
48
+ relativeFrom,
49
+ relativeLabels,
50
+ relativeLargestUnit,
51
+ relativeMaxUnits = 2,
52
+ relativeMinUnits,
53
+ relativeMode = 'time',
54
+ relativeRounding,
55
+ relativeSmallestUnit = 'second',
56
+ relativeUnitSteps = 'detailed',
57
+ relativeUnitStyle = 'long',
58
+ relativeUpdate = 'auto',
59
+ timestamp,
60
+ timeStyle = 'medium',
61
+ timeZone,
62
+ ...restProps
63
+ }: Props = $props();
64
+ </script>
65
+
66
+ <span
67
+ {...restProps}
68
+ class={`timestamp-card${className ? ` ${className}` : ''}`}
69
+ >
70
+ <span class="timestamp-card__relative">
71
+ <RelativeTime
72
+ from={relativeFrom}
73
+ labels={relativeLabels}
74
+ largestUnit={relativeLargestUnit}
75
+ locale={locale}
76
+ maxUnits={relativeMaxUnits}
77
+ minUnits={relativeMinUnits}
78
+ mode={relativeMode}
79
+ rounding={relativeRounding}
80
+ smallestUnit={relativeSmallestUnit}
81
+ unitSteps={relativeUnitSteps}
82
+ unitStyle={relativeUnitStyle}
83
+ update={relativeUpdate}
84
+ value={timestamp}
85
+ />
86
+ </span>
87
+ <span class="timestamp-card__absolute">
88
+ <DateValue {dateStyle} {locale} {timestamp} {timeZone} />
89
+ <TimeValue {hour12} {locale} {timestamp} {timeStyle} {timeZone} />
90
+ </span>
91
+ </span>
92
+
93
+ <style>
94
+ .timestamp-card {
95
+ display: grid;
96
+ min-width: min(16rem, 100%);
97
+ gap: 0.375rem;
98
+ box-sizing: border-box;
99
+ color: inherit;
100
+ font-size: 0.8125rem;
101
+ line-height: 1.35;
102
+ text-align: start;
103
+ }
104
+
105
+ .timestamp-card__relative {
106
+ display: block;
107
+ font-weight: 700;
108
+ white-space: nowrap;
109
+ }
110
+
111
+ .timestamp-card__absolute {
112
+ display: grid;
113
+ grid-template-columns: minmax(0, 1fr) auto;
114
+ align-items: baseline;
115
+ gap: 0.75rem;
116
+ font-size: 0.75rem;
117
+ font-weight: 500;
118
+ opacity: 0.82;
119
+ white-space: nowrap;
120
+ }
121
+ </style>
@@ -0,0 +1,25 @@
1
+ import type { DateTimeDateStyle, DateTimeInput, DateTimeTimeStyle } from '../../../../utility/format/date-time/formatDateTime';
2
+ import type { RelativeTimeInput, RelativeTimeLabel, RelativeTimeMode, RelativeTimeRounding, RelativeTimeStyle, RelativeTimeUnit, RelativeTimeUnitSteps } from '../../../../utility/format/relative-time/formatRelativeTime';
3
+ declare const TimestampCard: import("svelte").Component<{
4
+ [x: string]: unknown;
5
+ class?: string | undefined;
6
+ dateStyle?: DateTimeDateStyle | undefined;
7
+ hour12?: boolean | undefined;
8
+ locale?: Intl.LocalesArgument;
9
+ relativeFrom?: RelativeTimeInput | undefined;
10
+ relativeLabels?: readonly RelativeTimeLabel[] | undefined;
11
+ relativeLargestUnit?: RelativeTimeUnit | undefined;
12
+ relativeMaxUnits?: number | undefined;
13
+ relativeMinUnits?: number | undefined;
14
+ relativeMode?: RelativeTimeMode | undefined;
15
+ relativeRounding?: RelativeTimeRounding | undefined;
16
+ relativeSmallestUnit?: RelativeTimeUnit | undefined;
17
+ relativeUnitSteps?: RelativeTimeUnitSteps | undefined;
18
+ relativeUnitStyle?: RelativeTimeStyle | undefined;
19
+ relativeUpdate?: "auto" | false | number | undefined;
20
+ timestamp: DateTimeInput;
21
+ timeStyle?: DateTimeTimeStyle | undefined;
22
+ timeZone?: string | undefined;
23
+ }, {}, "">;
24
+ type TimestampCard = ReturnType<typeof TimestampCard>;
25
+ export default TimestampCard;