@vendure-io/ui 3.0.0-next.3 → 3.0.0-next.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure-io/ui",
3
- "version": "3.0.0-next.3",
3
+ "version": "3.0.0-next.4",
4
4
  "description": "React component library for Vendure, built on shadcn/ui and Tailwind v4",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://github.com/vendurehq/design/tree/main/packages/ui",
@@ -23,6 +23,7 @@
23
23
  "./lib/*": "./src/lib/*.ts",
24
24
  "./lib/control-name": null,
25
25
  "./lib/dialog-padding": null,
26
+ "./lib/env": null,
26
27
  "./lib/menu-item": null,
27
28
  "./lib/popup-align": null,
28
29
  "./lib/popup-direction": null,
@@ -11,6 +11,7 @@ import { LabelSwap } from "./label-swap.tsx"
11
11
  import { contentInsetPull } from "@vendure-io/ui/lib/content-inset"
12
12
  import { cn } from "@vendure-io/ui/lib/utils"
13
13
  import { outlineEdge, outlineEdgeHover } from "@vendure-io/ui/lib/outline-edge"
14
+ import { isDevelopment } from "../../lib/env.ts"
14
15
 
15
16
  // The v3 look: 34px default and 28px sm, the xl radius, 14px medium text.
16
17
  // Every size keeps its side padding with or without a `data-icon` icon;
