@vueless/storybook 0.0.58 → 0.0.59

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.
@@ -143,11 +143,57 @@ function getArgsFromUrl() {
143
143
 
144
144
  if (!args) return {};
145
145
 
146
- return args.split(";").reduce((acc, pair) => {
147
- const [key, value] = pair.split(":");
146
+ return parseKeyValuePairs(args);
147
+ }
148
+
149
+ function parseKeyValuePairs(input) {
150
+ const result = {};
151
+
152
+ // Split key-value pairs and parse them
153
+ input.split(";").forEach((pair) => {
154
+ const [rawKey, rawValue] = pair.split(":");
155
+
156
+ if (!rawKey) return;
157
+
158
+ let value;
159
+
160
+ if (rawValue === "!null") {
161
+ value = null;
162
+ } else if (rawValue === "!undefined") {
163
+ value = undefined;
164
+ } else if (!isNaN(parseInt(rawValue))) {
165
+ value = Number(rawValue);
166
+ } else {
167
+ value = decodeURIComponent(rawValue.replace(/\+/g, " "));
168
+ }
169
+
170
+ setNestedValue(result, rawKey, value);
171
+ });
172
+
173
+ return result;
174
+ }
175
+
176
+ // Set nested values like objects or arrays
177
+ function setNestedValue(obj, path, value) {
178
+ const arrayItems = path.match(/\w+|\[\d+\]/g) || [];
179
+ const keys = arrayItems.map((key) => (key.startsWith("[") ? Number(key.slice(1, -1)) : key));
180
+ const lastKeyIndex = keys.length - 1;
181
+
182
+ let current = obj;
148
183
 
149
- acc[key] = decodeURIComponent(value);
184
+ for (let index = 0; index < keys.length; index++) {
185
+ const key = keys[index];
186
+
187
+ if (index === lastKeyIndex) {
188
+ current[key] = value;
189
+ }
150
190
 
151
- return acc;
152
- }, {});
191
+ if (index !== lastKeyIndex && !current[key]) {
192
+ current[key] = typeof keys[index + 1] === "number" ? [] : {};
193
+ }
194
+
195
+ if (index !== lastKeyIndex && current[key]) {
196
+ current = current[key];
197
+ }
198
+ }
153
199
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueless/storybook",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "description": "Simplifies Storybook configuration for Vueless UI library.",
5
5
  "homepage": "https://vueless.com",
6
6
  "author": "Johnny Grid",