seblify 0.3.0 → 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 (118) hide show
  1. package/README.md +77 -54
  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 +4484 -167
  25. package/dist/components/action/input/select/checkbox/Checkbox.svelte.d.ts +22 -1
  26. package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.d.ts +11 -12
  27. package/dist/components/action/input/select/checkbox/checkbox-relations.svelte.js +56 -8
  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 +678 -82
  57. package/dist/components/action/input/select/switch/Switch.svelte.d.ts +1 -1
  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 +663 -70
  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/relative-time/RelativeTime.svelte +17 -0
  69. package/dist/components/display/data-display/metric/relative-time/RelativeTime.svelte.d.ts +6 -1
  70. package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte +121 -0
  71. package/dist/components/display/data-display/metric/timestamp-card/TimestampCard.svelte.d.ts +25 -0
  72. package/dist/components/display/data-display/visual/timeline/TimelineItem.svelte +653 -63
  73. package/dist/components/display/data-display/visual/timeline/context.d.ts +1 -1
  74. package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte +650 -60
  75. package/dist/components/display/feedback/loading/loading-dots/LoadingDots.svelte.d.ts +1 -1
  76. package/dist/components/display/feedback/loading/spinner/Spinner.svelte +650 -60
  77. package/dist/components/display/feedback/loading/spinner/Spinner.svelte.d.ts +1 -1
  78. package/dist/components/display/typography/code-snippet/CodeSnippet.svelte +3 -3
  79. package/dist/components/display/typography/eyebrow/Eyebrow.svelte +2 -2
  80. package/dist/components/display/typography/highlight/Highlight.svelte +719 -59
  81. package/dist/components/display/typography/highlight/Highlight.svelte.d.ts +1 -1
  82. package/dist/components/framework/layout/container/app-shell/AppShell.svelte +16 -2
  83. package/dist/components/framework/navigation/context/breadcrumb/Breadcrumb.svelte +1 -1
  84. package/dist/components/framework/navigation/sidebar/sidebar/Sidebar.svelte +35 -10
  85. package/dist/components/framework/navigation/sidebar/sidenav/Sidenav.svelte +5 -5
  86. package/dist/components/framework/overlay/tooltip/Tooltip.svelte +2 -3
  87. package/dist/components/framework/overlay/tooltip/Tooltip.svelte.d.ts +2 -2
  88. package/dist/components/framework/surface/paper/Paper.svelte +730 -87
  89. package/dist/components/framework/surface/paper/Paper.svelte.d.ts +1 -1
  90. package/dist/components/utility/format/date-time/formatDateTime.d.ts +23 -0
  91. package/dist/components/utility/format/date-time/formatDateTime.js +33 -0
  92. package/dist/components/utility/format/relative-time/formatRelativeTime.d.ts +7 -0
  93. package/dist/components/utility/format/relative-time/formatRelativeTime.js +194 -7
  94. package/dist/design-system/inheritance/tokens.js +6 -0
  95. package/dist/design-system/reserved-props/allowed-options.d.ts +5 -3
  96. package/dist/design-system/theme/tokens.d.ts +72 -2
  97. package/dist/design-system/theme/tokens.js +167 -176
  98. package/dist/index.d.ts +15 -4
  99. package/dist/index.js +14 -3
  100. package/dist/styles/tone-context.css +649 -58
  101. package/dist/theme.css +1 -183
  102. package/dist/themes/canopy.css +373 -0
  103. package/dist/themes/cobalt.css +373 -0
  104. package/dist/themes/iris.css +373 -0
  105. package/dist/themes/lumen.css +373 -0
  106. package/dist/themes/mono.css +373 -0
  107. package/dist/themes/moss.css +373 -0
  108. package/dist/themes/noir.css +373 -0
  109. package/dist/themes/plain.css +373 -0
  110. package/dist/themes/pulse.css +373 -0
  111. package/dist/themes/signal.css +373 -0
  112. package/dist/themes/slate.css +373 -0
  113. package/dist/themes/solar.css +373 -0
  114. package/dist/themes/sorbet.css +373 -0
  115. package/dist/themes/studio.css +369 -0
  116. package/dist/themes/vesper.css +373 -0
  117. package/package.json +18 -2
  118. package/dist/components/action/input/select/theme-switch/ThemeSwitch.svelte.d.ts +0 -10
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
2
2
  type PaperElement = keyof HTMLElementTagNameMap;
