@splendidlabz/svelte 4.12.0 → 4.13.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 (48) hide show
  1. package/components/SVG/SVG.svelte +18 -11
  2. package/components/SVG/parser.js +4 -4
  3. package/package.json +11 -8
  4. package/CHANGELOG.md +0 -636
  5. package/common.js +0 -21
  6. package/components/Accordion/accordion-controlled.spec.js +0 -14
  7. package/components/DisclosureOld/Drawer/Drawer.svelte +0 -31
  8. package/components/DisclosureOld/Drawer/DrawerCloseButton.svelte +0 -37
  9. package/components/DisclosureOld/Drawer/DrawerContent.svelte +0 -105
  10. package/components/DisclosureOld/Drawer/DrawerTrigger.svelte +0 -11
  11. package/components/DisclosureOld/Drawer/drawer.js +0 -18
  12. package/components/DisclosureOld/Drawer/index.js +0 -6
  13. package/components/DisclosureOld/Dropdown/DropdownContent.svelte +0 -15
  14. package/components/DisclosureOld/Dropdown/DropdownTrigger.svelte +0 -14
  15. package/components/DisclosureOld/Dropdown/dropdown.js +0 -4
  16. package/components/DisclosureOld/Dropdown/index.js +0 -4
  17. package/components/DisclosureOld/Modal/Modal.svelte +0 -30
  18. package/components/DisclosureOld/Modal/ModalCloseButton.svelte +0 -7
  19. package/components/DisclosureOld/Modal/ModalContent.svelte +0 -50
  20. package/components/DisclosureOld/Modal/ModalTrigger.svelte +0 -11
  21. package/components/DisclosureOld/Modal/exit-intent.js +0 -17
  22. package/components/DisclosureOld/Modal/index.js +0 -5
  23. package/components/DisclosureOld/Modal/modal.js +0 -4
  24. package/components/DisclosureOld/Old/DisclosureContentOld.svelte +0 -109
  25. package/components/DisclosureOld/Old/DisclosureTriggerOld.svelte +0 -62
  26. package/components/DisclosureOld/Popover/PopoverCloseButton.svelte +0 -32
  27. package/components/DisclosureOld/Popover/PopoverContent.svelte +0 -107
  28. package/components/DisclosureOld/Popover/PopoverTrigger.svelte +0 -33
  29. package/components/DisclosureOld/Popover/floating.js +0 -171
  30. package/components/DisclosureOld/Popover/index.js +0 -5
  31. package/components/DisclosureOld/Popover/popover.js +0 -18
  32. package/components/DisclosureOld/Popover/references/FollowTheMouse.svelte +0 -45
  33. package/components/DisclosureOld/Tooltip/Tooltip.svelte +0 -14
  34. package/components/DisclosureOld/Tooltip/TooltipContent.svelte +0 -7
  35. package/components/DisclosureOld/Tooltip/TooltipTrigger.svelte +0 -33
  36. package/components/DisclosureOld/Tooltip/index.js +0 -5
  37. package/components/DisclosureOld/Tooltip/tooltip.js +0 -22
  38. package/components/DisclosureOld/disclosure-store.js +0 -48
  39. package/components/DisclosureOld/disclosure.js +0 -443
  40. package/components/DisclosureOld/disclosure.svelte.js +0 -432
  41. package/components/Markdown/Markdown.spec.js +0 -48
  42. package/components/Tabs/tabs-css.spec.js +0 -43
  43. package/components/Tabs/tabs.spec.js +0 -553
  44. package/eslint.config.js +0 -2
  45. package/jsconfig.json +0 -16
  46. package/svelte.config.js +0 -13
  47. package/test-utils.js +0 -44
  48. package/vitest.config.js +0 -11
@@ -8,17 +8,18 @@
8
8
  * @component
9
9
  * @example
10
10
  * <!-- Renders /src/svg/logo.svg -->
11
- * <SVG icon="logo" class="w-6 h-6" />
11
+ * <SVG name="logo" class="w-6 h-6" />
12
12
  * @example
13
13
  * <!-- Use DOM parser when the SVG needs runtime DOM APIs -->
14
- * <SVG icon="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
15
- * @throws {Error} icon property is required
14
+ * <SVG name="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
15
+ * @throws {Error} When both name and icon are missing
16
16
  * @throws {Error} When the requested SVG file cannot be found
17
17
  */
18
18
 
19
19
  /**
20
20
  * @typedef {object} SVGProps
21
- * @property {string} icon - Basename of the SVG file (without .svg)
21
+ * @property {string} [name] - Basename of the SVG file (without .svg)
22
+ * @property {string} [icon] - Alias of name. Use whichever reads better
22
23
  * @property {object|string} [style] - Inline styles. Object is converted with `toStyleString`
23
24
  * @property {"naive"|"dom"} [parser="naive"] - Parsing strategy
24
25
  * @property {*} [children] - Ignored; component does not support slots
@@ -30,12 +31,15 @@
30
31
  /** @type {SVGProps} */
