@player-ui/reference-assets-plugin-react 0.8.0--canary.307.9621 → 0.8.0-next.0

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 (76) hide show
  1. package/dist/cjs/index.cjs +581 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.css +703 -0
  4. package/dist/index.legacy-esm.js +529 -0
  5. package/dist/index.mjs +529 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +34 -63
  8. package/src/__tests__/integration.test.tsx +158 -0
  9. package/src/assets/action/Action.tsx +10 -14
  10. package/src/assets/action/hooks.tsx +6 -6
  11. package/src/assets/action/index.ts +2 -2
  12. package/src/assets/choice/Choice.tsx +52 -0
  13. package/src/assets/choice/hooks.tsx +34 -0
  14. package/src/assets/choice/index.ts +2 -0
  15. package/src/assets/collection/Collection.tsx +6 -9
  16. package/src/assets/collection/index.tsx +1 -1
  17. package/src/assets/image/Image.tsx +4 -4
  18. package/src/assets/image/index.tsx +1 -1
  19. package/src/assets/index.tsx +7 -6
  20. package/src/assets/info/Info.tsx +26 -29
  21. package/src/assets/info/index.tsx +1 -1
  22. package/src/assets/input/Input.tsx +27 -19
  23. package/src/assets/input/hooks.tsx +35 -35
  24. package/src/assets/input/index.tsx +2 -2
  25. package/src/assets/input/types.ts +2 -2
  26. package/src/assets/text/Text.tsx +13 -7
  27. package/src/assets/text/hooks.tsx +6 -6
  28. package/src/assets/text/index.tsx +2 -2
  29. package/src/components/Button.tsx +56 -0
  30. package/src/components/ChoiceItem.tsx +31 -0
  31. package/src/components/Input.tsx +26 -0
  32. package/src/components/Label.tsx +26 -0
  33. package/src/components/Separator.tsx +30 -0
  34. package/src/global.css +83 -0
  35. package/src/index.tsx +4 -2
  36. package/src/intro.stories.mdx +9 -9
  37. package/src/plugin.tsx +22 -43
  38. package/src/utils.ts +6 -0
  39. package/types/assets/action/Action.d.ts +7 -0
  40. package/types/assets/action/hooks.d.ts +9 -0
  41. package/types/assets/action/index.d.ts +3 -0
  42. package/types/assets/choice/Choice.d.ts +6 -0
  43. package/types/assets/choice/hooks.d.ts +5 -0
  44. package/types/assets/choice/index.d.ts +3 -0
  45. package/types/assets/collection/Collection.d.ts +4 -0
  46. package/types/assets/collection/index.d.ts +2 -0
  47. package/types/assets/image/Image.d.ts +4 -0
  48. package/types/assets/image/index.d.ts +2 -0
  49. package/types/assets/index.d.ts +8 -0
  50. package/types/assets/info/Info.d.ts +5 -0
  51. package/types/assets/info/index.d.ts +2 -0
  52. package/types/assets/input/Input.d.ts +6 -0
  53. package/types/assets/input/hooks.d.ts +40 -0
  54. package/types/assets/input/index.d.ts +3 -0
  55. package/types/assets/input/types.d.ts +3 -0
  56. package/types/assets/text/Text.d.ts +7 -0
  57. package/types/assets/text/hooks.d.ts +9 -0
  58. package/types/assets/text/index.d.ts +3 -0
  59. package/types/components/Button.d.ts +12 -0
  60. package/types/components/ChoiceItem.d.ts +7 -0
  61. package/types/components/Input.d.ts +6 -0
  62. package/types/components/Label.d.ts +6 -0
  63. package/types/components/Separator.d.ts +5 -0
  64. package/types/index.d.ts +4 -0
  65. package/types/plugin.d.ts +19 -0
  66. package/types/utils.d.ts +3 -0
  67. package/dist/index.cjs.js +0 -501
  68. package/dist/index.d.ts +0 -94
  69. package/dist/index.esm.js +0 -479
  70. package/dist/xlr/ActionAsset.json +0 -126
  71. package/dist/xlr/CollectionAsset.json +0 -40
  72. package/dist/xlr/InfoAsset.json +0 -58
  73. package/dist/xlr/InputAsset.json +0 -109
  74. package/dist/xlr/TextAsset.json +0 -125
  75. package/dist/xlr/manifest.js +0 -16
  76. package/dist/xlr/manifest.json +0 -22
