@adobe-commerce/elsie 1.3.1-alpha014 → 1.3.1-alpha018

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "1.3.1-alpha014",
3
+ "version": "1.3.1-alpha018",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -90,7 +90,22 @@ export const Lazy: Story = {
90
90
 
91
91
  export const AllBuiltInIcons: Story = {
92
92
  argTypes: {
93
- style: Object
93
+ style: Object,
94
+ url: {
95
+ table: {
96
+ disable: true
97
+ }
98
+ },
99
+ source: {
100
+ table: {
101
+ disable: true
102
+ }
103
+ },
104
+ title: {
105
+ table: {
106
+ disable: true
107
+ }
108
+ }
94
109
  },
95
110
  args: {
96
111
  style: {
@@ -119,6 +134,18 @@ export const AllBuiltInIcons: Story = {
119
134
 
120
135
 
121
136
  export const UrlExamples: Story = {
137
+ argTypes: {
138
+ source: {
139
+ table: {
140
+ disable: true
141
+ }
142
+ },
143
+ title: {
144
+ table: {
145
+ disable: true
146
+ }
147
+ }
148
+ },
122
149
  render: ({ url, ...args }: StoryIconProps) => (
123
150
  <div style={{
124
151
  display: 'grid',
@@ -147,7 +174,7 @@ export const UrlExamples: Story = {
147
174
  margin: '0.5rem 0 0 0',
148
175
  wordBreak: 'break-all'
149
176
  }}>
150
- {url ? `Displays icon from: ${url}` : 'Displays icon from SVG'}
177
+ {url ? `Displays icon from: ${url}` : `Displays icon from ${window.location.origin}/favicon.svg`}
151
178
  </p>
152
179
  </div>
153
180
 
@@ -121,13 +121,24 @@ function UrlSvgLoader({
121
121
  })
122
122
  .then(content => {
123
123
  // Check if content is valid SVG
124
- if (!content.trim().toLowerCase().startsWith('<?xml') &&
125
- !content.trim().toLowerCase().startsWith('<svg')) {
126
- console.error(`[Icon] Invalid SVG content from ${url} - Content must be a valid SVG file`);
124
+ try {
125
+ const parser = new DOMParser();
126
+ const doc = parser.parseFromString(content, "image/svg+xml");
127
+ const svg = doc.querySelector('svg');
128
+ if (!svg) {
129
+ throw new Error("No <svg> element found");
130
+ }
131
+ // Success!
132
+ } catch(e: unknown) {
133
+ if (e instanceof Error ) {
134
+ console.error(`[Icon] Invalid SVG content from ${url}: ${e.message}`);
135
+ } else {
136
+ console.error(`[Icon] Invalid SVG content from ${url}: ${String(e)}`);
137
+ }
127
138
  setError(true);
128
139
  setLoading(false);
129
- return;
130
140
  }
141
+
131
142
 
132
143
  // Process SVG content to ensure proper sizing and accessibility
133
144
  let processedContent = content;
@@ -166,7 +177,11 @@ function UrlSvgLoader({
166
177
  setLoading(false);
167
178
  })
168
179
  .catch((error) => {
169
- console.error(`[Icon] ${error.message}`);
180
+ if (error instanceof Error) {
181
+ console.error(`[Icon] ${error.message}`);
182
+ } else {
183
+ console.error(`[Icon] ${String(error)}`);
184
+ }
170
185
  setError(true);
171
186
  setLoading(false);
172
187
  });
@@ -177,12 +192,12 @@ function UrlSvgLoader({
177
192
  }
178
193
 
179
194
  return (
180
- <div
195
+ <span
181
196
  className={props.className}
182
197
  style={{
183
198
  width: String(props.width),
184
199
  height: String(props.height),
185
- display: 'inline-block',
200
+ display: 'inline-flex',
186
201
  lineHeight: 0,
187
202
  }}
188
203
  dangerouslySetInnerHTML={{ __html: svgContent }}