3
3
  type PaperPadding = 'none' | 'sm' | 'md' | 'lg';
4
4
  type PaperRadius = 'sm' | 'md' | 'lg';
5
- type PaperTone = 'neutral' | 'primary' | 'success' | 'danger' | 'warning' | 'info' | 'inverse';
5
+ type PaperTone = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
6
6
  type PaperVariant = 'solid' | 'soft' | 'tint' | 'plain';
7
7
  declare const Paper: import("svelte").Component<{
8
8
  as?: PaperElement | undefined;
@@ -0,0 +1,23 @@
1
+ export type DateTimeInput = Date | number | string;
2
+ export type DateTimeDateStyle = 'short' | 'medium' | 'long' | 'full';
3
+ export type DateTimeTimeStyle = 'short' | 'medium' | 'long' | 'full';
4
+ export type DateTimeLocaleOptions = {
5
+ locale?: Intl.LocalesArgument;
6
+ timeZone?: string;
7
+ };
8
+ export type FormatDateOptions = DateTimeLocaleOptions & {
9
+ dateStyle?: DateTimeDateStyle;
10
+ };
11
+ export type FormatTimeOptions = DateTimeLocaleOptions & {
12
+ hour12?: boolean;
13
+ timeStyle?: DateTimeTimeStyle;
14
+ };
15
+ export type FormatDateTimeOptions = DateTimeLocaleOptions & {
16
+ dateStyle?: DateTimeDateStyle;
17
+ hour12?: boolean;
18
+ timeStyle?: DateTimeTimeStyle;
19
+ };
20
+ export declare function formatDate(timestamp: DateTimeInput, options?: FormatDateOptions): string;
21
+ export declare function formatTime(timestamp: DateTimeInput, options?: FormatTimeOptions): string;
22
+ export declare function formatDateTime(timestamp: DateTimeInput, options?: FormatDateTimeOptions): string;
23
+ export declare function dateTimeIsoString(timestamp: DateTimeInput): string;
@@ -0,0 +1,33 @@
1
+ export function formatDate(timestamp, options = {}) {
2
+ return new Intl.DateTimeFormat(options.locale, {
3
+ dateStyle: options.dateStyle ?? 'medium',
4
+ timeZone: options.timeZone,
5
+ }).format(toDate(timestamp));
6
+ }
7
+ export function formatTime(timestamp, options = {}) {
8
+ return new Intl.DateTimeFormat(options.locale, {
9
+ hour12: options.hour12,
10
+ timeStyle: options.timeStyle ?? 'short',
11
+ timeZone: options.timeZone,
12
+ }).format(toDate(timestamp));
13
+ }
14
+ export function formatDateTime(timestamp, options = {}) {
15
+ return new Intl.DateTimeFormat(options.locale, {
16
+ dateStyle: options.dateStyle ?? 'medium',
17
+ hour12: options.hour12,
18
+ timeStyle: options.timeStyle ?? 'short',
19
+ timeZone: options.timeZone,
20
+ }).format(toDate(timestamp));
21
+ }
22
+ export function dateTimeIsoString(timestamp) {
23
+ return toDate(timestamp).toISOString();
24
+ }
25
+ function toDate(timestamp) {
26
+ const date = timestamp instanceof Date
27
+ ? new Date(timestamp.getTime())
28
+ : new Date(timestamp);
29
+ if (Number.isNaN(date.getTime())) {
30
+ throw new RangeError('Invalid date time timestamp.');
31
+ }
32
+ return date;
33
+ }
@@ -1,3 +1,4 @@
1
+ import type { DurationRounding } from '../duration/formatDuration';
1
2
  export type RelativeTimeInput = Date | number | string;
2
3
  export type RelativeTimeLabel = {
3
4
  label: string;
@@ -8,6 +9,7 @@ export type RelativeTimeLabel = {
8
9
  };
9
10
  export type RelativeTimePresentation = 'relative' | 'unit';
10
11
  export type RelativeTimeMode = 'time' | 'calendar';
12
+ export type RelativeTimeRounding = DurationRounding;
11
13
  export type RelativeTimeStyle = 'long' | 'short' | 'narrow';
12
14
  export type RelativeTimeUnitSteps = 'detailed' | 'compact' | 'simple';
13
15
  export type RelativeTimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
@@ -24,9 +26,14 @@ export type RelativeTimeState = {
24
26
  export type FormatRelativeTimeOptions = {
25
27
  from?: RelativeTimeInput;
26
28
  labels?: readonly RelativeTimeLabel[];
29
+ largestUnit?: RelativeTimeUnit;
27
30
  locale?: Intl.LocalesArgument;
31
+ maxUnits?: number;
32
+ minUnits?: number;
28
33
  mode?: RelativeTimeMode;
29
34
  presentation?: RelativeTimePresentation;
35
+ rounding?: RelativeTimeRounding;
36
+ smallestUnit?: RelativeTimeUnit;
30
37
  style?: RelativeTimeStyle;
31
38
  unitSteps?: RelativeTimeUnitSteps;
32
39
  };
@@ -1,3 +1,4 @@
1
+ import { formatDuration } from '../duration/formatDuration';
1
2
  const SECOND = 1000;
2
3
  const MINUTE = 60 * SECOND;
3
4
  const HOUR = 60 * MINUTE;
@@ -8,11 +9,36 @@ const YEAR = 12 * MONTH;
8
9
  const CALENDAR_TIME_THRESHOLD = 13 * HOUR;
9
10
  const MAX_TIMEOUT = 2_147_483_647;
10
11
  const DEFAULT_LABEL_THRESHOLD = SECOND - 1;
12
+ const UNIT_MILLISECONDS = {
13
+ second: SECOND,
14
+ minute: MINUTE,
15
+ hour: HOUR,
16
+ day: DAY,
17
+ week: WEEK,
18
+ month: MONTH,
19
+ year: YEAR,
20
+ };
21
+ const UNIT_INDEX = {
22
+ second: 0,
23
+ minute: 1,
24
+ hour: 2,
25
+ day: 3,
26
+ week: 4,
27
+ month: 5,
28
+ year: 6,
29
+ };
11
30
  export function formatRelativeTime(value, options = {}) {
12
31
  const state = getRelativeTimeState(value, options);
13
32
  if (state.label !== undefined) {
14
33
  return state.label;
15
34
  }
35
+ if (usesDurationFormatting(options)) {
36
+ const durationText = formatRelativeTimeDuration(state, options);
37
+ if (options.presentation === 'unit') {
38
+ return durationText;
39
+ }
40
+ return formatRelativeDuration(durationText, state, options);
41
+ }
16
42
  if (options.presentation === 'unit') {
17
43
  return new Intl.NumberFormat(options.locale, {
18
44
  style: 'unit',
@@ -45,7 +71,7 @@ function selectRelativeTimeState(targetTime, fromTime, options) {
45
71
  const direction = getDirection(milliseconds);
46
72
  const absoluteMilliseconds = Math.abs(milliseconds);
47
73
  const unitSteps = options.unitSteps ?? 'detailed';
48
- const selected = selectUnit(absoluteMilliseconds, unitSteps);
74
+ const selected = selectUnit(absoluteMilliseconds, unitSteps, options);
49
75
  const labelSelection = selectLabel(milliseconds, options.labels);
50
76
  const calendarLabel = selectCalendarLabel(targetTime, fromTime, milliseconds, options);
51
77
  const label = labelSelection?.label ?? calendarLabel;
@@ -60,6 +86,122 @@ function selectRelativeTimeState(targetTime, fromTime, options) {
60
86
  unit: selected.unit,
61
87
  };
62
88
  }
89
+ function usesDurationFormatting(options) {
90
+ return ((options.maxUnits !== undefined && Math.floor(options.maxUnits) > 1) ||
91
+ (options.minUnits !== undefined && Math.floor(options.minUnits) > 1));
92
+ }
93
+ function formatRelativeTimeDuration(state, options) {
94
+ const minUnits = options.minUnits;
95
+ const maxUnits = options.maxUnits === undefined && minUnits !== undefined
96
+ ? minUnits
97
+ : options.maxUnits;
98
+ return formatDuration(Math.abs(state.milliseconds), {
99
+ largestUnit: getDurationLargestUnit(state.unit, options),
100
+ locale: options.locale,
101
+ maxUnits,
102
+ minUnits,
103
+ rounding: options.rounding,
104
+ smallestUnit: (options.smallestUnit ?? 'second'),
105
+ style: options.style,
106
+ });
107
+ }
108
+ function getDurationLargestUnit(selectedUnit, options) {
109
+ if (options.largestUnit !== undefined) {
110
+ return options.largestUnit;
111
+ }
112
+ const minUnits = getPositiveIntegerOption(options.minUnits);
113
+ if (minUnits === undefined || minUnits <= 1) {
114
+ return selectedUnit;
115
+ }
116
+ const smallestUnit = options.smallestUnit ?? 'second';
117
+ const smallestUnitIndex = UNIT_INDEX[smallestUnit];
118
+ if (smallestUnitIndex === undefined) {
119
+ throw new RangeError('Invalid relative time smallestUnit.');
120
+ }
121
+ const selectedUnitIndex = UNIT_INDEX[selectedUnit];
122
+ const inferredUnitIndex = Math.min(UNIT_INDEX.year, Math.max(selectedUnitIndex, smallestUnitIndex + minUnits - 1));
123
+ return unitFromIndex(inferredUnitIndex);
124
+ }
125
+ function getPositiveIntegerOption(value) {
126
+ if (value === undefined) {
127
+ return undefined;
128
+ }
129
+ if (!Number.isFinite(value) || value < 1) {
130
+ throw new RangeError('Invalid relative time unit count.');
131
+ }
132
+ return Math.floor(value);
133
+ }
134
+ function unitFromIndex(index) {
135
+ const unit = Object.keys(UNIT_INDEX).find((candidate) => UNIT_INDEX[candidate] === index);
136
+ if (unit === undefined) {
137
+ throw new RangeError('Invalid relative time unit index.');
138
+ }
139
+ return unit;
140
+ }
141
+ function formatRelativeDuration(durationText, state, options) {
142
+ const formatter = new Intl.RelativeTimeFormat(options.locale, {
143
+ numeric: state.direction === 'present' ? 'auto' : 'always',
144
+ style: options.style ?? 'long',
145
+ });
146
+ if (state.direction === 'present') {
147
+ return formatter.format(0, 'second');
148
+ }
149
+ const sampleAmount = state.direction === 'past' ? -1 : 1;
150
+ const parts = formatter.formatToParts(sampleAmount, 'second');
151
+ const firstUnitPartIndex = parts.findIndex(isRelativeTimeNumberPart);
152
+ const lastUnitPartIndex = findLastRelativeTimeNumberPartIndex(parts);
153
+ if (firstUnitPartIndex === -1 || lastUnitPartIndex === -1) {
154
+ return formatter.format(sampleAmount, 'second');
155
+ }
156
+ const suffix = removeUnitText(parts
157
+ .slice(lastUnitPartIndex + 1)
158
+ .map((part) => part.value)
159
+ .join(''), options);
160
+ return [
161
+ ...parts.slice(0, firstUnitPartIndex).map((part) => part.value),
162
+ durationText,
163
+ suffix,
164
+ ].join('');
165
+ }
166
+ function findLastRelativeTimeNumberPartIndex(parts) {
167
+ for (let index = parts.length - 1; index >= 0; index -= 1) {
168
+ if (isRelativeTimeNumberPart(parts[index])) {
169
+ return index;
170
+ }
171
+ }
172
+ return -1;
173
+ }
174
+ function isRelativeTimeNumberPart(part) {
175
+ return (part.type === 'integer' ||
176
+ part.type === 'decimal' ||
177
+ part.type === 'fraction' ||
178
+ part.type === 'group');
179
+ }
180
+ function removeUnitText(text, options) {
181
+ const unitText = new Intl.NumberFormat(options.locale, {
182
+ style: 'unit',
183
+ unit: 'second',
184
+ unitDisplay: options.style ?? 'long',
185
+ })
186
+ .formatToParts(1)
187
+ .find((part) => part.type === 'unit')?.value;
188
+ if (unitText === undefined) {
189
+ return text;
190
+ }
191
+ const index = text.indexOf(unitText);
192
+ if (index === -1) {
193
+ return text;
194
+ }
195
+ const before = text.slice(0, index);
196
+ let after = text.slice(index + unitText.length);
197
+ if (after.startsWith('.') && (after.length === 1 || after[1] === ' ')) {
198
+ after = after.slice(1);
199
+ }
200
+ if (before.trim() === '') {
201
+ return after;
202
+ }
203
+ return `${before}${after}`;
204
+ }
63
205
  export function relativeTimeDateTime(value) {
64
206
  return new Date(toTime(value, 'value')).toISOString();
65
207
  }
@@ -76,14 +218,55 @@ function getDirection(milliseconds) {
76
218
  }
77
219
  return milliseconds < 0 ? 'past' : 'future';
78
220
  }
79
- function selectUnit(milliseconds, unitSteps) {
80
- if (unitSteps === 'detailed') {
81
- return selectDetailedUnit(milliseconds);
221
+ function selectUnit(milliseconds, unitSteps, options) {
222
+ validateUnitRange(options.largestUnit, options.smallestUnit);
223
+ const selected = unitSteps === 'detailed'
224
+ ? selectDetailedUnit(milliseconds)
225
+ : unitSteps === 'compact'
226
+ ? selectCompactUnit(milliseconds)
227
+ : selectSimpleUnit(milliseconds);
228
+ const largestLimited = limitLargestUnit(milliseconds, selected, options.largestUnit);
229
+ return limitSmallestUnit(milliseconds, largestLimited, options.smallestUnit);
230
+ }
231
+ function validateUnitRange(largestUnit, smallestUnit) {
232
+ if (largestUnit !== undefined && !(largestUnit in UNIT_MILLISECONDS)) {
233
+ throw new RangeError('Invalid relative time largestUnit.');
234
+ }
235
+ if (smallestUnit !== undefined && !(smallestUnit in UNIT_MILLISECONDS)) {
236
+ throw new RangeError('Invalid relative time smallestUnit.');
237
+ }
238
+ if (largestUnit !== undefined &&
239
+ smallestUnit !== undefined &&
240
+ UNIT_INDEX[largestUnit] < UNIT_INDEX[smallestUnit]) {
241
+ throw new RangeError('Relative time largestUnit must be larger than smallestUnit.');
242
+ }
243
+ }
244
+ function limitLargestUnit(milliseconds, selected, largestUnit) {
245
+ if (largestUnit === undefined) {
246
+ return selected;
82
247
  }
83
- if (unitSteps === 'compact') {
84
- return selectCompactUnit(milliseconds);
248
+ if (!(largestUnit in UNIT_MILLISECONDS)) {
249
+ throw new RangeError('Invalid relative time largestUnit.');
85
250
  }
86
- return selectSimpleUnit(milliseconds);
251
+ if (UNIT_INDEX[selected.unit] <= UNIT_INDEX[largestUnit]) {
252
+ return selected;
253
+ }
254
+ return {
255
+ amount: wholeUnit(milliseconds, UNIT_MILLISECONDS[largestUnit]),
256
+ unit: largestUnit,
257
+ };
258
+ }
259
+ function limitSmallestUnit(milliseconds, selected, smallestUnit) {
260
+ if (smallestUnit === undefined) {
261
+ return selected;
262
+ }
263
+ if (UNIT_INDEX[selected.unit] >= UNIT_INDEX[smallestUnit]) {
264
+ return selected;
265
+ }
266
+ return {
267
+ amount: wholeUnit(milliseconds, UNIT_MILLISECONDS[smallestUnit]),
268
+ unit: smallestUnit,
269
+ };
87
270
  }
88
271
  function selectLabel(milliseconds, labels) {
89
272
  if (labels === undefined) {
@@ -337,6 +520,10 @@ function matchesRelativeTimeState(targetTime, fromTime, options, current) {
337
520
  if (current.label !== next.label) {
338
521
  return false;
339
522
  }
523
+ if (usesDurationFormatting(options)) {
524
+ return (formatRelativeTimeDuration(current, options) ===
525
+ formatRelativeTimeDuration(next, options));
526
+ }
340
527
  return (current.amount === next.amount &&
341
528
  current.direction === next.direction &&
342
529
  current.unit === next.unit);
@@ -11,6 +11,12 @@ const inheritanceTokens = [
11
11
  value: 'ambient fill text color',
12
12
  description: 'Resolved readable foreground color for content placed on the current tone fill. Use when a child can render a solid tone surface.',
13
13
  },
14
+ {
15
+ name: '--seblify-current-tone-fill-hover',
16
+ category: 'Tone',
17
+ value: 'ambient fill hover color',
18
+ description: 'Resolved hover color for the current tone fill. Use when a child renders a solid interactive tone surface.',
19
+ },
14
20
  {
15
21
  name: '--seblify-current-tone-text',
16
22
  category: 'Tone',
@@ -1,15 +1,16 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import { CustomCssSize } from './complex-types';
3
3
  type SizeKeys = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
4
- type ToneOptions = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'inverse';
4
+ type ToneOptions = 'neutral' | 'strong' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
5
+ type SurfaceOptions = 'default' | 'inverse';
5
6
  type PlacementOptions = 'top-start' | 'top' | 'top-end' | 'end-top' | 'end' | 'end-bottom' | 'bottom-end' | 'bottom' | 'bottom-start' | 'start-bottom' | 'start' | 'start-top';
6
- type VariantOptions = 'solid' | 'soft' | 'tint' | 'outline' | 'plain';
7
+ type VariantOptions = 'solid' | 'soft' | 'tint' | 'outline' | 'plain' | 'blank' | 'inset' | 'overflow';
7
8
  type BorderOptions = 'none' | 'solid' | 'dash';
8
9
  type ShapeOptions = 'pill' | 'dot' | 'floating' | 'line' | 'slim' | 'long' | 'flat';
9
10
  type AlignOptions = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
10
11
  type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
11
12
  type DirOptions = 'ltr' | 'rtl' | 'auto';
12
- type AnimationOptions = 'none' | 'smooth' | 'snappy' | 'bouncy';
13
+ type AnimationOptions = 'none' | 'smooth' | 'snappy' | 'bouncy' | 'fade' | 'scale' | 'bump' | 'pop' | 'draw' | 'rise' | 'bounce';
13
14
  type OrientationOptions = 'horizontal' | 'vertical';
14
15
  export type SeblifyReservedPropOptions = {
15
16
  class: string;
@@ -39,6 +40,7 @@ export type SeblifyReservedPropOptions = {
39
40
  shape: ShapeOptions & {};
40
41
  tone: ToneOptions & {};
41
42
  variant: VariantOptions & {};
43
+ surface: SurfaceOptions & {};
42
44
  size: (SizeKeys & {}) | CustomCssSize;
43
45
  padding: ((SizeKeys | 'none') & {}) | CustomCssSize;
44
46
  animation: AnimationOptions & {};
@@ -1,7 +1,77 @@
1
- declare const themeTokens: {
1
+ declare const themeTokens: ({
2
+ readonly name: "--seblify-color-background";
3
+ readonly category: "Surface";
4
+ readonly value: "#faf7f2";
5
+ readonly description: "Default page background behind component surfaces.";
6
+ } | {
7
+ readonly name: "--seblify-color-surface";
8
+ readonly category: "Surface";
9
+ readonly value: "#fffdf9";
10
+ readonly description: "Default component surface.";
11
+ } | {
12
+ readonly name: "--seblify-color-surface-raised";
13
+ readonly category: "Surface";
14
+ readonly value: "#ffffff";
15
+ readonly description: "Raised surface for panels, popovers, and elevated UI.";
16
+ } | {
17
+ readonly name: "--seblify-color-surface-muted";
18
+ readonly category: "Surface";
19
+ readonly value: "#f2ebe4";
20
+ readonly description: "Muted surface for inactive controls and subtle areas.";
21
+ } | {
22
+ readonly name: "--seblify-color-surface-hover";
23
+ readonly category: "Surface";
24
+ readonly value: "#ebe1d8";
25
+ readonly description: "Surface color for hover states on neutral controls.";
26
+ } | {
27
+ readonly name: "--seblify-color-surface-inverse";
28
+ readonly category: "Surface";
29
+ readonly value: "#15110f";
30
+ readonly description: "High-contrast inverse surface for sidebars and snackbars.";
31
+ } | {
32
+ readonly name: "--seblify-color-surface-inverse-hover";
33
+ readonly category: "Surface";
34
+ readonly value: "#241d19";
35
+ readonly description: "Hover or active state on inverse surfaces.";
36
+ } | {
37
+ readonly name: "--seblify-color-border";
38
+ readonly category: "Border";
39
+ readonly value: "#ded0c4";
40
+ readonly description: "Default border for controls and containers.";
41
+ } | {
42
+ readonly name: "--seblify-color-border-strong";
43
+ readonly category: "Border";
44
+ readonly value: "#c5afa0";
45
+ readonly description: "Stronger border for interactive controls.";
46
+ } | {
47
+ readonly name: "--seblify-color-border-inverse";
48
+ readonly category: "Border";
49
+ readonly value: "#4a3b32";
50
+ readonly description: "Border used on inverse surfaces.";
51
+ } | {
52
+ readonly name: "--seblify-color-text";
53
+ readonly category: "Text";
54
+ readonly value: "#211916";
55
+ readonly description: "Primary text color on page and surface backgrounds.";
56
+ } | {
57
+ readonly name: "--seblify-color-text-muted";
58
+ readonly category: "Text";
59
+ readonly value: "#6f5f55";
60
+ readonly description: "Secondary text for descriptions, helper text, and metadata.";
61
+ } | {
62
+ readonly name: "--seblify-color-text-subtle";
63
+ readonly category: "Text";
64
+ readonly value: "#8b7a70";
65
+ readonly description: "Lower-emphasis text for labels, separators, and quiet UI.";
66
+ } | {
67
+ readonly name: "--seblify-color-text-inverse";
68
+ readonly category: "Text";
69
+ readonly value: "#fff4e7";
70
+ readonly description: "Text placed on inverse surfaces.";
71
+ } | {
2
72
  name: string;
3
73
  category: string;
4
74
  value: string;
5
75
  description: string;
6
- }[];
76
+ })[];
7
77
  export default themeTokens;