@@ -0,0 +1,581 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/index.tsx
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Action: () => Action,
34
+ Choice: () => Choice,
35
+ Collection: () => Collection,
36
+ Image: () => Image,
37
+ Info: () => Info,
38
+ Input: () => Input2,
39
+ ReferenceAssetsPlugin: () => ReferenceAssetsPlugin,
40
+ Text: () => Text,
41
+ TextModifierContext: () => TextModifierContext,
42
+ getConfig: () => getConfig,
43
+ getLinkModifier: () => getLinkModifier,
44
+ useAction: () => useAction,
45
+ useChoiceItems: () => useChoiceItems,
46
+ useInputAsset: () => useInputAsset,
47
+ useInputBeacon: () => useInputBeacon,
48
+ useText: () => useText
49
+ });
50
+ module.exports = __toCommonJS(src_exports);
51
+
52
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/plugin.tsx
53
+ var import_asset_provider_plugin_react = require("@player-ui/asset-provider-plugin-react");
54
+ var import_reference_assets_plugin2 = require("@player-ui/reference-assets-plugin");
55
+
56
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/input/Input.tsx
57
+ var import_react2 = __toESM(require("react"));
58
+ var import_react3 = require("@player-ui/react");
59
+
60
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/Input.tsx
61
+ var React = __toESM(require("react"));
62
+
63
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/utils.ts
64
+ var import_clsx = require("clsx");
65
+ var import_tailwind_merge = require("tailwind-merge");
66
+ function cn(...inputs) {
67
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
68
+ }
69
+
70
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/Input.tsx
71
+ var Input = React.forwardRef(
72
+ ({ className, type, ...props }, ref) => {
73
+ return /* @__PURE__ */ React.createElement(
74
+ "input",
75
+ {
76
+ type,
77
+ className: cn(
78
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
79
+ className
80
+ ),
81
+ ref,
82
+ ...props
83
+ }
84
+ );
85
+ }
86
+ );
87
+ Input.displayName = "Input";
88
+
89
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/Label.tsx
90
+ var React2 = __toESM(require("react"));
91
+ var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
92
+ var import_class_variance_authority = require("class-variance-authority");
93
+ var labelVariants = (0, import_class_variance_authority.cva)(
94
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
95
+ );
96
+ var Label = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React2.createElement(
97
+ LabelPrimitive.Root,
98
+ {
99
+ ref,
100
+ className: cn(labelVariants(), className),
101
+ ...props
102
+ }
103
+ ));
104
+ Label.displayName = LabelPrimitive.Root.displayName;
105
+
106
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/input/hooks.tsx
107
+ var import_react = __toESM(require("react"));
108
+ var import_beacon_plugin_react = require("@player-ui/beacon-plugin-react");
109
+ var defaultKeyStrings = [
110
+ "Delete",
111
+ "Backspace",
112
+ "Tab",
113
+ "Home",
114
+ "End",
115
+ "ArrowLeft",
116
+ "ArrowRight",
117
+ "ArrowUp",
118
+ "ArrowDown",
119
+ "Escape"
120
+ ];
121
+ var getConfig = (userConfig = {}) => {
122
+ return {
123
+ liveFormat: true,
124
+ suppressBeacons: false,
125
+ quickFormatDelay: 200,
126
+ slowFormatDelay: 1e3,
127
+ slowFormatKeys: defaultKeyStrings,
128
+ decimalSymbol: ".",
129
+ prefix: "",
130
+ suffix: "",
131
+ ...userConfig
132
+ };
133
+ };
134
+ var useInputBeacon = (props) => {
135
+ const beaconHandler = (0, import_beacon_plugin_react.useBeacon)({ element: "text_input", asset: props });
136
+ return (newValue) => {
137
+ let action = "modified";
138
+ if (newValue === props.value) {
139
+ return;
140
+ }
141
+ if (newValue && !props.value) {
142
+ action = "added";
143
+ } else if (!newValue && props.value) {
144
+ action = "deleted";
145
+ }
146
+ beaconHandler({ action });
147
+ };
148
+ };
149
+ var useInputAsset = (props, config) => {
150
+ const [localValue, setLocalValue] = import_react.default.useState(props.value ?? "");
151
+ const formatTimerRef = import_react.default.useRef(void 0);
152
+ const inputBeacon = useInputBeacon(props);
153
+ const {
154
+ liveFormat,
155
+ suppressBeacons,
156
+ quickFormatDelay,
157
+ slowFormatDelay,
158
+ slowFormatKeys,
159
+ decimalSymbol,
160
+ prefix,
161
+ suffix
162
+ } = getConfig(config);
163
+ function clearPending() {
164
+ if (formatTimerRef.current) {
165
+ clearTimeout(formatTimerRef.current);
166
+ formatTimerRef.current = void 0;
167
+ }
168
+ }
169
+ function getFormatDelaySpeed(e) {
170
+ const key = slowFormatKeys.every((k) => typeof k === "number") ? e.which : e.key;
171
+ return slowFormatKeys.includes(key) ? slowFormatDelay : quickFormatDelay;
172
+ }
173
+ function handleAffixOnFocus(target) {
174
+ let val = target.value;
175
+ if (suffix)
176
+ val = val.substring(0, val.indexOf(suffix));
177
+ if (prefix && !val.includes(prefix)) {
178
+ val = `${prefix}${val}`;
179
+ }
180
+ return val;
181
+ }
182
+ function handlePrefixEdgeCases(e) {
183
+ const target = e.target;
184
+ const start = target.selectionStart;
185
+ const end = target.selectionEnd;
186
+ const pl = prefix.length;
187
+ const atStart = start === pl;
188
+ const atEnd = end === pl;
189
+ if (start && end && start < pl) {
190
+ e.preventDefault();
191
+ target.setSelectionRange(pl, end - start + pl);
192
+ } else if (e.key === "ArrowLeft" && atStart || e.key === "Backspace" && atStart && atEnd || e.key === "Home") {
193
+ e.preventDefault();
194
+ target.setSelectionRange(prefix.length, prefix.length);
195
+ }
196
+ }
197
+ function formatValueWithAffix(value) {
198
+ if (!value)
199
+ return "";
200
+ return `${prefix}${value}${suffix}`;
201
+ }
202
+ const onKeyDownHandler = (currentValue) => {
203
+ const symbolPosition = currentValue.indexOf(decimalSymbol);
204
+ const newValue = props.format(currentValue) ?? "";
205
+ const newSymbolPosition = newValue.indexOf(decimalSymbol);
206
+ if ((symbolPosition === -1 || symbolPosition === 0) && newSymbolPosition > 0) {
207
+ return {
208
+ newValue: newValue.includes(prefix) ? `${newValue}` : `${prefix}${newValue}`,
209
+ newCursorPosition: newValue.includes(prefix) ? newSymbolPosition : newSymbolPosition + prefix.length
210
+ };
211
+ }
212
+ return {
213
+ newValue: newValue.includes(prefix) ? `${newValue}` : `${prefix}${newValue}`
214
+ };
215
+ };
216
+ const onBlur = (e) => {
217
+ clearPending();
218
+ const formatted = (prefix ? e.target.value.replace(prefix, "") : props.format(e.target.value)) ?? "";
219
+ if (formatted) {
220
+ props.set(formatted);
221
+ setLocalValue(formatValueWithAffix(formatted));
222
+ } else {
223
+ props.set("");
224
+ setLocalValue("");
225
+ }
226
+ if (!suppressBeacons) {
227
+ inputBeacon(formatted);
228
+ }
229
+ };
230
+ const onChange = (e) => {
231
+ setLocalValue(e.target.value);
232
+ };
233
+ const onKeyDown = (e) => {
234
+ clearPending();
235
+ if (prefix)
236
+ handlePrefixEdgeCases(e);
237
+ const target = e.target;
238
+ if (liveFormat) {
239
+ formatTimerRef.current = setTimeout(() => {
240
+ const cursorPosition = target.selectionStart;
241
+ const currentValue = target.value;
242
+ if (cursorPosition !== currentValue.length) {
243
+ return;
244
+ }
245
+ const obj = onKeyDownHandler(currentValue);
246
+ setLocalValue(obj.newValue);
247
+ target.selectionStart = obj.newCursorPosition ?? target.selectionStart;
248
+ target.selectionEnd = obj.newCursorPosition ?? target.selectionEnd;
249
+ }, getFormatDelaySpeed(e));
250
+ }
251
+ };
252
+ const onFocus = (e) => {
253
+ const target = e.target;
254
+ const inputEmpty = target.value === "";
255
+ if (!inputEmpty && suffix || inputEmpty && prefix) {
256
+ setLocalValue(handleAffixOnFocus(target));
257
+ }
258
+ };
259
+ const propsValue = props.value;
260
+ import_react.default.useEffect(() => {
261
+ setLocalValue(formatValueWithAffix(propsValue));
262
+ }, [propsValue]);
263
+ import_react.default.useEffect(() => clearPending, []);
264
+ return {
265
+ onBlur,
266
+ onChange,
267
+ onKeyDown,
268
+ onFocus,
269
+ value: localValue
270
+ };
271
+ };
272
+
273
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/input/Input.tsx
274
+ var Input2 = (props) => {
275
+ const { validation, label, id, note } = props;
276
+ const inputProps = useInputAsset(props);
277
+ return /* @__PURE__ */ import_react2.default.createElement("div", { className: "grid w-full max-w-sm items-center gap-1.5" }, label && /* @__PURE__ */ import_react2.default.createElement(Label, { htmlFor: id }, /* @__PURE__ */ import_react2.default.createElement(import_react3.ReactAsset, { ...label })), /* @__PURE__ */ import_react2.default.createElement(
278
+ Input,
279
+ {
280
+ id,
281
+ "aria-invalid": Boolean(validation),
282
+ "aria-describedby": validation ? `${id}-validation` : void 0,
283
+ ...inputProps
284
+ }
285
+ ), validation && /* @__PURE__ */ import_react2.default.createElement(
286
+ Label,
287
+ {
288
+ id: `${id}-validation`,
289
+ className: "text-[0.8rem] font-medium text-destructive"
290
+ },
291
+ validation.message
292
+ ), note && /* @__PURE__ */ import_react2.default.createElement(Label, { className: "text-[0.8rem] text-muted-foreground" }, /* @__PURE__ */ import_react2.default.createElement(import_react3.ReactAsset, { ...note })));
293
+ };
294
+
295
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/text/Text.tsx
296
+ var import_react6 = __toESM(require("react"));
297
+
298
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/text/hooks.tsx
299
+ var import_react4 = __toESM(require("react"));
300
+ var import_clsx2 = __toESM(require("clsx"));
301
+ var import_react5 = require("@player-ui/react");
302
+ var TextModifierContext = import_react4.default.createContext(void 0);
303
+ var useText = (props) => {
304
+ let className;
305
+ const modifierContext = (0, import_react4.useContext)(TextModifierContext);
306
+ if (props.modifiers && modifierContext?.getClassForModifier) {
307
+ className = (0, import_clsx2.default)(
308
+ ...props.modifiers.map(modifierContext.getClassForModifier)
309
+ );
310
+ }
311
+ return {
312
+ ...(0, import_react5.useAssetProps)(props),
313
+ className,
314
+ children: props.value
315
+ };
316
+ };
317
+
318
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/text/Text.tsx
319
+ var getLinkModifier = (asset) => {
320
+ return asset.modifiers?.find(
321
+ (mod) => mod.type === "link" && mod.metaData?.ref !== void 0
322
+ );
323
+ };
324
+ var Text = (props) => {
325
+ const spanProps = useText(props);
326
+ const linkModifier = getLinkModifier(props);
327
+ const { value } = props;
328
+ if (linkModifier) {
329
+ return /* @__PURE__ */ import_react6.default.createElement(
330
+ "a",
331
+ {
332
+ className: "underline text-blue-600 hover:text-blue-800 visited:text-purple-600",
333
+ href: linkModifier.metaData.ref
334
+ },
335
+ value
336
+ );
337
+ }
338
+ return /* @__PURE__ */ import_react6.default.createElement("span", { ...spanProps }, value);
339
+ };
340
+
341
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/collection/Collection.tsx
342
+ var import_react7 = __toESM(require("react"));
343
+ var import_react8 = require("@player-ui/react");
344
+ var Collection = (props) => {
345
+ return /* @__PURE__ */ import_react7.default.createElement("div", { className: "flex flex-col gap-4" }, props.label && /* @__PURE__ */ import_react7.default.createElement("h3", null, /* @__PURE__ */ import_react7.default.createElement(import_react8.ReactAsset, { ...props.label })), props.values?.map((a) => /* @__PURE__ */ import_react7.default.createElement(import_react8.ReactAsset, { key: a.asset.id, ...a })));
346
+ };
347
+
348
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/action/Action.tsx
349
+ var import_react11 = __toESM(require("react"));
350
+ var import_react12 = require("@player-ui/react");
351
+ var import_lucide_react = require("lucide-react");
352
+ var import_reference_assets_plugin = require("@player-ui/reference-assets-plugin");
353
+
354
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/action/hooks.tsx
355
+ var import_react9 = __toESM(require("react"));
356
+ var import_react10 = require("@player-ui/react");
357
+ var import_beacon_plugin_react2 = require("@player-ui/beacon-plugin-react");
358
+ var useAction = (props) => {
359
+ const { label } = props;
360
+ const beacon = (0, import_beacon_plugin_react2.useBeacon)({
361
+ asset: props,
362
+ action: "clicked",
363
+ element: "button"
364
+ });
365
+ return {
366
+ id: props.id,
367
+ onClick: () => {
368
+ beacon();
369
+ props.run();
370
+ },
371
+ children: label?.asset ? /* @__PURE__ */ import_react9.default.createElement(import_react10.ReactAsset, { ...label?.asset }) : null
372
+ };
373
+ };
374
+
375
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/Button.tsx
376
+ var React9 = __toESM(require("react"));
377
+ var import_react_slot = require("@radix-ui/react-slot");
378
+ var import_class_variance_authority2 = require("class-variance-authority");
379
+ var buttonVariants = (0, import_class_variance_authority2.cva)(
380
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
381
+ {
382
+ variants: {
383
+ variant: {
384
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
385
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
386
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
387
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
388
+ ghost: "hover:bg-accent hover:text-accent-foreground",
389
+ link: "text-primary underline-offset-4 hover:underline"
390
+ },
391
+ size: {
392
+ default: "h-9 px-4 py-2",
393
+ sm: "h-8 rounded-md px-3 text-xs",
394
+ lg: "h-10 rounded-md px-8",
395
+ icon: "h-9 w-9"
396
+ }
397
+ },
398
+ defaultVariants: {
399
+ variant: "default",
400
+ size: "default"
401
+ }
402
+ }
403
+ );
404
+ var Button = React9.forwardRef(
405
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
406
+ const Comp = asChild ? import_react_slot.Slot : "button";
407
+ return /* @__PURE__ */ React9.createElement(
408
+ Comp,
409
+ {
410
+ className: cn(buttonVariants({ variant, size, className })),
411
+ ref,
412
+ ...props
413
+ }
414
+ );
415
+ }
416
+ );
417
+ Button.displayName = "Button";
418
+
419
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/action/Action.tsx
420
+ var Action = (props) => {
421
+ const { label } = props;
422
+ const buttonProps = useAction(props);
423
+ return /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement(
424
+ Button,
425
+ {
426
+ variant: (0, import_reference_assets_plugin.isBackAction)(props) ? "outline" : void 0,
427
+ ...buttonProps
428
+ },
429
+ props?.metaData?.role === "back" && /* @__PURE__ */ import_react11.default.createElement(import_lucide_react.ChevronLeftIcon, null),
430
+ label && /* @__PURE__ */ import_react11.default.createElement(import_react12.ReactAsset, { ...label })
431
+ ));
432
+ };
433
+
434
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/info/Info.tsx
435
+ var import_react13 = __toESM(require("react"));
436
+ var import_react14 = require("@player-ui/react");
437
+
438
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/Separator.tsx
439
+ var React11 = __toESM(require("react"));
440
+ var SeparatorPrimitive = __toESM(require("@radix-ui/react-separator"));
441
+ var Separator = React11.forwardRef(
442
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React11.createElement(
443
+ SeparatorPrimitive.Root,
444
+ {
445
+ ref,
446
+ decorative,
447
+ orientation,
448
+ className: cn(
449
+ "shrink-0 bg-border",
450
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
451
+ className
452
+ ),
453
+ ...props
454
+ }
455
+ )
456
+ );
457
+ Separator.displayName = SeparatorPrimitive.Root.displayName;
458
+
459
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/info/Info.tsx
460
+ var Info = (props) => {
461
+ return /* @__PURE__ */ import_react13.default.createElement("div", { className: "max-w-full" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-4" }, props.title && /* @__PURE__ */ import_react13.default.createElement("h1", { className: "scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl" }, /* @__PURE__ */ import_react13.default.createElement(import_react14.ReactAsset, { ...props.title })), props.subTitle && /* @__PURE__ */ import_react13.default.createElement("h3", { className: "scroll-m-20 text-2xl font-semibold tracking-tight" }, /* @__PURE__ */ import_react13.default.createElement(import_react14.ReactAsset, { ...props.subTitle })), props.primaryInfo && /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(import_react14.ReactAsset, { ...props.primaryInfo })), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-4" }, props?.segmentedActions && /* @__PURE__ */ import_react13.default.createElement(Separator, null), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex justify-between sm:flex-row flex-col-reverse gap-4" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex gap-4" }, props?.segmentedActions?.prev?.map((a) => /* @__PURE__ */ import_react13.default.createElement(import_react14.ReactAsset, { key: a.asset.id, ...a }))), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex gap-4" }, props?.segmentedActions?.next?.map((a) => /* @__PURE__ */ import_react13.default.createElement(import_react14.ReactAsset, { key: a.asset.id, ...a })))))));
462
+ };
463
+
464
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/image/Image.tsx
465
+ var import_react15 = __toESM(require("react"));
466
+ var import_react16 = require("@player-ui/react");
467
+ var Image = (props) => {
468
+ const { metaData, caption, altText } = props;
469
+ return /* @__PURE__ */ import_react15.default.createElement("figure", { className: "figure" }, /* @__PURE__ */ import_react15.default.createElement("img", { className: "figure-img img-fluid", src: metaData.ref, alt: altText }), caption && /* @__PURE__ */ import_react15.default.createElement("figcaption", { className: "figure-caption", style: { marginTop: 15 } }, /* @__PURE__ */ import_react15.default.createElement(import_react16.ReactAsset, { ...caption })));
470
+ };
471
+
472
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/choice/Choice.tsx
473
+ var import_react19 = __toESM(require("react"));
474
+ var import_react20 = require("@player-ui/react");
475
+
476
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/components/ChoiceItem.tsx
477
+ var import_react17 = __toESM(require("react"));
478
+ var import_react18 = require("@player-ui/react");
479
+ var ChoiceItem = (props) => {
480
+ const { label, id, ...rest } = props;
481
+ return /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex items-center gap-1.5" }, /* @__PURE__ */ import_react17.default.createElement(
482
+ Input,
483
+ {
484
+ type: "radio",
485
+ className: "h-fit w-fit shadow-none",
486
+ id,
487
+ ...rest
488
+ }
489
+ ), label && /* @__PURE__ */ import_react17.default.createElement(Label, { htmlFor: id }, /* @__PURE__ */ import_react17.default.createElement(import_react18.ReactAsset, { ...label })));
490
+ };
491
+
492
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/choice/hooks.tsx
493
+ var import_beacon_plugin_react3 = require("@player-ui/beacon-plugin-react");
494
+ var useChoiceItems = (props) => {
495
+ const beacon = (0, import_beacon_plugin_react3.useBeacon)({
496
+ asset: props,
497
+ action: "clicked",
498
+ element: "choice"
499
+ });
500
+ return props.items?.map((item) => {
501
+ const { id, value, label } = item;
502
+ return {
503
+ id,
504
+ label,
505
+ name: props.id,
506
+ value: (value ?? "").toString(),
507
+ checked: value === props.value,
508
+ onChange: () => {
509
+ beacon();
510
+ item.select();
511
+ }
512
+ };
513
+ }) ?? [];
514
+ };
515
+
516
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/assets/choice/Choice.tsx
517
+ var Choice = (props) => {
518
+ const { validation, title, id, note } = props;
519
+ const choiceItemProps = useChoiceItems(props);
520
+ const renderChoices = () => choiceItemProps.map((choiceItemProp) => /* @__PURE__ */ import_react19.default.createElement(ChoiceItem, { key: choiceItemProp.id, ...choiceItemProp }));
521
+ return /* @__PURE__ */ import_react19.default.createElement("div", { className: "grid w-full max-w-sm items-center gap-3" }, title && /* @__PURE__ */ import_react19.default.createElement(Label, { htmlFor: id }, /* @__PURE__ */ import_react19.default.createElement(import_react20.ReactAsset, { ...title })), /* @__PURE__ */ import_react19.default.createElement(
522
+ "div",
523
+ {
524
+ id: props.id,
525
+ className: "grid gap-2",
526
+ "aria-invalid": Boolean(validation),
527
+ "aria-describedby": validation ? `${id}-validation` : void 0
528
+ },
529
+ renderChoices()
530
+ ), validation && /* @__PURE__ */ import_react19.default.createElement(
531
+ Label,
532
+ {
533
+ id: `${id}-validation`,
534
+ className: "text-[0.8rem] font-medium text-destructive"
535
+ },
536
+ validation.message
537
+ ), note && /* @__PURE__ */ import_react19.default.createElement(Label, { className: "text-[0.8rem] text-muted-foreground" }, /* @__PURE__ */ import_react19.default.createElement(import_react20.ReactAsset, { ...note })));
538
+ };
539
+
540
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/plugins/reference-assets/react/src/plugin.tsx
541
+ var ReferenceAssetsPlugin = class {
542
+ constructor() {
543
+ this.name = "reference-assets-web-plugin";
544
+ }
545
+ applyReact(reactPlayer) {
546
+ reactPlayer.registerPlugin(
547
+ new import_asset_provider_plugin_react.AssetProviderPlugin([
548
+ ["input", Input2],
549
+ ["text", Text],
550
+ ["action", Action],
551
+ ["info", Info],
552
+ ["collection", Collection],
553
+ ["image", Image],
554
+ ["choice", Choice]
555
+ ])
556
+ );
557
+ }
558
+ apply(player) {
559
+ player.registerPlugin(new import_reference_assets_plugin2.ReferenceAssetsPlugin());
560
+ }
561
+ };
562
+ // Annotate the CommonJS export names for ESM import in node:
563
+ 0 && (module.exports = {
564
+ Action,
565
+ Choice,
566
+ Collection,
567
+ Image,
568
+ Info,
569
+ Input,
570
+ ReferenceAssetsPlugin,
571
+ Text,
572
+ TextModifierContext,
573
+ getConfig,
574
+ getLinkModifier,
575
+ useAction,
576
+ useChoiceItems,
577
+ useInputAsset,
578
+ useInputBeacon,
579
+ useText
580
+ });
581
+ //# sourceMappingURL=index.cjs.map