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