@burger-editor/frozen-patty 0.11.0 → 4.0.0-alpha.2

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/dist/set.d.ts CHANGED
@@ -1,2 +1,9 @@
1
1
  import type { Filter, FrozenPattyData } from './types.js';
2
+ /**
3
+ *
4
+ * @param el
5
+ * @param data
6
+ * @param attr
7
+ * @param filter
8
+ */
2
9
  export default function (el: Element, data: FrozenPattyData, attr: string, filter?: Filter): Element;
package/dist/set.js CHANGED
@@ -1,10 +1,18 @@
1
1
  import { setValue } from './set-value.js';
2
+ import { kebabCase } from './utils.js';
3
+ /**
4
+ *
5
+ * @param el
6
+ * @param data
7
+ * @param attr
8
+ * @param filter
9
+ */
2
10
  export default function (el, data, attr, filter) {
3
11
  el = el.cloneNode(true);
4
12
  for (const dataKeyName in data) {
5
13
  if (dataKeyName in data) {
6
14
  const datum = data[dataKeyName];
7
- const selector = `[data-${attr}*="${dataKeyName}"]`;
15
+ const selector = `[data-${attr}*="${kebabCase(dataKeyName)}"]`;
8
16
  // eslint-disable-next-line unicorn/prefer-spread
9
17
  const targetList = Array.from(el.querySelectorAll(selector));
10
18
  if (Array.isArray(datum)) {
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,18 @@
1
1
  import type { FrozenPattyData, PrimitiveDatum } from './types.js';
2
+ /**
3
+ *
4
+ * @param kvs
5
+ */
2
6
  export declare function arrayToHash(kvs: [keyof FrozenPattyData, PrimitiveDatum, boolean][]): {
3
7
  [index: string]: PrimitiveDatum | PrimitiveDatum[];
4
8
  };
9
+ /**
10
+ *
11
+ * @param str
12
+ */
13
+ export declare function kebabCase(str: string): string;
14
+ /**
15
+ *
16
+ * @param str
17
+ */
18
+ export declare function camelCase(str: string): string;
package/dist/utils.js CHANGED
@@ -1,21 +1,37 @@
1
+ /**
2
+ *
3
+ * @param kvs
4
+ */
1
5
  export function arrayToHash(kvs) {
2
6
  const result = {};
3
7
  for (const kv of kvs) {
4
8
  const k = kv[0];
5
9
  const v = kv[1];
6
10
  const toArray = kv[2];
7
- if (toArray) {
8
- const arrayPropVal = result[k];
9
- if (Array.isArray(arrayPropVal)) {
10
- arrayPropVal.push(v);
11
- }
12
- else {
13
- result[k] = k in result ? [arrayPropVal, v] : [v];
14
- }
15
- }
16
- else {
11
+ if (!toArray) {
17
12
  result[k] = v;
13
+ continue;
14
+ }
15
+ const arrayPropVal = result[k];
16
+ if (Array.isArray(arrayPropVal)) {
17
+ arrayPropVal.push(v);
18
+ continue;
18
19
  }
20
+ result[k] = k in result ? [arrayPropVal, v] : [v];
19
21
  }
20
22
  return result;
21
23
  }
24
+ /**
25
+ *
26
+ * @param str
27
+ */
28
+ export function kebabCase(str) {
29
+ return str.replaceAll(/([A-Z])/g, '-$1').toLowerCase();
30
+ }
31
+ /**
32
+ *
33
+ * @param str
34
+ */
35
+ export function camelCase(str) {
36
+ return str.replaceAll(/-([a-z])/g, (_, c) => c.toUpperCase());
37
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@burger-editor/frozen-patty",
3
- "version": "0.11.0",
3
+ "version": "4.0.0-alpha.2",
4
4
  "description": "Pure HTML to JSON converter that not use template engine.",
5
5
  "author": "D-ZERO",
6
6
  "license": "MIT",
7
7
  "repository": {
8
- "url": "https://github.com/d-zero-dev/burger-editor.git"
8
+ "url": "https://github.com/d-zero-dev/BurgerEditor.git"
9
9
  },
10
10
  "private": false,
11
11
  "publishConfig": {
@@ -37,8 +37,9 @@
37
37
  "dist"
38
38
  ],
39
39
  "scripts": {
40
- "build": "tsc",
40
+ "build": "tsc --project tsconfig.build.json",
41
+ "dev": "tsc --watch --project tsconfig.build.json",
41
42
  "clean": "tsc --build --clean"
42
43
  },
43
- "gitHead": "3cc9deb4a7316211f6d75cc14c346775bdb4f907"
44
+ "gitHead": "1cea9c5b36023cad1acfc2b3ef8b18c0d5bf79c2"
44
45
  }