@jsenv/navi 0.18.18 → 0.18.20

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.
@@ -630,109 +630,6 @@ const stringifyForDisplay = (
630
630
  return String(value);
631
631
  };
632
632
 
633
- /**
634
- * Reactively runs an action whenever the params derived from signals change.
635
- *
636
- * @param {object} action - The action to run.
637
- * @param {Function} deriveActionParamsFromSignals - A function that reads signals and returns
638
- * the params to pass to the action. It is re-evaluated automatically whenever a signal it
639
- * read changes. Return `false`/`null`/`undefined` to skip running the action.
640
- * @param {object} [options]
641
- * @param {number} [options.debounce] - When set, the action is only run once the derived params
642
- * have been stable for this many milliseconds. Useful to avoid firing a backend call on every
643
- * keystroke: set `debounce: 500` and the request is sent only after the user stops interacting
644
- * with the filters for 500 ms.
645
- *
646
- * Example — auto-refresh a result list while the user tweaks filters:
647
- * ```js
648
- * actionRunEffect(searchAction, () => ({
649
- * query: querySignal.value,
650
- * page: pageSignal.value,
651
- * }), { debounce: 500 });
652
- * ```
653
- * The action will not fire while the user is actively changing filters; it fires once
654
- * they pause for half a second.
655
- */
656
- const actionRunEffect = (
657
- action,
658
- deriveActionParamsFromSignals,
659
- { debounce, meta } = {},
660
- ) => {
661
- let lastTruthyParams;
662
- let actionParamsSignal = computed(() => {
663
- const params = deriveActionParamsFromSignals();
664
- action.debug(
665
- `Derived params for action "${action}": ${stringifyForDisplay(params)}`,
666
- );
667
- if (!params) {
668
- // normalize falsy values to undefined so that any falsy value ends up in the same state of "don't run the action"
669
- return undefined;
670
- }
671
- if (params && typeof params.then === "function") {
672
- {
673
- console.warn(
674
- `actionRunEffect second arg is returning a promise. This is not supported, the function should be sync and return params to give to the action`,
675
- );
676
- }
677
- }
678
- if (lastTruthyParams === undefined) {
679
- lastTruthyParams = params;
680
- }
681
- return params;
682
- });
683
- if (debounce) {
684
- actionParamsSignal = debounceSignal(actionParamsSignal, {
685
- delay: debounce,
686
- });
687
- }
688
-
689
- const actionRunnedByThisEffect = action.bindParams(actionParamsSignal, {
690
- syncParams: debounce ? actionParamsSignal.flush : undefined,
691
- onChange: (actionTarget, actionTargetPrevious, { explicitRunIntent }) => {
692
- if (explicitRunIntent) {
693
- // The caller already issued an explicit run/rerun/prerun/reset/abort —
694
- // don't attempt to also auto-run from the params change to avoid double-runs.
695
- action.debug(
696
- `"${actionTarget}": explicit run intent detected -> skipping auto-run from params change`,
697
- );
698
- return;
699
- }
700
- if (!actionTargetPrevious && actionTarget) {
701
- // first run
702
- if (!actionTarget.params) {
703
- // falsy params, don't run
704
- return;
705
- }
706
- actionTarget.run({ reason: "truthy params first run" });
707
- return;
708
- }
709
-
710
- if (
711
- actionTargetPrevious &&
712
- !actionTargetPrevious.isPrerun &&
713
- actionTarget
714
- ) {
715
- // params changed
716
- if (!actionTarget.params) {
717
- // falsy params, don't run
718
- actionTargetPrevious.abort("abortOnFalsyParams");
719
- return;
720
- }
721
- if (compareTwoJsValues(lastTruthyParams, actionTarget.params)) {
722
- actionTarget.run({ reason: "params restored to last truthy value" });
723
- } else {
724
- actionTarget.rerun({ reason: "params modified" });
725
- }
726
- }
727
- },
728
- meta,
729
- });
730
- if (actionParamsSignal.peek()) {
731
- actionRunnedByThisEffect.run({ reason: "initial truthy params" });
732
- }
733
- return actionRunnedByThisEffect;
734
- };
735
-
736
633
  /**
737
634
  * jsenv/navi - createJsValueWeakMap
738
635
  *
@@ -2386,6 +2283,110 @@ const COMPLETED_ACTION = createAction(() => undefined, {
2386
2283
  });
2387
2284
  getActionPrivateProperties(COMPLETED_ACTION).performRun({});
2388
2285
 
2286
+ /**
2287
+ * Reactively runs an action whenever the params derived from signals change.
2288
+ *
2289
+ * @param {object} action - The action to run.
2290
+ * @param {Function} deriveActionParamsFromSignals - A function that reads signals and returns
2291
+ * the params to pass to the action. It is re-evaluated automatically whenever a signal it
2292
+ * read changes. Return `false`/`null`/`undefined` to skip running the action.
2293
+ * @param {object} [options]
2294
+ * @param {number} [options.debounce] - When set, the action is only run once the derived params
2295
+ * have been stable for this many milliseconds. Useful to avoid firing a backend call on every
2296
+ * keystroke: set `debounce: 500` and the request is sent only after the user stops interacting
2297
+ * with the filters for 500 ms.
2298
+ *
2299
+ * Example — auto-refresh a result list while the user tweaks filters:
2300
+ * ```js
2301
+ * actionRunEffect(searchAction, () => ({
2302
+ * query: querySignal.value,
2303
+ * page: pageSignal.value,
2304
+ * }), { debounce: 500 });
2305
+ * ```
2306
+ * The action will not fire while the user is actively changing filters; it fires once
2307
+ * they pause for half a second.
2308
+ */
2309
+ const actionRunEffect = (
2310
+ action,
2311
+ deriveActionParamsFromSignals,
2312
+ { debounce, meta } = {},
2313
+ ) => {
2314
+ if (typeof action === "function") action = createAction(action);
2315
+ let lastTruthyParams;
2316
+ let actionParamsSignal = computed(() => {
2317
+ const params = deriveActionParamsFromSignals();
2318
+ action.debug(
2319
+ `Derived params for action "${action}": ${stringifyForDisplay(params)}`,
2320
+ );
2321
+ if (!params) {
2322
+ // normalize falsy values to undefined so that any falsy value ends up in the same state of "don't run the action"
2323
+ return undefined;
2324
+ }
2325
+ if (params && typeof params.then === "function") {
2326
+ {
2327
+ console.warn(
2328
+ `actionRunEffect second arg is returning a promise. This is not supported, the function should be sync and return params to give to the action`,
2329
+ );
2330
+ }
2331
+ }
2332
+ if (lastTruthyParams === undefined) {
2333
+ lastTruthyParams = params;
2334
+ }
2335
+ return params;
2336
+ });
2337
+ if (debounce) {
2338
+ actionParamsSignal = debounceSignal(actionParamsSignal, {
2339
+ delay: debounce,
2340
+ });
2341
+ }
2342
+
2343
+ const actionRunnedByThisEffect = action.bindParams(actionParamsSignal, {
2344
+ syncParams: debounce ? actionParamsSignal.flush : undefined,
2345
+ onChange: (actionTarget, actionTargetPrevious, { explicitRunIntent }) => {
2346
+ if (explicitRunIntent) {
2347
+ // The caller already issued an explicit run/rerun/prerun/reset/abort —
2348
+ // don't attempt to also auto-run from the params change to avoid double-runs.
2349
+ action.debug(
2350
+ `"${actionTarget}": explicit run intent detected -> skipping auto-run from params change`,
2351
+ );
2352
+ return;
2353
+ }
2354
+ if (!actionTargetPrevious && actionTarget) {
2355
+ // first run
2356
+ if (!actionTarget.params) {
2357
+ // falsy params, don't run
2358
+ return;
2359
+ }
2360
+ actionTarget.run({ reason: "truthy params first run" });
2361
+ return;
2362
+ }
2363
+
2364
+ if (
2365
+ actionTargetPrevious &&
2366
+ !actionTargetPrevious.isPrerun &&
2367
+ actionTarget
2368
+ ) {
2369
+ // params changed
2370
+ if (!actionTarget.params) {
2371
+ // falsy params, don't run
2372
+ actionTargetPrevious.abort("abortOnFalsyParams");
2373
+ return;
2374
+ }
2375
+ if (compareTwoJsValues(lastTruthyParams, actionTarget.params)) {
2376
+ actionTarget.run({ reason: "params restored to last truthy value" });
2377
+ } else {
2378
+ actionTarget.rerun({ reason: "params modified" });
2379
+ }
2380
+ }
2381
+ },
2382
+ meta,
2383
+ });
2384
+ if (actionParamsSignal.peek()) {
2385
+ actionRunnedByThisEffect.run({ reason: "initial truthy params" });
2386
+ }
2387
+ return actionRunnedByThisEffect;
2388
+ };
2389
+
2389
2390
  const useActionData = (action) => {
2390
2391
  if (!action) {
2391
2392
  return undefined;
@@ -29713,9 +29714,6 @@ installImportMetaCss(import.meta);import.meta.css = /* css */`
29713
29714
  letter-spacing: 0.06em;
29714
29715
  }
29715
29716
  .navi_quantity_body {
29716
- .navi_quantity_value {
29717
- font-weight: bold;
29718
- }
29719
29717
  .navi_quantity_unit {
29720
29718
  color: var(--unit-color);
29721
29719
  font-weight: normal;
@@ -29800,6 +29798,7 @@ const Quantity = ({
29800
29798
  loading,
29801
29799
  readOnly,
29802
29800
  disabled,
29801
+ bold = true,
29803
29802
  ...props
29804
29803
  }) => {
29805
29804
  const value = parseQuantityValue(children);
@@ -29819,6 +29818,7 @@ const Quantity = ({
29819
29818
  },
29820
29819
  pseudoClasses: QuantityPseudoClasses,
29821
29820
  spacing: "pre",
29821
+ bold: bold,
29822
29822
  ...props,
29823
29823
  children: [label && jsx("span", {
29824
29824
  className: "navi_quantity_label",