@streamscloud/kit 1.0.3 → 1.0.4

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 (68) hide show
  1. package/dist/core/actions/index.d.ts +1 -0
  2. package/dist/core/actions/index.js +1 -0
  3. package/dist/core/actions/stop-click-propagation.d.ts +3 -0
  4. package/dist/core/actions/stop-click-propagation.js +17 -0
  5. package/dist/core/continuation-token.js +1 -8
  6. package/dist/core/event-dispatcher.d.ts +1 -3
  7. package/dist/core/event-dispatcher.js +20 -12
  8. package/dist/core/files/file-service.js +3 -1
  9. package/dist/core/files/file-validator.js +1 -1
  10. package/dist/core/files/files-provider.js +2 -1
  11. package/dist/core/locale/app-locale.svelte.d.ts +2 -1
  12. package/dist/core/locale/app-locale.svelte.js +2 -1
  13. package/dist/core/repository/repository.svelte.js +4 -1
  14. package/dist/core/theme/app-theme.svelte.d.ts +2 -0
  15. package/dist/core/theme/app-theme.svelte.js +2 -0
  16. package/dist/core/utils/after-mount.svelte.d.ts +13 -0
  17. package/dist/core/utils/after-mount.svelte.js +21 -0
  18. package/dist/core/utils/array-helper.js +4 -3
  19. package/dist/core/utils/compact-number.js +1 -0
  20. package/dist/core/utils/date-helper.js +10 -35
  21. package/dist/core/utils/href-validator.js +4 -2
  22. package/dist/core/utils/html-helper.d.ts +2 -0
  23. package/dist/core/utils/html-helper.js +6 -1
  24. package/dist/core/utils/index.d.ts +1 -0
  25. package/dist/core/utils/index.js +1 -0
  26. package/dist/core/utils/string-helper.js +2 -2
  27. package/dist/core/utils/utils.d.ts +4 -2
  28. package/dist/core/utils/utils.js +4 -6
  29. package/dist/core/validation/form-validation-handler/yup-form-validator.d.ts +1 -1
  30. package/dist/core/validation/form-validation-handler/yup-form-validator.js +10 -5
  31. package/dist/core/validation/validation-schemas/email-validation.js +10 -10
  32. package/dist/ui/checkbox/cmp.checkbox.svelte +5 -4
  33. package/dist/ui/date-picker/cmp.date-picker.svelte +13 -2
  34. package/dist/ui/date-picker/cmp.date-picker.svelte.d.ts +1 -1
  35. package/dist/ui/dialog/cmp.dialog-container.svelte +2 -8
  36. package/dist/ui/dialog/dialog-store.svelte.js +1 -0
  37. package/dist/ui/drawer/cmp.drawer.svelte +3 -1
  38. package/dist/ui/drawer/cmp.drawer.svelte.d.ts +3 -1
  39. package/dist/ui/duration/cmp.duration.svelte +7 -3
  40. package/dist/ui/duration/cmp.duration.svelte.d.ts +3 -3
  41. package/dist/ui/empty-state/cmp.empty-state.svelte +5 -5
  42. package/dist/ui/grid-card/cmp.grid-card-media.svelte +1 -1
  43. package/dist/ui/grid-card/cmp.grid-card-media.svelte.d.ts +4 -1
  44. package/dist/ui/icon/cmp.icon.svelte +6 -10
  45. package/dist/ui/image/cmp.image.svelte +4 -3
  46. package/dist/ui/infinite-scroll/cmp.infinite-scroll.svelte +2 -2
  47. package/dist/ui/numeral-input/cmp.numeral-input.svelte +3 -0
  48. package/dist/ui/numeral-input/cmp.numeral-input.svelte.d.ts +1 -0
  49. package/dist/ui/pagination/pagination-state.svelte.d.ts +1 -0
  50. package/dist/ui/pagination/pagination-state.svelte.js +1 -0
  51. package/dist/ui/pin-input/cmp.pin-input.svelte +44 -26
  52. package/dist/ui/pin-input/cmp.pin-input.svelte.d.ts +3 -2
  53. package/dist/ui/player/carousel/cmp.carousel.svelte +8 -9
  54. package/dist/ui/player/carousel/cmp.carousel.svelte.d.ts +1 -1
  55. package/dist/ui/radio/cmp.radio.svelte +9 -4
  56. package/dist/ui/rich-text-input/validated-link-button.js +1 -1
  57. package/dist/ui/select/cmp.singleselect-async.svelte +2 -1
  58. package/dist/ui/select/multiselect-base.svelte +2 -1
  59. package/dist/ui/select/select-core.svelte.d.ts +2 -0
  60. package/dist/ui/select/select-core.svelte.js +18 -17
  61. package/dist/ui/slider/cmp.slider.svelte +28 -37
  62. package/dist/ui/slider/cmp.slider.svelte.d.ts +1 -0
  63. package/dist/ui/table/table-cells/table-text-cell.svelte +5 -3
  64. package/dist/ui/time-ago/cmp.time-ago.svelte +10 -1
  65. package/dist/ui/time-ago/cmp.time-ago.svelte.d.ts +1 -1
  66. package/dist/ui/toggle/cmp.toggle.svelte +4 -2
  67. package/dist/ui/video/cmp.video.svelte +6 -5
  68. package/package.json +1 -1