31
32
  const {
32
33
  icon,
34
+ name,
33
35
  style,
34
36
  parser = 'naive', // or DOM
35
37
  children, // Just to remove children slots
36
38
  ...rest
37
39
  } = $props()
38
40
 
41
+ const basename = name || icon
42
+
39
43
  const files = {
40
44
  ...import.meta.glob(`/src/svg/**/*.svg`, { eager: true, query: 'raw' }),
41
45
  ...import.meta.glob(`/src/svgs/**/*.svg`, { eager: true, query: 'raw' }),
@@ -43,9 +47,11 @@
43
47
 
44
48
  // Find the SVG
45
49
  const file = init(() => {
46
- if (!icon) throw new Error('icon property is required')
47
- const found = Object.keys(files).find(f => f.split('/').pop() === `${icon}.svg`)
48
- if (!found) throw new Error(`${icon}.svg not found`)
50
+ if (!basename) throw new Error('name (or icon) property is required')
51
+ const found = Object.keys(files).find(
52
+ f => f.split('/').pop() === `${basename}.svg`,
53
+ )
54
+ if (!found) throw new Error(`${basename}.svg not found`)
49
55
  return found
50
56
  })
51
57
 
@@ -77,19 +83,20 @@
77
83
  Inline SVG renderer for files under `/src/svg` or `/src/svgs`.
78
84
 
79
85
  - Props:
80
- - icon (string, required): Basename of the SVG file (without .svg)
86
+ - name (string): Basename of the SVG file (without .svg)
87
+ - icon (string): Alias of name. Use whichever reads better
81
88
  - style (object|string, optional): Inline styles; objects are converted with `toStyleString`
82
89
  - parser ("naive"|"dom", optional, default "naive"): Parsing strategy
83
90
  - Slots: none
84
91
  - Events: none
85
92
  - Errors:
86
- - Throws if `icon` is missing
93
+ - Throws if both `name` and `icon` are missing
87
94
  - Throws if the SVG file cannot be found
88
95
 
89
96
  Usage:
90
97
  ```svelte
91
- <SVG icon="logo" class="w-6 h-6" />
92
- <SVG icon="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
98
+ <SVG name="logo" class="w-6 h-6" />
99
+ <SVG name="spinner" parser="dom" style={{ color: 'rebeccapurple' }} />
93
100
  ```
94
101
  -->
95
102
 
@@ -46,10 +46,10 @@ export function naiveParser(content, options) {
46
46
  }
47
47
 
48
48
  // If width/height exist but viewBox doesn't, create viewBox
49
- if (!currentViewBox && (finalWidth || finalHeight)) {
50
- const vbWidth = finalWidth || '0'
51
- const vbHeight = finalHeight || '0'
52
- finalViewBox = `0 0 ${vbWidth} ${vbHeight}`
49
+ // from the file's own dimensions — a width/height option only
50
+ // changes the display size, not the coordinate system.
51
+ if (!currentViewBox && currentWidth && currentHeight) {
52
+ finalViewBox = `0 0 ${currentWidth} ${currentHeight}`
53
53
  }
54
54
 
55
55
  // Apply width if we have a final value
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@splendidlabz/svelte",
3
3
  "type": "module",
4
- "version": "4.12.0",
4
+ "version": "4.13.0",
5
5
  "sideEffects": false,
6
6
  "homepage": "https://splendidlabz.com/docs/svelte",
7
7
  "scripts": {
@@ -22,20 +22,23 @@
22
22
  "./actions": "./actions/index.js",
23
23
  "./utils": "./utils/index.js"
24
24
  },
25
+ "files": [
26
+ "actions",
27
+ "components",
28
+ "utils",
29
+ "!**/*.spec.js",
30
+ "!**/*.test.js",
31
+ "!components/DisclosureOld"
32
+ ],
25
33
  "dependencies": {
26
34
  "@floating-ui/dom": "^1.7.6",
27
35
  "@iconify/svelte": "^5.2.1",
28
- "@splendidlabz/styles": "*",
29
36
  "@splendidlabz/utils": "*",
30
- "autosuggest-highlight": "^3.3.4",
31
- "lodash-es": "^4.18.1",
32
- "node-html-parser": "^7.1.0"
37
+ "autosuggest-highlight": "^3.3.4"
33
38
  },
34
39
  "devDependencies": {
35
- "@splendidlabz/eslint-config": "2.1.4",
40
+ "@splendidlabz/eslint-config": "2.1.6",
36
41
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
37
- "@testing-library/svelte": "^5.3.1",
38
- "@tsconfig/svelte": "^5.0.8",
39
42
  "happy-dom": "^20.9.0",
40
43
  "svelte": "^5.55.4",
41
44
  "svelte-check": "^4.4.6",