@ktjs/shared 0.23.1 → 0.23.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/index.d.ts CHANGED
@@ -30,7 +30,12 @@ declare const $toString: () => string;
30
30
  declare const $keys: <T>(o: T) => Array<keyof T>;
31
31
  declare const $defines: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
32
32
  declare const $define: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
33
- declare const $entries: <T>(o: T) => Array<[keyof T, T[keyof T]]>;
33
+ declare const $entries: {
34
+ <T>(o: {
35
+ [s: string]: T;
36
+ } | ArrayLike<T>): [string, T][];
37
+ (o: {}): [string, any][];
38
+ };
34
39
  declare const $random: () => number;
35
40
  declare const $isThenable: (o: any) => o is Promise<any>;
36
41
 
@@ -114,7 +119,7 @@ declare const originAppend: (...nodes: (Node | string)[]) => void;
114
119
  declare const $append: typeof originAppend;
115
120
  declare const $buttonDisabledGetter: () => any;
116
121
  declare const $buttonDisabledSetter: (v: any) => void;
117
- declare const parseStyle: (style: string | Partial<CSSStyleDeclaration> | undefined) => string;
122
+ declare const parseStyle: (style: unknown) => string;
118
123
  type ChangeHandler<T = string> = (value: T, ...args: any[]) => void;
