@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
package/dist/index.cjs.js
DELETED
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var assetProviderPluginReact = require('@player-ui/asset-provider-plugin-react');
|
|
7
|
-
var react = require('@chakra-ui/react');
|
|
8
|
-
var referenceAssetsPlugin = require('@player-ui/reference-assets-plugin');
|
|
9
|
-
var react$1 = require('@player-ui/react');
|
|
10
|
-
var beaconPluginReact = require('@player-ui/beacon-plugin-react');
|
|
11
|
-
var makeClass = require('clsx');
|
|
12
|
-
var icons = require('@chakra-ui/icons');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
-
var makeClass__default = /*#__PURE__*/_interopDefaultLegacy(makeClass);
|
|
18
|
-
|
|
19
|
-
var __defProp$8 = Object.defineProperty;
|
|
20
|
-
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
21
|
-
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
22
|
-
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
23
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
24
|
-
var __spreadValues$8 = (a, b) => {
|
|
25
|
-
for (var prop in b || (b = {}))
|
|
26
|
-
if (__hasOwnProp$8.call(b, prop))
|
|
27
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
28
|
-
if (__getOwnPropSymbols$8)
|
|
29
|
-
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
30
|
-
if (__propIsEnum$8.call(b, prop))
|
|
31
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
32
|
-
}
|
|
33
|
-
return a;
|
|
34
|
-
};
|
|
35
|
-
const defaultKeyStrings = [
|
|
36
|
-
"Delete",
|
|
37
|
-
"Backspace",
|
|
38
|
-
"Tab",
|
|
39
|
-
"Home",
|
|
40
|
-
"End",
|
|
41
|
-
"ArrowLeft",
|
|
42
|
-
"ArrowRight",
|
|
43
|
-
"ArrowUp",
|
|
44
|
-
"ArrowDown",
|
|
45
|
-
"Escape"
|
|
46
|
-
];
|
|
47
|
-
const getConfig = (userConfig = {}) => {
|
|
48
|
-
return __spreadValues$8({
|
|
49
|
-
liveFormat: true,
|
|
50
|
-
suppressBeacons: false,
|
|
51
|
-
quickFormatDelay: 200,
|
|
52
|
-
slowFormatDelay: 1e3,
|
|
53
|
-
slowFormatKeys: defaultKeyStrings,
|
|
54
|
-
decimalSymbol: ".",
|
|
55
|
-
prefix: "",
|
|
56
|
-
suffix: ""
|
|
57
|
-
}, userConfig);
|
|
58
|
-
};
|
|
59
|
-
const useInputBeacon = (props) => {
|
|
60
|
-
const beaconHandler = beaconPluginReact.useBeacon({ element: "text_input", asset: props });
|
|
61
|
-
return (newValue) => {
|
|
62
|
-
let action = "modified";
|
|
63
|
-
if (newValue === props.value) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (newValue && !props.value) {
|
|
67
|
-
action = "added";
|
|
68
|
-
} else if (!newValue && props.value) {
|
|
69
|
-
action = "deleted";
|
|
70
|
-
}
|
|
71
|
-
beaconHandler({ action });
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
const useInputAsset = (props, config) => {
|
|
75
|
-
var _a;
|
|
76
|
-
const [localValue, setLocalValue] = React__default["default"].useState((_a = props.value) != null ? _a : "");
|
|
77
|
-
const formatTimerRef = React__default["default"].useRef(void 0);
|
|
78
|
-
const inputBeacon = useInputBeacon(props);
|
|
79
|
-
const {
|
|
80
|
-
liveFormat,
|
|
81
|
-
suppressBeacons,
|
|
82
|
-
quickFormatDelay,
|
|
83
|
-
slowFormatDelay,
|
|
84
|
-
slowFormatKeys,
|
|
85
|
-
decimalSymbol,
|
|
86
|
-
prefix,
|
|
87
|
-
suffix
|
|
88
|
-
} = getConfig(config);
|
|
89
|
-
function clearPending() {
|
|
90
|
-
if (formatTimerRef.current) {
|
|
91
|
-
clearTimeout(formatTimerRef.current);
|
|
92
|
-
formatTimerRef.current = void 0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function getFormatDelaySpeed(e) {
|
|
96
|
-
const key = slowFormatKeys.every((k) => typeof k === "number") ? e.which : e.key;
|
|
97
|
-
return slowFormatKeys.includes(key) ? slowFormatDelay : quickFormatDelay;
|
|
98
|
-
}
|
|
99
|
-
function handleAffixOnFocus(target) {
|
|
100
|
-
let val = target.value;
|
|
101
|
-
if (suffix)
|
|
102
|
-
val = val.substring(0, val.indexOf(suffix));
|
|
103
|
-
if (prefix && !val.includes(prefix)) {
|
|
104
|
-
val = `${prefix}${val}`;
|
|
105
|
-
}
|
|
106
|
-
return val;
|
|
107
|
-
}
|
|
108
|
-
function handlePrefixEdgeCases(e) {
|
|
109
|
-
const target = e.target;
|
|
110
|
-
const start = target.selectionStart;
|
|
111
|
-
const end = target.selectionEnd;
|
|
112
|
-
const pl = prefix.length;
|
|
113
|
-
const atStart = start === pl;
|
|
114
|
-
const atEnd = end === pl;
|
|
115
|
-
if (start && end && start < pl) {
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
target.setSelectionRange(pl, end - start + pl);
|
|
118
|
-
} else if (e.key === "ArrowLeft" && atStart || e.key === "Backspace" && atStart && atEnd || e.key === "Home") {
|
|
119
|
-
e.preventDefault();
|
|
120
|
-
target.setSelectionRange(prefix.length, prefix.length);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function formatValueWithAffix(value) {
|
|
124
|
-
if (!value)
|
|
125
|
-
return "";
|
|
126
|
-
return `${prefix}${value}${suffix}`;
|
|
127
|
-
}
|
|
128
|
-
const onKeyDownHandler = (currentValue) => {
|
|
129
|
-
var _a2;
|
|
130
|
-
const symbolPosition = currentValue.indexOf(decimalSymbol);
|
|
131
|
-
const newValue = (_a2 = props.format(currentValue)) != null ? _a2 : "";
|
|
132
|
-
const newSymbolPosition = newValue.indexOf(decimalSymbol);
|
|
133
|
-
if ((symbolPosition === -1 || symbolPosition === 0) && newSymbolPosition > 0) {
|
|
134
|
-
return {
|
|
135
|
-
newValue: newValue.includes(prefix) ? `${newValue}` : `${prefix}${newValue}`,
|
|
136
|
-
newCursorPosition: newValue.includes(prefix) ? newSymbolPosition : newSymbolPosition + prefix.length
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
newValue: newValue.includes(prefix) ? `${newValue}` : `${prefix}${newValue}`
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
const onBlur = (e) => {
|
|
144
|
-
var _a2;
|
|
145
|
-
clearPending();
|
|
146
|
-
const formatted = (_a2 = prefix ? e.target.value.replace(prefix, "") : props.format(e.target.value)) != null ? _a2 : "";
|
|
147
|
-
if (formatted) {
|
|
148
|
-
props.set(formatted);
|
|
149
|
-
setLocalValue(formatValueWithAffix(formatted));
|
|
150
|
-
} else {
|
|
151
|
-
props.set("");
|
|
152
|
-
setLocalValue("");
|
|
153
|
-
}
|
|
154
|
-
if (!suppressBeacons) {
|
|
155
|
-
inputBeacon(formatted);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const onChange = (e) => {
|
|
159
|
-
setLocalValue(e.target.value);
|
|
160
|
-
};
|
|
161
|
-
const onKeyDown = (e) => {
|
|
162
|
-
clearPending();
|
|
163
|
-
if (prefix)
|
|
164
|
-
handlePrefixEdgeCases(e);
|
|
165
|
-
const target = e.target;
|
|
166
|
-
if (liveFormat) {
|
|
167
|
-
formatTimerRef.current = setTimeout(() => {
|
|
168
|
-
var _a2, _b;
|
|
169
|
-
const cursorPosition = target.selectionStart;
|
|
170
|
-
const currentValue = target.value;
|
|
171
|
-
if (cursorPosition !== currentValue.length) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const obj = onKeyDownHandler(currentValue);
|
|
175
|
-
setLocalValue(obj.newValue);
|
|
176
|
-
target.selectionStart = (_a2 = obj.newCursorPosition) != null ? _a2 : target.selectionStart;
|
|
177
|
-
target.selectionEnd = (_b = obj.newCursorPosition) != null ? _b : target.selectionEnd;
|
|
178
|
-
}, getFormatDelaySpeed(e));
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const onFocus = (e) => {
|
|
182
|
-
const target = e.target;
|
|
183
|
-
const inputEmpty = target.value === "";
|
|
184
|
-
if (!inputEmpty && suffix || inputEmpty && prefix) {
|
|
185
|
-
setLocalValue(handleAffixOnFocus(target));
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
const propsValue = props.value;
|
|
189
|
-
React__default["default"].useEffect(() => {
|
|
190
|
-
setLocalValue(formatValueWithAffix(propsValue));
|
|
191
|
-
}, [propsValue]);
|
|
192
|
-
React__default["default"].useEffect(() => clearPending, []);
|
|
193
|
-
return {
|
|
194
|
-
onBlur,
|
|
195
|
-
onChange,
|
|
196
|
-
onKeyDown,
|
|
197
|
-
onFocus,
|
|
198
|
-
value: localValue
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
var __defProp$7 = Object.defineProperty;
|
|
203
|
-
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
204
|
-
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
205
|
-
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
206
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
207
|
-
var __spreadValues$7 = (a, b) => {
|
|
208
|
-
for (var prop in b || (b = {}))
|
|
209
|
-
if (__hasOwnProp$7.call(b, prop))
|
|
210
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
211
|
-
if (__getOwnPropSymbols$7)
|
|
212
|
-
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
213
|
-
if (__propIsEnum$7.call(b, prop))
|
|
214
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
215
|
-
}
|
|
216
|
-
return a;
|
|
217
|
-
};
|
|
218
|
-
const Input = (props) => {
|
|
219
|
-
const { validation, label, id, note } = props;
|
|
220
|
-
const inputProps = useInputAsset(props);
|
|
221
|
-
return /* @__PURE__ */ React__default["default"].createElement(react.FormControl, {
|
|
222
|
-
isInvalid: Boolean(validation)
|
|
223
|
-
}, label && /* @__PURE__ */ React__default["default"].createElement(react.FormLabel, {
|
|
224
|
-
htmlFor: id
|
|
225
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$7({}, label))), /* @__PURE__ */ React__default["default"].createElement(react.Input, __spreadValues$7({
|
|
226
|
-
id,
|
|
227
|
-
size: "md"
|
|
228
|
-
}, inputProps)), validation && /* @__PURE__ */ React__default["default"].createElement(react.FormErrorMessage, null, validation.message), note && /* @__PURE__ */ React__default["default"].createElement(react.FormHelperText, null, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$7({}, note))));
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
var __defProp$6 = Object.defineProperty;
|
|
232
|
-
var __defProps = Object.defineProperties;
|
|
233
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
234
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
235
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
236
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
237
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
238
|
-
var __spreadValues$6 = (a, b) => {
|
|
239
|
-
for (var prop in b || (b = {}))
|
|
240
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
241
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
242
|
-
if (__getOwnPropSymbols$6)
|
|
243
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
244
|
-
if (__propIsEnum$6.call(b, prop))
|
|
245
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
246
|
-
}
|
|
247
|
-
return a;
|
|
248
|
-
};
|
|
249
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
250
|
-
const TextModifierContext = React__default["default"].createContext(void 0);
|
|
251
|
-
const useText = (props) => {
|
|
252
|
-
let className;
|
|
253
|
-
const modifierContext = React.useContext(TextModifierContext);
|
|
254
|
-
if (props.modifiers && (modifierContext == null ? void 0 : modifierContext.getClassForModifier)) {
|
|
255
|
-
className = makeClass__default["default"](...props.modifiers.map(modifierContext.getClassForModifier));
|
|
256
|
-
}
|
|
257
|
-
return __spreadProps(__spreadValues$6({}, react$1.useAssetProps(props)), {
|
|
258
|
-
className,
|
|
259
|
-
children: props.value
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
var __defProp$5 = Object.defineProperty;
|
|
264
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
265
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
266
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
267
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
268
|
-
var __spreadValues$5 = (a, b) => {
|
|
269
|
-
for (var prop in b || (b = {}))
|
|
270
|
-
if (__hasOwnProp$5.call(b, prop))
|
|
271
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
272
|
-
if (__getOwnPropSymbols$5)
|
|
273
|
-
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
274
|
-
if (__propIsEnum$5.call(b, prop))
|
|
275
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
276
|
-
}
|
|
277
|
-
return a;
|
|
278
|
-
};
|
|
279
|
-
const getLinkModifier = (asset) => {
|
|
280
|
-
var _a;
|
|
281
|
-
return (_a = asset.modifiers) == null ? void 0 : _a.find((mod) => {
|
|
282
|
-
var _a2;
|
|
283
|
-
return mod.type === "link" && ((_a2 = mod.metaData) == null ? void 0 : _a2.ref) !== void 0;
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
const Text = (props) => {
|
|
287
|
-
const spanProps = useText(props);
|
|
288
|
-
const linkModifier = getLinkModifier(props);
|
|
289
|
-
const { value } = props;
|
|
290
|
-
if (linkModifier) {
|
|
291
|
-
return /* @__PURE__ */ React__default["default"].createElement(react.Link, {
|
|
292
|
-
href: linkModifier.metaData.ref
|
|
293
|
-
}, value);
|
|
294
|
-
}
|
|
295
|
-
return /* @__PURE__ */ React__default["default"].createElement("span", __spreadValues$5({}, spanProps), value);
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
var __defProp$4 = Object.defineProperty;
|
|
299
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
300
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
301
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
302
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
303
|
-
var __spreadValues$4 = (a, b) => {
|
|
304
|
-
for (var prop in b || (b = {}))
|
|
305
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
306
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
307
|
-
if (__getOwnPropSymbols$4)
|
|
308
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
309
|
-
if (__propIsEnum$4.call(b, prop))
|
|
310
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
311
|
-
}
|
|
312
|
-
return a;
|
|
313
|
-
};
|
|
314
|
-
const Collection = (props) => {
|
|
315
|
-
var _a;
|
|
316
|
-
return /* @__PURE__ */ React__default["default"].createElement(react.Flex, {
|
|
317
|
-
direction: "column",
|
|
318
|
-
gap: "5"
|
|
319
|
-
}, props.label && /* @__PURE__ */ React__default["default"].createElement("h3", null, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$4({}, props.label))), (_a = props.values) == null ? void 0 : _a.map((a) => /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$4({
|
|
320
|
-
key: a.asset.id
|
|
321
|
-
}, a))));
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
var __defProp$3 = Object.defineProperty;
|
|
325
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
326
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
327
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
328
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
329
|
-
var __spreadValues$3 = (a, b) => {
|
|
330
|
-
for (var prop in b || (b = {}))
|
|
331
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
332
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
333
|
-
if (__getOwnPropSymbols$3)
|
|
334
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
335
|
-
if (__propIsEnum$3.call(b, prop))
|
|
336
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
337
|
-
}
|
|
338
|
-
return a;
|
|
339
|
-
};
|
|
340
|
-
const useAction = (props) => {
|
|
341
|
-
const { label } = props;
|
|
342
|
-
const beacon = beaconPluginReact.useBeacon({
|
|
343
|
-
asset: props,
|
|
344
|
-
action: "clicked",
|
|
345
|
-
element: "button"
|
|
346
|
-
});
|
|
347
|
-
return {
|
|
348
|
-
id: props.id,
|
|
349
|
-
onClick: () => {
|
|
350
|
-
beacon();
|
|
351
|
-
props.run();
|
|
352
|
-
},
|
|
353
|
-
children: (label == null ? void 0 : label.asset) ? /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$3({}, label == null ? void 0 : label.asset)) : null
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
var __defProp$2 = Object.defineProperty;
|
|
358
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
359
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
360
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
361
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
362
|
-
var __spreadValues$2 = (a, b) => {
|
|
363
|
-
for (var prop in b || (b = {}))
|
|
364
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
365
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
366
|
-
if (__getOwnPropSymbols$2)
|
|
367
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
368
|
-
if (__propIsEnum$2.call(b, prop))
|
|
369
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
370
|
-
}
|
|
371
|
-
return a;
|
|
372
|
-
};
|
|
373
|
-
const Action = (props) => {
|
|
374
|
-
var _a;
|
|
375
|
-
const { label } = props;
|
|
376
|
-
const buttonProps = useAction(props);
|
|
377
|
-
return /* @__PURE__ */ React__default["default"].createElement("div", null, /* @__PURE__ */ React__default["default"].createElement(react.Button, __spreadValues$2({
|
|
378
|
-
variant: referenceAssetsPlugin.isBackAction(props) ? "ghost" : "solid"
|
|
379
|
-
}, buttonProps), ((_a = props == null ? void 0 : props.metaData) == null ? void 0 : _a.role) === "back" && /* @__PURE__ */ React__default["default"].createElement(icons.ChevronLeftIcon, null), label && /* @__PURE__ */ React__default["default"].createElement(react.Text, null, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$2({}, label)))));
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var __defProp$1 = Object.defineProperty;
|
|
383
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
384
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
385
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
386
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
387
|
-
var __spreadValues$1 = (a, b) => {
|
|
388
|
-
for (var prop in b || (b = {}))
|
|
389
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
390
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
391
|
-
if (__getOwnPropSymbols$1)
|
|
392
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
393
|
-
if (__propIsEnum$1.call(b, prop))
|
|
394
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
395
|
-
}
|
|
396
|
-
return a;
|
|
397
|
-
};
|
|
398
|
-
const Info = (props) => {
|
|
399
|
-
var _a, _b, _c, _d;
|
|
400
|
-
return /* @__PURE__ */ React__default["default"].createElement(react.Box, {
|
|
401
|
-
minW: { base: void 0, md: "md" }
|
|
402
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react.Stack, {
|
|
403
|
-
gap: "10"
|
|
404
|
-
}, props.title && /* @__PURE__ */ React__default["default"].createElement(react.Heading, {
|
|
405
|
-
size: "lg",
|
|
406
|
-
as: "h1"
|
|
407
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$1({}, props.title))), props.subTitle && /* @__PURE__ */ React__default["default"].createElement(react.Heading, {
|
|
408
|
-
size: "md",
|
|
409
|
-
as: "h3"
|
|
410
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$1({}, props.subTitle))), /* @__PURE__ */ React__default["default"].createElement(react.Box, null, props.primaryInfo && /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$1({}, props.primaryInfo))), /* @__PURE__ */ React__default["default"].createElement(react.Stack, {
|
|
411
|
-
gap: "4"
|
|
412
|
-
}, (props == null ? void 0 : props.segmentedActions) && /* @__PURE__ */ React__default["default"].createElement(react.Divider, null), /* @__PURE__ */ React__default["default"].createElement(react.HStack, {
|
|
413
|
-
justifyContent: "space-between"
|
|
414
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react.ButtonGroup, {
|
|
415
|
-
spacing: "6"
|
|
416
|
-
}, (_b = (_a = props == null ? void 0 : props.segmentedActions) == null ? void 0 : _a.prev) == null ? void 0 : _b.map((a) => /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$1({
|
|
417
|
-
key: a.asset.id
|
|
418
|
-
}, a)))), /* @__PURE__ */ React__default["default"].createElement(react.ButtonGroup, {
|
|
419
|
-
spacing: "6"
|
|
420
|
-
}, (_d = (_c = props == null ? void 0 : props.segmentedActions) == null ? void 0 : _c.next) == null ? void 0 : _d.map((a) => /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues$1({
|
|
421
|
-
key: a.asset.id
|
|
422
|
-
}, a))))))));
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
var __defProp = Object.defineProperty;
|
|
426
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
427
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
428
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
429
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
430
|
-
var __spreadValues = (a, b) => {
|
|
431
|
-
for (var prop in b || (b = {}))
|
|
432
|
-
if (__hasOwnProp.call(b, prop))
|
|
433
|
-
__defNormalProp(a, prop, b[prop]);
|
|
434
|
-
if (__getOwnPropSymbols)
|
|
435
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
436
|
-
if (__propIsEnum.call(b, prop))
|
|
437
|
-
__defNormalProp(a, prop, b[prop]);
|
|
438
|
-
}
|
|
439
|
-
return a;
|
|
440
|
-
};
|
|
441
|
-
const Image = (props) => {
|
|
442
|
-
const { metaData, caption, altText } = props;
|
|
443
|
-
console.log(props);
|
|
444
|
-
return /* @__PURE__ */ React__default["default"].createElement("figure", {
|
|
445
|
-
className: "figure"
|
|
446
|
-
}, /* @__PURE__ */ React__default["default"].createElement("img", {
|
|
447
|
-
className: "figure-img img-fluid",
|
|
448
|
-
src: metaData.ref,
|
|
449
|
-
alt: altText
|
|
450
|
-
}), caption && /* @__PURE__ */ React__default["default"].createElement("figcaption", {
|
|
451
|
-
className: "figure-caption",
|
|
452
|
-
style: { marginTop: 15 }
|
|
453
|
-
}, /* @__PURE__ */ React__default["default"].createElement(react$1.ReactAsset, __spreadValues({}, caption))));
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
const OptionalChakraThemeProvider = (props) => {
|
|
457
|
-
const theme = react.useTheme();
|
|
458
|
-
if (theme) {
|
|
459
|
-
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, props.children);
|
|
460
|
-
}
|
|
461
|
-
return /* @__PURE__ */ React__default["default"].createElement(react.ChakraProvider, null, props.children);
|
|
462
|
-
};
|
|
463
|
-
class ReferenceAssetsPlugin {
|
|
464
|
-
constructor() {
|
|
465
|
-
this.name = "reference-assets-web-plugin";
|
|
466
|
-
}
|
|
467
|
-
applyReact(reactPlayer) {
|
|
468
|
-
reactPlayer.registerPlugin(new assetProviderPluginReact.AssetProviderPlugin([
|
|
469
|
-
["input", Input],
|
|
470
|
-
["text", Text],
|
|
471
|
-
["action", Action],
|
|
472
|
-
["info", Info],
|
|
473
|
-
["collection", Collection],
|
|
474
|
-
["image", Image]
|
|
475
|
-
]));
|
|
476
|
-
reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
|
|
477
|
-
return () => {
|
|
478
|
-
return /* @__PURE__ */ React__default["default"].createElement(OptionalChakraThemeProvider, null, /* @__PURE__ */ React__default["default"].createElement(Comp, null));
|
|
479
|
-
};
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
apply(player) {
|
|
483
|
-
player.registerPlugin(new referenceAssetsPlugin.ReferenceAssetsPlugin());
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
exports.Action = Action;
|
|
488
|
-
exports.Collection = Collection;
|
|
489
|
-
exports.Image = Image;
|
|
490
|
-
exports.Info = Info;
|
|
491
|
-
exports.Input = Input;
|
|
492
|
-
exports.ReferenceAssetsPlugin = ReferenceAssetsPlugin;
|
|
493
|
-
exports.Text = Text;
|
|
494
|
-
exports.TextModifierContext = TextModifierContext;
|
|
495
|
-
exports.getConfig = getConfig;
|
|
496
|
-
exports.getLinkModifier = getLinkModifier;
|
|
497
|
-
exports.useAction = useAction;
|
|
498
|
-
exports.useInputAsset = useInputAsset;
|
|
499
|
-
exports.useInputBeacon = useInputBeacon;
|
|
500
|
-
exports.useText = useText;
|
|
501
|
-
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ReactPlayerPlugin, ReactPlayer } from '@player-ui/react';
|
|
2
|
-
import { ExtendedPlayerPlugin, Player } from '@player-ui/player';
|
|
3
|
-
import { InputAsset, TextAsset, ActionAsset, CollectionAsset, InfoAsset, TransformedInput, LinkModifier, TransformedAction, InfoAssetTransform, TransformedImage } from '@player-ui/reference-assets-plugin';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A plugin to register the base reference assets
|
|
8
|
-
*/
|
|
9
|
-
declare class ReferenceAssetsPlugin implements ReactPlayerPlugin, ExtendedPlayerPlugin<[
|
|
10
|
-
InputAsset,
|
|
11
|
-
TextAsset,
|
|
12
|
-
ActionAsset,
|
|
13
|
-
CollectionAsset
|
|
14
|
-
], [
|
|
15
|
-
InfoAsset
|
|
16
|
-
]> {
|
|
17
|
-
name: string;
|
|
18
|
-
applyReact(reactPlayer: ReactPlayer): void;
|
|
19
|
-
apply(player: Player): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** An Input */
|
|
23
|
-
declare const Input: (props: TransformedInput) => JSX.Element;
|
|
24
|
-
|
|
25
|
-
interface InputHookConfig {
|
|
26
|
-
/** Format the input as the user keys down */
|
|
27
|
-
liveFormat?: boolean;
|
|
28
|
-
/** Skip sending beacon events for this input */
|
|
29
|
-
suppressBeacons?: boolean;
|
|
30
|
-
/** Time (ms) to wait before formatting the user input for normal keys */
|
|
31
|
-
quickFormatDelay?: number;
|
|
32
|
-
/** Time (ms) to wait before formatting the input after the user types a special _slow_ format key */
|
|
33
|
-
slowFormatDelay?: number;
|
|
34
|
-
/** Keys to use a slower formatter for. Usually reserved for backspace, arrows, tabs, etc */
|
|
35
|
-
slowFormatKeys?: Array<number | string>;
|
|
36
|
-
/** Symbol to be used for decimal point */
|
|
37
|
-
decimalSymbol?: string;
|
|
38
|
-
/** Affix to append to value - does not save to model and is only for display on input */
|
|
39
|
-
prefix?: string;
|
|
40
|
-
/** Affix to prepend to value - does not save to model and is only for display on input */
|
|
41
|
-
suffix?: string;
|
|
42
|
-
}
|
|
43
|
-
/** Create a valid config mixing in defaults and user overrides */
|
|
44
|
-
declare const getConfig: (userConfig?: InputHookConfig) => Required<InputHookConfig>;
|
|
45
|
-
/** A hook to manage beacon changes for input assets */
|
|
46
|
-
declare const useInputBeacon: (props: TransformedInput) => (newValue: string) => void;
|
|
47
|
-
/**
|
|
48
|
-
* A hook to manage an input html element as an asset.
|
|
49
|
-
* The hook returns an object containing props that are expected to reside on any html input.
|
|
50
|
-
* It will handle formatting, setting values, beaconing, aria-labels, etc.
|
|
51
|
-
*
|
|
52
|
-
* @param props - The output of the input transform
|
|
53
|
-
* @param config - Local config to manage user interaction overrides
|
|
54
|
-
*/
|
|
55
|
-
declare const useInputAsset: (props: TransformedInput, config?: InputHookConfig | undefined) => {
|
|
56
|
-
onBlur: React.FocusEventHandler<HTMLInputElement>;
|
|
57
|
-
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
58
|
-
onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
59
|
-
onFocus: React.FocusEventHandler<HTMLInputElement>;
|
|
60
|
-
value: string;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/** Find any link modifiers on the text */
|
|
64
|
-
declare const getLinkModifier: (asset: TextAsset) => LinkModifier | undefined;
|
|
65
|
-
/** A text asset */
|
|
66
|
-
declare const Text: (props: TextAsset) => JSX.Element;
|
|
67
|
-
|
|
68
|
-
interface TextModifierContextType {
|
|
69
|
-
getClassForModifier?<T>(modifier: T): string | undefined;
|
|
70
|
-
}
|
|
71
|
-
declare const TextModifierContext: React.Context<TextModifierContextType | undefined>;
|
|
72
|
-
/** Get the props for a basic text element */
|
|
73
|
-
declare const useText: (props: TextAsset) => JSX.IntrinsicElements['span'];
|
|
74
|
-
|
|
75
|
-
declare const Collection: (props: CollectionAsset) => JSX.Element;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* An action that a user can take
|
|
79
|
-
*/
|
|
80
|
-
declare const Action: (props: TransformedAction) => JSX.Element;
|
|
81
|
-
|
|
82
|
-
/** Hook to get all the props for a button */
|
|
83
|
-
declare const useAction: (props: TransformedAction) => {
|
|
84
|
-
readonly id: string;
|
|
85
|
-
readonly onClick: () => void;
|
|
86
|
-
readonly children: JSX.Element | null;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/** The info view type is used to show information to the user */
|
|
90
|
-
declare const Info: (props: InfoAssetTransform) => JSX.Element;
|
|
91
|
-
|
|
92
|
-
declare const Image: (props: TransformedImage) => JSX.Element;
|
|
93
|
-
|
|
94
|
-
export { Action, Collection, Image, Info, Input, InputHookConfig, ReferenceAssetsPlugin, Text, TextModifierContext, TextModifierContextType, getConfig, getLinkModifier, useAction, useInputAsset, useInputBeacon, useText };
|