@@ -226,7 +227,7 @@ function Button({ className, variant = "default", size = "default", render, nati
226
227
  const isLink = rendersLink(render)
227
228
  const ref = useUndetectedLinkCheck(
228
229
  props.ref,
229
- process.env.NODE_ENV !== "production" && Boolean(render) && !isLink
230
+ isDevelopment && Boolean(render) && !isLink
230
231
  )
231
232
  if (isLink) {
232
233
  return <LinkButton className={className} variant={variant} size={size} render={render} {...props} />
@@ -3,7 +3,7 @@
3
3
  import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
4
4
 
5
5
  import { cn } from "@vendure-io/ui/lib/utils"
6
- import { useUserToggleMotion } from "../../hooks/use-user-toggle-motion"
6
+ import { useUserToggleMotion } from "../../hooks/use-user-toggle-motion.ts"
7
7
  import {
8
8
  useFieldControlProps,
9
9
  useFieldLabelCheckedClass,
@@ -5,6 +5,7 @@ import { cn } from '@vendure-io/ui/lib/utils';
5
5
  import type { VariantProps } from 'class-variance-authority';
6
6
  import { XIcon } from 'lucide-react';
7
7
  import type * as React from 'react';
8
+ import { isDevelopment } from '../../lib/env.ts';
8
9
 
9
10
  interface ChipProps extends React.ComponentProps<'span'> {
10
11
  /** Badge variants a tag can take. `link` and `ghost` are not tag treatments. */
@@ -62,7 +63,7 @@ function Chip({
62
63
  children,
63
64
  ...props
64
65
  }: ChipProps) {
65
- if (process.env.NODE_ENV !== 'production' && onRemove && !removeLabel) {
66
+ if (isDevelopment && onRemove && !removeLabel) {
66
67
  console.warn(
67
68
  'Chip: `removeLabel` is required when `onRemove` is set — the remove button has no accessible name otherwise. Pass e.g. removeLabel="Remove <name>".',
68
69
  );
@@ -71,6 +71,7 @@ import { ChevronRight } from 'lucide-react';
71
71
  import { AnimatePresence, MotionConfig, motion, useReducedMotion } from 'motion/react';
72
72
  import * as React from 'react';
73
73
  import { createPortal } from 'react-dom';
74
+ import { isDevelopment } from '../../../lib/env.ts';
74
75
  // Relative: `data-table-helpers` is closed in the package exports.
75
76
  import {
76
77
  buildDisplayColumns,
@@ -745,7 +746,7 @@ function DataTable<TData>({
745
746
  }: DataTableProps<TData>) {
746
747
  const warnedMissingPaginatedSelectionRowId = React.useRef(false);
747
748
  if (
748
- process.env.NODE_ENV !== 'production' &&
749
+ isDevelopment &&
749
750
  rowSelection != null &&
750
751
  pagination != null &&
751
752
  pagination.mode !== 'client' &&
@@ -1137,11 +1138,7 @@ function DataTable<TData>({
1137
1138
  };
1138
1139
 
1139
1140
  const warnedUnknownSkeletonCells = React.useRef(false);
1140
- if (
1141
- process.env.NODE_ENV !== 'production' &&
1142
- skeletonCells != null &&
1143
- !warnedUnknownSkeletonCells.current
1144
- ) {
1141
+ if (isDevelopment && skeletonCells != null && !warnedUnknownSkeletonCells.current) {
1145
1142
  const knownIds = new Set(
1146
1143
  table
1147
1144
  .getAllLeafColumns()
@@ -3,6 +3,7 @@
3
3
  import { useFormatSettings } from '@vendure-io/ui/components/molecules/format-provider';
4
4
  import { cn } from '@vendure-io/ui/lib/utils';
5
5
  import type { ComponentProps } from 'react';
6
+ import { isDevelopment } from '../../lib/env.ts';
6
7
 
7
8
  // How many minor-unit digits a currency uses — 2 for USD (cents), 0 for JPY, 3
8
9
  // for BHD. Derived from Intl rather than a hardcoded `/100`, which is wrong for
@@ -60,7 +61,7 @@ function Money({
60
61
  const resolvedPrecision =
61
62
  precision ?? settings.currencyPrecision ?? currencyFractionDigits(resolvedCurrency);
62
63
 
63
- if (!resolvedCurrency && !warnedMissingCurrency && process.env.NODE_ENV !== 'production') {
64
+ if (!resolvedCurrency && !warnedMissingCurrency && isDevelopment) {
64
65
  warnedMissingCurrency = true;
65
66
  console.warn(
66
67
  '<Money> was rendered without a `currency` prop or a `FormatProvider` currency; ' +
@@ -10,6 +10,7 @@ import {
10
10
  } from '@vendure-io/ui/components/atoms/select';
11
11
  import { cn } from '@vendure-io/ui/lib/utils';
12
12
  import * as React from 'react';
13
+ import { isDevelopment } from '../../lib/env.ts';
13
14
 
14
15
  type ItemValue = string | number;
15
16
 
@@ -104,7 +105,7 @@ function MultiSelect<T>({
104
105
  const map = new Map<ItemValue, T>();
105
106
  for (const item of items) {
106
107
  const itemValue = getValue(item);
107
- if (process.env.NODE_ENV !== 'production') {
108
+ if (isDevelopment) {
108
109
  if (typeof itemValue !== 'string' && typeof itemValue !== 'number') {
109
110
  console.warn(
110
111
  'MultiSelect: `itemToValue` must resolve to a string or number. When `items` are ' +
package/src/lib/env.ts ADDED
@@ -0,0 +1,9 @@
1
+ // The build mode, read in one place. The design system ships its source, and a
2
+ // consumer type-checks it without Node types (the Console's app-shell package,
3
+ // for one). So `process` is declared here for this module only. Keep the
4
+ // literal `process.env.NODE_ENV`: bundlers replace it, so a production build
5
+ // drops the development-only checks.
6
+ declare const process: { env: { NODE_ENV?: string } };
7
+
8
+ /** True outside a production build: development warnings and checks run. */
9
+ export const isDevelopment = process.env.NODE_ENV !== 'production';
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
+ import { isDevelopment } from './env.ts';
2
3
 
3
4
  /**
4
5
  * The state dictionary — the mechanism that makes the same entity state look
@@ -72,8 +73,6 @@ export function stateNameToWords(state: string): string {
72
73
  return sentence.charAt(0).toUpperCase() + sentence.slice(1);
73
74
  }
74
75
 
75
- const isDev = process.env.NODE_ENV !== 'production';
76
-
77
76
  /**
78
77
  * Declare a domain's state→tone map. The `Record<S, StateEntry>` argument is
79
78
  * exhaustive over `S`, so typing the call as `defineStateEntries<DeploymentStatus>`
@@ -94,7 +93,7 @@ export function defineStateEntries<S extends string>(entries: Record<S, StateEnt
94
93
  const entry = index.get(key);
95
94
  // Dedup on the lowercased key so casing variants of the same unknown state
96
95
  // ("Foo" / "foo") warn once — matching the lookup semantics.
97
- if (!entry && isDev && !warned.has(key)) {
96
+ if (!entry && isDevelopment && !warned.has(key)) {
98
97
  warned.add(key);
99
98
  console.warn(
100
99
  `[state-dictionary] Unmapped state "${state}" — rendering as neutral. ` +