@vitus-labs/rocketstyle 2.6.1 → 2.6.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.
Files changed (2) hide show
  1. package/lib/index.js +27 -15
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -14,6 +14,12 @@ const PSEUDO_KEYS = [
14
14
  ];
15
15
  /** Meta pseudo-state keys representing non-interactive states (disabled, readOnly). */
16
16
  const PSEUDO_META_KEYS = ["disabled", "readOnly"];
17
+ /**
18
+ * Pre-merged interaction + meta keys. Hoisted from `rocketstyle.tsx`'s render
19
+ * body so the `pick(props, [...PSEUDO_KEYS, ...PSEUDO_META_KEYS])` call no
20
+ * longer allocates a fresh 6-element array on every render.
21
+ */
22
+ const PSEUDO_AND_META_KEYS = [...PSEUDO_KEYS, ...PSEUDO_META_KEYS];
17
23
  /** Supported theme mode flags. */
18
24
  const THEME_MODES = {
19
25
  light: true,
@@ -281,10 +287,11 @@ const removeUndefinedProps = (props) => {
281
287
  for (const key in props) if (props[key] !== void 0) result[key] = props[key];
282
288
  return result;
283
289
  };
284
- const pickStyledAttrs = (props, keywords) => Object.keys(props).reduce((acc, key) => {
285
- if (keywords[key] && props[key]) acc[key] = props[key];
286
- return acc;
287
- }, {});
290
+ const pickStyledAttrs = (props, keywords) => {
291
+ const result = {};
292
+ for (const key in props) if (keywords[key] && props[key]) result[key] = props[key];
293
+ return result;
294
+ };
288
295
  const calculateChainOptions = (options) => (args) => {
289
296
  const result = {};
290
297
  if (isEmpty(options)) return result;
@@ -494,13 +501,16 @@ const getTheme = ({ rocketstate, themes, baseTheme, transformKeys, appTheme }) =
494
501
  for (const transform of deferredTransforms) merge(finalTheme, transform(finalTheme, appTheme ?? {}, themeModeCallback, config.css));
495
502
  return finalTheme;
496
503
  };
497
- const getThemeByMode = (object, mode) => Object.keys(object).reduce((acc, key) => {
498
- const value = object[key];
499
- if (typeof value === "object" && value !== null) acc[key] = getThemeByMode(value, mode);
500
- else if (isModeCallback(value)) acc[key] = value(mode);
501
- else acc[key] = value;
504
+ const getThemeByMode = (object, mode) => {
505
+ const acc = {};
506
+ for (const key in object) {
507
+ const value = object[key];
508
+ if (typeof value === "object" && value !== null) acc[key] = getThemeByMode(value, mode);
509
+ else if (isModeCallback(value)) acc[key] = value(mode);
510
+ else acc[key] = value;
511
+ }
502
512
  return acc;
503
- }, {});
513
+ };
504
514
 
505
515
  //#endregion
506
516
  //#region src/rocketstyle.tsx
@@ -519,16 +529,18 @@ const arraysEqual = (a, b) => {
519
529
  const isShallowEqualRocketstate = (a, b) => {
520
530
  if (a === b) return true;
521
531
  if (!a || !b) return false;
522
- const aKeys = Object.keys(a);
523
- if (aKeys.length !== Object.keys(b).length) return false;
524
- for (const k of aKeys) {
532
+ let aCount = 0;
533
+ for (const k in a) {
534
+ aCount++;
525
535
  const av = a[k];
526
536
  const bv = b[k];
527
537
  if (av === bv) continue;
528
538
  if (Array.isArray(av) && Array.isArray(bv) && arraysEqual(av, bv)) continue;
529
539
  return false;
530
540
  }
531
- return true;
541
+ let bCount = 0;
542
+ for (const _ in b) bCount++;
543
+ return aCount === bCount;
532
544
  };
533
545
  /**
534
546
  * Clones the current configuration and merges new options, returning a fresh
@@ -619,7 +631,7 @@ const rocketComponent = (options) => {
619
631
  };
620
632
  const pseudoRocketstate = {
621
633
  ...pseudo,
622
- ...pick(props, [...PSEUDO_KEYS, ...PSEUDO_META_KEYS])
634
+ ...pick(props, PSEUDO_AND_META_KEYS)
623
635
  };
624
636
  const rocketstate = _calculateStylingAttrs({
625
637
  props: pickStyledAttrs(mergeProps, reservedPropNames),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/rocketstyle",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "license": "MIT",
5
5
  "author": "Vit Bokisch <vit@bokisch.cz>",
6
6
  "maintainers": [
@@ -64,7 +64,7 @@
64
64
  "typecheck": "tsc --noEmit"
65
65
  },
66
66
  "peerDependencies": {
67
- "@vitus-labs/core": "^2.6.1",
67
+ "@vitus-labs/core": "^2.6.2",
68
68
  "react": ">= 19"
69
69
  },
70
70
  "devDependencies": {