@@ -1,8 +1,13 @@
1
- <script lang="ts">import { claimFormFieldLabel } from '../_internal/form-field-label-context';
2
- let { value, min = 0, max = 100, step = 1, disabled = false, showValue = false, withInput = false, ticks = [], valueSuffix = '', id, on } = $props();
1
+ <script lang="ts">import { claimFormFieldLabel, getFormFieldLabel, resolveAriaLabelledby } from '../_internal/form-field-label-context';
2
+ import { NumeralInput } from '../numeral-input';
3
+ import { untrack } from 'svelte';
4
+ let { value, min = 0, max = 100, step = 1, disabled = false, showValue = false, withInput = false, ticks = [], valueSuffix = '', id, 'aria-label': ariaLabel, on } = $props();
3
5
  const fallbackId = $props.id();
4
6
  const controlId = $derived(id ?? fallbackId);
5
- claimFormFieldLabel(() => controlId);
7
+ const formFieldLabel = getFormFieldLabel();
8
+ if (!untrack(() => withInput)) {
9
+ claimFormFieldLabel(() => controlId);
10
+ }
6
11
  let focused = $state(false);
7
12
  const fillPct = $derived(max === min ? 0 : ((value - min) / (max - min)) * 100);
8
13
  const handleInput = (e) => {
@@ -11,15 +16,7 @@ const handleInput = (e) => {
11
16
  const handleChange = (e) => {
12
17
  on?.change?.(Number(e.currentTarget.value));
13
18
  };
14
- const handleNumeric = (e) => {
15
- const raw = Number(e.currentTarget.value);
16
- if (Number.isNaN(raw)) {
17
- return;
18
- }
19
- const clamped = Math.min(max, Math.max(min, raw));
20
- on?.input?.(clamped);
21
- on?.change?.(clamped);
22
- };
19
+ const stepDecimals = $derived((String(step).split('.')[1] ?? '').length);
23
20
  </script>
24
21
 
25
22
  <div class="slider" class:slider--disabled={disabled}>
@@ -29,6 +26,8 @@ const handleNumeric = (e) => {
29
26
  type="range"
30
27
  class="slider__input"
31
28
  id={controlId}
29
+ aria-label={ariaLabel}
30
+ aria-labelledby={resolveAriaLabelledby(formFieldLabel, ariaLabel, undefined)}
32
31
  min={min}
33
32
  max={max}
34
33
  step={step}
@@ -45,21 +44,25 @@ const handleNumeric = (e) => {
45
44
  <span class="slider__value">{value}{valueSuffix}</span>
46
45
  {/if}
47
46
  {#if withInput}
48
- <input
49
- type="number"
50
- class="slider__numeric"
51
- min={min}
52
- max={max}
53
- step={step}
54
- disabled={disabled}
55
- value={value}
56
- oninput={handleNumeric} />
47
+ <div class="slider__numeric">
48
+ <NumeralInput
49
+ clearable={false}
50
+ value={value}
51
+ min={min}
52
+ max={max}
53
+ decimals={stepDecimals}
54
+ size="sm"
55
+ disabled={disabled}
56
+ hideResolvedValue
57
+ aria-label={ariaLabel}
58
+ on={{ input: (next) => on?.input?.(next), change: (next) => on?.change?.(next) }} />
59
+ </div>
57
60
  {/if}
58
61
  </div>
59
62
 
60
63
  {#if ticks.length}
61
64
  <div class="slider__ticks">
62
- {#each ticks as tick (tick)}
65
+ {#each ticks as tick, i (i)}
63
66
  <span class="slider__tick">{tick}</span>
64
67
  {/each}
65
68
  </div>
@@ -148,21 +151,9 @@ Optionally renders the current value, a numeric input alongside the track, and t
148
151
  text-align: right;
149
152
  }
150
153
  .slider__numeric {
151
- width: 4rem;
152
- height: var(--sc-kit--field--height--sm);
153
- padding: 0 var(--sc-kit--space--2);
154
- text-align: center;
155
- font-size: var(--sc-kit--font-size--sm);
156
- line-height: var(--sc-kit--line-height--control--sm);
157
- font-variant-numeric: tabular-nums;
158
- background: var(--sc-kit--field--background);
159
- border: 1px solid var(--sc-kit--field--border-color);
160
- border-radius: var(--sc-kit--field--border-radius--sm);
161
- color: var(--sc-kit--color--text--primary);
162
- outline: none;
163
- }
164
- .slider__numeric:focus {
165
- border-color: var(--sc-kit--field--border-color--focus);
154
+ --sc-kit--numeral-input--width: 3rem;
155
+ --sc-kit--numeral-input--text-align: center;
156
+ flex: none;
166
157
  }
167
158
  .slider__ticks {
168
159
  display: flex;
@@ -16,6 +16,7 @@ type Props = {
16
16
  /** Suffix appended to the displayed value (e.g. ' %'). @default '' */
17
17
  valueSuffix?: string;
18
18
  id?: string;
19
+ 'aria-label'?: string;
19
20
  on?: {
20
21
  change?: (value: number) => void;
21
22
  input?: (value: number) => void;
@@ -1,4 +1,4 @@
1
- <script lang="ts" generics="T extends {id: string}">import { HtmlHelper, DateHelper } from '../../../core/utils';
1
+ <script lang="ts" generics="T extends {id: string}">import { AfterMount, HtmlHelper, DateHelper } from '../../../core/utils';
2
2
  import { LineClamp } from '../../line-clamp';
3
3
  let { item, column, centered } = $props();
4
4
  const getValueForColumn = (column, item) => (column.valueFactory ? column.valueFactory(item) : item[column.id])?.toString();
@@ -8,6 +8,8 @@ const getDateValueForColumn = (column, item) => {
8
8
  };
9
9
  const dateValue = $derived(getDateValueForColumn(column, item) ?? null);
10
10
  const fmt = (d, options) => new Intl.DateTimeFormat(undefined, options).format(d);
11
+ const strippedHtml = new AfterMount(() => HtmlHelper.stripHtml(value), '');
12
+ const sanitizedHtml = new AfterMount(() => HtmlHelper.sanitizeHtml(value), '');
11
13
  </script>
12
14
 
13
15
  <span class="table-text-cell" class:table-text-cell--centered={centered}>
@@ -19,10 +21,10 @@ const fmt = (d, options) => new Intl.DateTimeFormat(undefined, options).format(d
19
21
  : `${fmt(dateValue, { dateStyle: 'medium' })} ${fmt(dateValue, { timeStyle: 'medium' })}`}
20
22
  {:else if column.format === 'html'}
21
23
  {#if column.maxLines === 'single-line-no-trim'}
22
- <span class="table-text-cell__single-line-no-trim">{HtmlHelper.stripHtml(value)}</span>
24
+ <span class="table-text-cell__single-line-no-trim">{strippedHtml.current}</span>
23
25
  {:else}
24
26
  <LineClamp maxLines={column.maxLines || 1}>
25
- {@html HtmlHelper.sanitizeHtml(value)}
27
+ {@html sanitizedHtml.current}
26
28
  </LineClamp>
27
29
  {/if}
28
30
  {:else if column.maxLines === 'single-line-no-trim'}
@@ -6,7 +6,11 @@ let timeSpan = $state.raw(null);
6
6
  let timeoutId;
7
7
  const setRelativeTime = (d) => {
8
8
  disableTimeout();
9
- const dateVal = d ? DateHelper.toDate(d) : new Date();
9
+ if (!d) {
10
+ timeSpan = null;
11
+ return;
12
+ }
13
+ const dateVal = DateHelper.toDate(d);
10
14
  const formatTime = () => dateVal.toLocaleString(localization.locale, DateFormatOptions.timeFormat);
11
15
  const setupAbsDate = () => {
12
16
  if (absoluteFormat === 'compact') {
@@ -48,6 +52,11 @@ const setRelativeTime = (d) => {
48
52
  refreshIntervalSec = 3600;
49
53
  }
50
54
  else if (diffSeconds < secsIn2Days) {
55
+ const yesterday = new Date();
56
+ yesterday.setDate(yesterday.getDate() - 1);
57
+ if (dateVal.toDateString() !== yesterday.toDateString()) {
58
+ return setupAbsDate();
59
+ }
51
60
  timeSpan = showTime ? localization.yesterdayAt(formatTime()) : localization.yesterday;
52
61
  refreshIntervalSec = 3600;
53
62
  }
@@ -1,6 +1,6 @@
1
1
  import type { AppLocaleValue } from '../../core/locale';
2
2
  type Props = {
3
- /** Date to display relative to now */
3
+ /** Date to display relative to now; `null` renders nothing. */
4
4
  date: Date | string | null;
5
5
  /** Minutes after which absolute date format is used @default 2880 */
6
6
  thresholdMinutes?: number;
@@ -1,4 +1,5 @@
1
- <script lang="ts">import { getFormFieldLabel } from '../_internal/form-field-label-context';
1
+ <script lang="ts">import { stopClickPropagation } from '../../core/actions';
2
+ import { getFormFieldLabel } from '../_internal/form-field-label-context';
2
3
  const { checked, size = 'md', disabled = false, presentational = false, layout = 'spread', label, sublabel, title, name, on } = $props();
3
4
  const hasLabel = $derived(label !== undefined || sublabel !== undefined);
4
5
  const ariaLabel = $derived(typeof label === 'string' ? label : name);
@@ -43,7 +44,8 @@ const handleClick = (event) => {
43
44
  <label
44
45
  class="toggle-row toggle-row--{layout}"
45
46
  class:toggle-row--disabled={disabled}
46
- title={title}>
47
+ title={title}
48
+ use:stopClickPropagation={!presentational}>
47
49
  <span class="toggle-row__text">
48
50
  {#if typeof label === 'string'}
49
51
  <span class="toggle-row__label">{label}</span>
@@ -235,12 +235,13 @@ const notifyProgress = () => {
235
235
  on?.progress?.(percentageCompleted);
236
236
  };
237
237
  const handleSeek = (percent) => {
238
- if (video) {
239
- video.currentTime = video.duration * percent;
240
- percentageCompleted = percent;
241
- notifyProgress();
242
- on?.timeUpdate?.({ id, seconds: video.currentTime });
238
+ if (!video || !Number.isFinite(video.duration)) {
239
+ return;
243
240
  }
241
+ video.currentTime = video.duration * percent;
242
+ percentageCompleted = percent;
243
+ notifyProgress();
244
+ on?.timeUpdate?.({ id, seconds: video.currentTime });
244
245
  };
245
246
  </script>
246
247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",