@winkintel/bootstrap-svelte 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -174,7 +174,7 @@ Interactive components are implemented as Svelte components rather than requirin
174
174
 
175
175
  ## Status and feedback
176
176
 
177
- This package is published as `1.0.3`, but feedback from Svelte developers is still very welcome. Useful feedback includes:
177
+ This package is published as `1.0.5`, but feedback from Svelte developers is still very welcome. Useful feedback includes:
178
178
 
179
179
  - Component API ergonomics
180
180
  - Svelte 5 idioms and runes compatibility
@@ -22,7 +22,6 @@ Title component for the Modal.Header.
22
22
  - `level` (number): Optional. Heading level (1-6) for the title element
23
23
  -->
24
24
  <script lang="ts">import { uniqueClsx } from '../common/css.js';
25
- import { onDestroy } from 'svelte';
26
25
  import { getOptionalModalRootState } from './modal.svelte.js';
27
26
  // Generate a unique ID for the modal title element, in case one is not provided...
28
27
  const uid = $props.id();
@@ -31,12 +30,13 @@ let elementType = $derived(`h${level}`);
31
30
  let classes = $derived(uniqueClsx('modal-title', classValues));
32
31
  const rootState = getOptionalModalRootState();
33
32
  $effect(() => {
34
- if (id)
35
- rootState?.registerTitleId(id);
36
- });
37
- onDestroy(() => {
38
- if (id)
39
- rootState?.unregisterTitleId(id);
33
+ const registeredId = id;
34
+ if (!registeredId)
35
+ return;
36
+ rootState?.registerTitleId(registeredId);
37
+ return () => {
38
+ rootState?.unregisterTitleId(registeredId);
39
+ };
40
40
  });
41
41
  </script>
42
42
 
@@ -221,7 +221,7 @@ const handleKeydown = (event) => {
221
221
  };
222
222
  </script>
223
223
 
224
- <svelte:window on:keydown={handleKeydown} />
224
+ <svelte:window onkeydown={handleKeydown} />
225
225
 
226
226
  {#if rootState.isShown}
227
227
  <div
@@ -1,5 +1,5 @@
1
1
  import { type EasingFunction } from 'bezier-easing';
2
- import clsx from 'clsx';
2
+ import type clsx from 'clsx';
3
3
  /**
4
4
  * This easing function will match the CSS `ease-in-out` easing function using a cubic Bezier curve defined by the points (0.25, 0.1, 0.25, 1).
5
5
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function#ease
@@ -1,5 +1,50 @@
1
1
  import BezierEasing, {} from 'bezier-easing';
2
- import clsx from 'clsx';
2
+ const whitespacePattern = /\s/;
3
+ const classTokenPattern = /\S+/g;
4
+ function appendClassTokens(result, value) {
5
+ const classValue = typeof value === 'string' ? value : String(value);
6
+ if (!classValue) {
7
+ return;
8
+ }
9
+ if (!whitespacePattern.test(classValue)) {
10
+ if (result.indexOf(classValue) === -1) {
11
+ result.push(classValue);
12
+ }
13
+ return;
14
+ }
15
+ const tokens = classValue.match(classTokenPattern);
16
+ if (!tokens) {
17
+ return;
18
+ }
19
+ for (let i = 0; i < tokens.length; i++) {
20
+ const token = tokens[i];
21
+ if (result.indexOf(token) === -1) {
22
+ result.push(token);
23
+ }
24
+ }
25
+ }
26
+ function appendClassValue(result, value) {
27
+ if (typeof value === 'string' || typeof value === 'number') {
28
+ appendClassTokens(result, value);
29
+ return;
30
+ }
31
+ if (!value || typeof value !== 'object') {
32
+ return;
33
+ }
34
+ if (Array.isArray(value)) {
35
+ for (let i = 0; i < value.length; i++) {
36
+ if (value[i]) {
37
+ appendClassValue(result, value[i]);
38
+ }
39
+ }
40
+ return;
41
+ }
42
+ for (const key in value) {
43
+ if (value[key]) {
44
+ appendClassTokens(result, key);
45
+ }
46
+ }
47
+ }
3
48
  /**
4
49
  * This easing function will match the CSS `ease-in-out` easing function using a cubic Bezier curve defined by the points (0.25, 0.1, 0.25, 1).
5
50
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function#ease
@@ -42,20 +87,17 @@ export const cubicBezier = (x1, y1, x2, y2) => {
42
87
  * @returns A string containing unique class names.
43
88
  */
44
89
  export function uniqueClsx(...args) {
45
- const classString = clsx(...args);
46
- // Early return for empty strings
47
- if (!classString) {
48
- return '';
49
- }
50
- // Using a regex split will normalize whitespace and split simultaneously...
51
- const classes = classString.split(/\s+/);
52
- const seen = new Set();
53
90
  const result = [];
54
- for (let i = 0; i < classes.length; i++) {
55
- const cls = classes[i];
56
- if (cls && !seen.has(cls)) {
57
- seen.add(cls);
58
- result.push(cls);
91
+ for (let i = 0; i < args.length; i++) {
92
+ const value = args[i];
93
+ if (!value) {
94
+ continue;
95
+ }
96
+ if (typeof value === 'string' || typeof value === 'number') {
97
+ appendClassTokens(result, value);
98
+ }
99
+ else {
100
+ appendClassValue(result, value);
59
101
  }
60
102
  }
61
103
  return result.join(' ');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Wink, Inc.",
3
3
  "name": "@winkintel/bootstrap-svelte",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "description": "Bootstrap components for Svelte 5 with TypeScript support.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -23,6 +23,7 @@
23
23
  "check-types:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
24
24
  "clean": "rimraf --glob --max-retries=10 --retry-delay=250 '{.svelte-kit,.turbo,.vercel,build,dist,node_modules,playwright-mcp,test-results}'",
25
25
  "dev": "vite dev --port 5176",
26
+ "doctor": "svelte-doctor check",
26
27
  "format": "prettier --write --ignore-path=.prettierignore $(git diff --name-only --diff-filter d --relative . && git ls-files --others --exclude-standard | sed \"s|^$(git rev-parse --show-prefix)||\")",
27
28
  "format-all": "prettier --write --ignore-path=.prettierignore ./src",
28
29
  "lint": "prettier --check ./src && eslint ./src",
@@ -88,6 +89,7 @@
88
89
  "sass": "1.77.6",
89
90
  "svelte": "~5.56.1",
90
91
  "svelte-check": "~4.5.0",
92
+ "svelte-doctor": "~0.3.1",
91
93
  "svelte-highlight": "~7.9.0",
92
94
  "svelte-preprocess": "~6.0.5",
93
95
  "typescript": "~6.0.3",