119
124
  /**
120
125
  * Used for `k-model`
@@ -26,7 +26,7 @@ var __ktjs_shared__ = (function (exports) {
26
26
  const $keys = Object.keys;
27
27
  const $defines = Object.defineProperties;
28
28
  const $define = Object.defineProperty;
29
- const $entries = Object.entries;
29
+ const $entries = Object.entries; // as <T>(o: T) => Array<[keyof T, T[keyof T]]>;
30
30
  const $random = Math.random;
31
31
  const $isThenable = (o) => typeof o?.then === 'function';
32
32
 
@@ -80,19 +80,23 @@ var __ktjs_shared__ = (function (exports) {
80
80
  }
81
81
  };
82
82
  const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
83
- // # DOM utilities
84
83
  const parseStyle = (style) => {
84
+ if (!style) {
85
+ return '';
86
+ }
85
87
  if (typeof style === 'string') {
86
88
  return style;
87
89
  }
88
90
  if (style && typeof style === 'object') {
89
- return Object.entries(style)
90
- .map(([key, value]) => {
91
- // Convert camelCase to kebab-case
92
- const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
93
- return `${cssKey}: ${value}`;
91
+ if (style.isKT) {
92
+ return parseStyle(style.value);
93
+ }
94
+ return $entries(style)
95
+ .map((entry) => {
96
+ const cssKey = entry[0].replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
97
+ return `${cssKey}:${entry[1]}`;
94
98
  })
95
- .join('; ');
99
+ .join(';');
96
100
  }
97
101
  return '';
98
102
  };
@@ -197,7 +201,7 @@ var __ktjs_shared__ = (function (exports) {
197
201
  }
198
202
 
199
203
  // Shared utilities and cached native methods for kt.js framework
200
- Object.defineProperty(window, '__ktjs__', { value: '0.23.1' });
204
+ Object.defineProperty(window, '__ktjs__', { value: '0.23.2' });
201
205
 
202
206
  exports.$ArrayFrom = $ArrayFrom;
203
207
  exports.$append = $append;
@@ -26,7 +26,7 @@ var __ktjs_shared__ = (function (exports) {
26
26
  var $keys = Object.keys;
27
27
  var $defines = Object.defineProperties;
28
28
  var $define = Object.defineProperty;
29
- var $entries = Object.entries;
29
+ var $entries = Object.entries; // as <T>(o: T) => Array<[keyof T, T[keyof T]]>;
30
30
  var $random = Math.random;
31
31
  var $isThenable = function (o) { return typeof (o === null || o === void 0 ? void 0 : o.then) === 'function'; };
32
32
 
@@ -85,20 +85,23 @@ var __ktjs_shared__ = (function (exports) {
85
85
  }
86
86
  };
87
87
  var $buttonDisabledGetter = (_a = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled'), _a.get), $buttonDisabledSetter = _a.set;
88
- // # DOM utilities
89
88
  var parseStyle = function (style) {
89
+ if (!style) {
90
+ return '';
91
+ }
90
92
  if (typeof style === 'string') {
91
93
  return style;
92
94
  }
93
95
  if (style && typeof style === 'object') {
94
- return Object.entries(style)
95
- .map(function (_a) {
96
- var key = _a[0], value = _a[1];
97
- // Convert camelCase to kebab-case
98
- var cssKey = key.replace(/[A-Z]/g, function (m) { return "-".concat(m.toLowerCase()); });
99
- return "".concat(cssKey, ": ").concat(value);
96
+ if (style.isKT) {
97
+ return parseStyle(style.value);
98
+ }
99
+ return $entries(style)
100
+ .map(function (entry) {
101
+ var cssKey = entry[0].replace(/[A-Z]/g, function (m) { return "-".concat(m.toLowerCase()); });
102
+ return "".concat(cssKey, ":").concat(entry[1]);
100
103
  })
101
- .join('; ');
104
+ .join(';');
102
105
  }
103
106
  return '';
104
107
  };
@@ -208,7 +211,7 @@ var __ktjs_shared__ = (function (exports) {
208
211
  }
209
212
 
210
213
  // Shared utilities and cached native methods for kt.js framework
211
- Object.defineProperty(window, '__ktjs__', { value: '0.23.1' });
214
+ Object.defineProperty(window, '__ktjs__', { value: '0.23.2' });
212
215
 
213
216
  exports.$ArrayFrom = $ArrayFrom;
214
217
  exports.$append = $append;
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ const $toString = Object.prototype.toString;
23
23
  const $keys = Object.keys;
24
24
  const $defines = Object.defineProperties;
25
25
  const $define = Object.defineProperty;
26
- const $entries = Object.entries;
26
+ const $entries = Object.entries; // as <T>(o: T) => Array<[keyof T, T[keyof T]]>;
27
27
  const $random = Math.random;
28
28
  const $isThenable = (o) => typeof o?.then === 'function';
29
29
 
@@ -77,19 +77,23 @@ const $append = // for ie 9/10/11
77
77
  }
78
78
  };
79
79
  const { get: $buttonDisabledGetter, set: $buttonDisabledSetter } = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, 'disabled');
80
- // # DOM utilities
81
80
  const parseStyle = (style) => {
81
+ if (!style) {
82
+ return '';
83
+ }
82
84
  if (typeof style === 'string') {
83
85
  return style;
84
86
  }
85
87
  if (style && typeof style === 'object') {
86
- return Object.entries(style)
87
- .map(([key, value]) => {
88
- // Convert camelCase to kebab-case
89
- const cssKey = key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
90
- return `${cssKey}: ${value}`;
88
+ if (style.isKT) {
89
+ return parseStyle(style.value);
90
+ }
91
+ return $entries(style)
92
+ .map((entry) => {
93
+ const cssKey = entry[0].replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
94
+ return `${cssKey}:${entry[1]}`;
91
95
  })
92
- .join('; ');
96
+ .join(';');
93
97
  }
94
98
  return '';
95
99
  };
@@ -194,6 +198,6 @@ if (typeof Symbol === 'undefined') {
194
198
  }
195
199
 
196
200
  // Shared utilities and cached native methods for kt.js framework
197
- Object.defineProperty(window, '__ktjs__', { value: '0.23.1' });
201
+ Object.defineProperty(window, '__ktjs__', { value: '0.23.2' });
198
202
 
199
203
  export { $ArrayFrom, $append, $appendChild, $assign, $buttonDisabledGetter, $buttonDisabledSetter, $define, $defines, $emptyFn, $entries, $hasOwn, $is, $isArray, $isNode, $isSame, $isThenable, $keys, $random, $replaceNode, $toString, DIRV_TYPE, MATHML_ATTR_FLAG, SVG_ATTR_FLAG, applyModel, buildQuery, emplaceParams, extractParams, normalizePath, parseQuery, parseStyle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/shared",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "description": "Shared utilities and cached native methods for kt.js framework",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",