@hanzogui/web 7.3.0 → 7.3.1

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": "@hanzogui/web",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
4
4
  "license": "BSD-3-Clause",
5
5
  "author": "Hanzo AI <dev@hanzo.ai>",
6
6
  "repository": {
@@ -49,20 +49,20 @@
49
49
  "test:web": "vitest --typecheck --run"
50
50
  },
51
51
  "dependencies": {
52
- "@hanzogui/compose-refs": "7.3.0",
53
- "@hanzogui/constants": "7.3.0",
54
- "@hanzogui/helpers": "7.3.0",
55
- "@hanzogui/is-equal-shallow": "7.3.0",
56
- "@hanzogui/native": "7.3.0",
57
- "@hanzogui/normalize-css-color": "7.3.0",
58
- "@hanzogui/timer": "7.3.0",
52
+ "@hanzogui/compose-refs": "7.3.1",
53
+ "@hanzogui/constants": "7.3.1",
54
+ "@hanzogui/helpers": "7.3.1",
55
+ "@hanzogui/is-equal-shallow": "7.3.1",
56
+ "@hanzogui/native": "7.3.1",
57
+ "@hanzogui/normalize-css-color": "7.3.1",
58
+ "@hanzogui/timer": "7.3.1",
59
59
  "@hanzogui/types": "7.3.0",
60
- "@hanzogui/use-did-finish-ssr": "7.3.0",
61
- "@hanzogui/use-event": "7.3.0",
62
- "@hanzogui/use-force-update": "7.3.0"
60
+ "@hanzogui/use-did-finish-ssr": "7.3.1",
61
+ "@hanzogui/use-event": "7.3.1",
62
+ "@hanzogui/use-force-update": "7.3.1"
63
63
  },
64
64
  "devDependencies": {
65
- "@hanzogui/build": "7.3.0",
65
+ "@hanzogui/build": "7.3.1",
66
66
  "@testing-library/react": "^16.1.0",
67
67
  "csstype": "^3.0.10",
68
68
  "react": ">=19",
@@ -84,5 +84,10 @@
84
84
  "*.mjs",
85
85
  "*.css",
86
86
  "README.md"
87
- ]
87
+ ],
88
+ "peerDependenciesMeta": {
89
+ "react-native": {
90
+ "optional": true
91
+ }
92
+ }
88
93
  }
@@ -56,6 +56,26 @@ import { Slot } from './views/Slot'
56
56
  import { getThemedChildren } from './views/Theme'
57
57
  import type { ViewProps } from './views/View'
58
58
 
59
+ // data-slot: a neutral, standard structural annotation for zero-config analytics.
60
+ // Mirrors shadcn's convention — the component's name, kebab-cased — so a tracker
61
+ // like track.js's `annotate` can capture DOM structure with no per-app config.
62
+ // Only named components carry one (base View/Text/Stack have no componentName),
63
+ // matching shadcn's "named primitives only" rule.
64
+ // Memoized: names come from the fixed set of styled() definitions, so each is
65
+ // kebab-cased once — the render path is then an O(1) hit with no per-render regex.
66
+ const dataSlotCache = new Map<string, string>()
67
+ const dataSlotFor = (name: string): string => {
68
+ let slot = dataSlotCache.get(name)
69
+ if (slot === undefined) {
70
+ slot = name
71
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
72
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
73
+ .toLowerCase()
74
+ dataSlotCache.set(name, slot)
75
+ }
76
+ return slot
77
+ }
78
+
59
79
  /**
60
80
  * All things that need one-time setup after createGui is called
61
81
  */
@@ -1471,6 +1491,15 @@ export function createComponent<
1471
1491
 
1472
1492
  if (process.env.NODE_ENV === 'development' && time) time`spaced-as-child`
1473
1493
 
1494
+ // Stamp a neutral, standard structural annotation (data-slot) on the web host
1495
+ // node so analytics can self-describe with zero app config. Named components
1496
+ // only; overridable — passing your own `data-slot` (any value) opts out.
1497
+ // No-op on native (isWeb compiles to false there). asChild flows via Slot,
1498
+ // which merges viewProps onto the child host, so it is covered too.
1499
+ if (isWeb && componentName && !('data-slot' in viewProps)) {
1500
+ viewProps['data-slot'] = dataSlotFor(componentName)
1501
+ }
1502
+
1474
1503
  let content: ReactNode | undefined
1475
1504
 
1476
1505
  if (isPassthrough) {