@veritone-ce/design-system 2.8.8 → 2.8.10

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 (26) hide show
  1. package/dist/cjs/Accordion/Accordion.js +120 -0
  2. package/dist/cjs/Accordion/AccordionGroup.js +61 -0
  3. package/dist/cjs/Accordion/Context.js +39 -0
  4. package/dist/cjs/Accordion/styles.module.scss.js +7 -0
  5. package/dist/cjs/bundled_modules/@react-spring/animated/dist/react-spring_animated.modern.js +338 -0
  6. package/dist/cjs/bundled_modules/@react-spring/core/dist/react-spring_core.modern.js +1799 -0
  7. package/dist/cjs/bundled_modules/@react-spring/rafz/dist/react-spring_rafz.modern.js +160 -0
  8. package/dist/cjs/bundled_modules/@react-spring/shared/dist/react-spring_shared.modern.js +775 -0
  9. package/dist/cjs/bundled_modules/@react-spring/web/dist/react-spring_web.modern.js +382 -0
  10. package/dist/cjs/index.js +9 -0
  11. package/dist/cjs/styles.css +1 -1
  12. package/dist/esm/Accordion/Accordion.js +116 -0
  13. package/dist/esm/Accordion/AccordionGroup.js +57 -0
  14. package/dist/esm/Accordion/Context.js +33 -0
  15. package/dist/esm/Accordion/styles.module.scss.js +3 -0
  16. package/dist/esm/bundled_modules/@react-spring/animated/dist/react-spring_animated.modern.js +308 -0
  17. package/dist/esm/bundled_modules/@react-spring/core/dist/react-spring_core.modern.js +1765 -0
  18. package/dist/esm/bundled_modules/@react-spring/rafz/dist/react-spring_rafz.modern.js +158 -0
  19. package/dist/esm/bundled_modules/@react-spring/shared/dist/react-spring_shared.modern.js +730 -0
  20. package/dist/esm/bundled_modules/@react-spring/web/dist/react-spring_web.modern.js +365 -0
  21. package/dist/esm/index.js +3 -0
  22. package/dist/esm/styles.css +1 -1
  23. package/dist/types/Accordion/Accordion.d.ts +20 -4
  24. package/dist/types/Accordion/index.d.ts +3 -0
  25. package/dist/types/index.d.ts +2 -0
  26. package/package.json +1 -1
@@ -0,0 +1,308 @@
1
+ import { defineHidden, is, isAnimatedString, createInterpolator, eachProp, each, useForceUpdate, useIsomorphicLayoutEffect, addFluidObserver, removeFluidObserver, useOnce, hasFluidValue, getFluidValue } from '../../shared/dist/react-spring_shared.modern.js';
2
+ import * as React from 'react';
3
+ import { forwardRef, useRef, useCallback, useEffect } from 'react';
4
+ import { raf } from '../../rafz/dist/react-spring_rafz.modern.js';
5
+
6
+ // src/Animated.ts
7
+ var $node = Symbol.for("Animated:node");
8
+ var isAnimated = (value) => !!value && value[$node] === value;
9
+ var getAnimated = (owner) => owner && owner[$node];
10
+ var setAnimated = (owner, node) => defineHidden(owner, $node, node);
11
+ var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload();
12
+ var Animated = class {
13
+ constructor() {
14
+ setAnimated(this, this);
15
+ }
16
+ /** Get every `AnimatedValue` used by this node. */
17
+ getPayload() {
18
+ return this.payload || [];
19
+ }
20
+ };
21
+ var AnimatedValue = class _AnimatedValue extends Animated {
22
+ constructor(_value) {
23
+ super();
24
+ this._value = _value;
25
+ this.done = true;
26
+ this.durationProgress = 0;
27
+ if (is.num(this._value)) {
28
+ this.lastPosition = this._value;
29
+ }
30
+ }
31
+ /** @internal */
32
+ static create(value) {
33
+ return new _AnimatedValue(value);
34
+ }
35
+ getPayload() {
36
+ return [this];
37
+ }
38
+ getValue() {
39
+ return this._value;
40
+ }
41
+ setValue(value, step) {
42
+ if (is.num(value)) {
43
+ this.lastPosition = value;
44
+ if (step) {
45
+ value = Math.round(value / step) * step;
46
+ if (this.done) {
47
+ this.lastPosition = value;
48
+ }
49
+ }
50
+ }
51
+ if (this._value === value) {
52
+ return false;
53
+ }
54
+ this._value = value;
55
+ return true;
56
+ }
57
+ reset() {
58
+ const { done } = this;
59
+ this.done = false;
60
+ if (is.num(this._value)) {
61
+ this.elapsedTime = 0;
62
+ this.durationProgress = 0;
63
+ this.lastPosition = this._value;
64
+ if (done) this.lastVelocity = null;
65
+ this.v0 = null;
66
+ }
67
+ }
68
+ };
69
+ var AnimatedString = class _AnimatedString extends AnimatedValue {
70
+ constructor(value) {
71
+ super(0);
72
+ this._string = null;
73
+ this._toString = createInterpolator({
74
+ output: [value, value]
75
+ });
76
+ }
77
+ /** @internal */
78
+ static create(value) {
79
+ return new _AnimatedString(value);
80
+ }
81
+ getValue() {
82
+ const value = this._string;
83
+ return value == null ? this._string = this._toString(this._value) : value;
84
+ }
85
+ setValue(value) {
86
+ if (is.str(value)) {
87
+ if (value == this._string) {
88
+ return false;
89
+ }
90
+ this._string = value;
91
+ this._value = 1;
92
+ } else if (super.setValue(value)) {
93
+ this._string = null;
94
+ } else {
95
+ return false;
96
+ }
97
+ return true;
98
+ }
99
+ reset(goal) {
100
+ if (goal) {
101
+ this._toString = createInterpolator({
102
+ output: [this.getValue(), goal]
103
+ });
104
+ }
105
+ this._value = 0;
106
+ super.reset();
107
+ }
108
+ };
109
+
110
+ // src/context.ts
111
+ var TreeContext = { dependencies: null };
112
+
113
+ // src/AnimatedObject.ts
114
+ var AnimatedObject = class extends Animated {
115
+ constructor(source) {
116
+ super();
117
+ this.source = source;
118
+ this.setValue(source);
119
+ }
120
+ getValue(animated) {
121
+ const values = {};
122
+ eachProp(this.source, (source, key) => {
123
+ if (isAnimated(source)) {
124
+ values[key] = source.getValue(animated);
125
+ } else if (hasFluidValue(source)) {
126
+ values[key] = getFluidValue(source);
127
+ } else if (!animated) {
128
+ values[key] = source;
129
+ }
130
+ });
131
+ return values;
132
+ }
133
+ /** Replace the raw object data */
134
+ setValue(source) {
135
+ this.source = source;
136
+ this.payload = this._makePayload(source);
137
+ }
138
+ reset() {
139
+ if (this.payload) {
140
+ each(this.payload, (node) => node.reset());
141
+ }
142
+ }
143
+ /** Create a payload set. */
144
+ _makePayload(source) {
145
+ if (source) {
146
+ const payload = /* @__PURE__ */ new Set();
147
+ eachProp(source, this._addToPayload, payload);
148
+ return Array.from(payload);
149
+ }
150
+ }
151
+ /** Add to a payload set. */
152
+ _addToPayload(source) {
153
+ if (TreeContext.dependencies && hasFluidValue(source)) {
154
+ TreeContext.dependencies.add(source);
155
+ }
156
+ const payload = getPayload(source);
157
+ if (payload) {
158
+ each(payload, (node) => this.add(node));
159
+ }
160
+ }
161
+ };
162
+
163
+ // src/AnimatedArray.ts
164
+ var AnimatedArray = class _AnimatedArray extends AnimatedObject {
165
+ constructor(source) {
166
+ super(source);
167
+ }
168
+ /** @internal */
169
+ static create(source) {
170
+ return new _AnimatedArray(source);
171
+ }
172
+ getValue() {
173
+ return this.source.map((node) => node.getValue());
174
+ }
175
+ setValue(source) {
176
+ const payload = this.getPayload();
177
+ if (source.length == payload.length) {
178
+ return payload.map((node, i) => node.setValue(source[i])).some(Boolean);
179
+ }
180
+ super.setValue(source.map(makeAnimated));
181
+ return true;
182
+ }
183
+ };
184
+ function makeAnimated(value) {
185
+ const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue;
186
+ return nodeType.create(value);
187
+ }
188
+ function getAnimatedType(value) {
189
+ const parentNode = getAnimated(value);
190
+ return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue;
191
+ }
192
+ var withAnimated = (Component, host) => {
193
+ const hasInstance = (
194
+ // Function components must use "forwardRef" to avoid being
195
+ // re-rendered on every animation frame.
196
+ !is.fun(Component) || Component.prototype && Component.prototype.isReactComponent
197
+ );
198
+ return forwardRef((givenProps, givenRef) => {
199
+ const instanceRef = useRef(null);
200
+ const ref = hasInstance && // eslint-disable-next-line react-hooks/rules-of-hooks
201
+ useCallback(
202
+ (value) => {
203
+ instanceRef.current = updateRef(givenRef, value);
204
+ },
205
+ [givenRef]
206
+ );
207
+ const [props, deps] = getAnimatedState(givenProps, host);
208
+ const forceUpdate = useForceUpdate();
209
+ const callback = () => {
210
+ const instance = instanceRef.current;
211
+ if (hasInstance && !instance) {
212
+ return;
213
+ }
214
+ const didUpdate = instance ? host.applyAnimatedValues(instance, props.getValue(true)) : false;
215
+ if (didUpdate === false) {
216
+ forceUpdate();
217
+ }
218
+ };
219
+ const observer = new PropsObserver(callback, deps);
220
+ const observerRef = useRef(void 0);
221
+ useIsomorphicLayoutEffect(() => {
222
+ observerRef.current = observer;
223
+ each(deps, (dep) => addFluidObserver(dep, observer));
224
+ return () => {
225
+ if (observerRef.current) {
226
+ each(
227
+ observerRef.current.deps,
228
+ (dep) => removeFluidObserver(dep, observerRef.current)
229
+ );
230
+ raf.cancel(observerRef.current.update);
231
+ }
232
+ };
233
+ });
234
+ useEffect(callback, []);
235
+ useOnce(() => () => {
236
+ const observer2 = observerRef.current;
237
+ each(observer2.deps, (dep) => removeFluidObserver(dep, observer2));
238
+ });
239
+ const usedProps = host.getComponentProps(props.getValue());
240
+ return /* @__PURE__ */ React.createElement(Component, { ...usedProps, ref });
241
+ });
242
+ };
243
+ var PropsObserver = class {
244
+ constructor(update, deps) {
245
+ this.update = update;
246
+ this.deps = deps;
247
+ }
248
+ eventObserved(event) {
249
+ if (event.type == "change") {
250
+ raf.write(this.update);
251
+ }
252
+ }
253
+ };
254
+ function getAnimatedState(props, host) {
255
+ const dependencies = /* @__PURE__ */ new Set();
256
+ TreeContext.dependencies = dependencies;
257
+ if (props.style)
258
+ props = {
259
+ ...props,
260
+ style: host.createAnimatedStyle(props.style)
261
+ };
262
+ props = new AnimatedObject(props);
263
+ TreeContext.dependencies = null;
264
+ return [props, dependencies];
265
+ }
266
+ function updateRef(ref, value) {
267
+ if (ref) {
268
+ if (is.fun(ref)) ref(value);
269
+ else ref.current = value;
270
+ }
271
+ return value;
272
+ }
273
+
274
+ // src/createHost.ts
275
+ var cacheKey = Symbol.for("AnimatedComponent");
276
+ var createHost = (components, {
277
+ applyAnimatedValues = () => false,
278
+ createAnimatedStyle = (style) => new AnimatedObject(style),
279
+ getComponentProps = (props) => props
280
+ } = {}) => {
281
+ const hostConfig = {
282
+ applyAnimatedValues,
283
+ createAnimatedStyle,
284
+ getComponentProps
285
+ };
286
+ const animated = (Component) => {
287
+ const displayName = getDisplayName(Component) || "Anonymous";
288
+ if (is.str(Component)) {
289
+ Component = animated[Component] || (animated[Component] = withAnimated(Component, hostConfig));
290
+ } else {
291
+ Component = Component[cacheKey] || (Component[cacheKey] = withAnimated(Component, hostConfig));
292
+ }
293
+ Component.displayName = `Animated(${displayName})`;
294
+ return Component;
295
+ };
296
+ eachProp(components, (Component, key) => {
297
+ if (is.arr(components)) {
298
+ key = getDisplayName(Component);
299
+ }
300
+ animated[key] = animated(Component);
301
+ });
302
+ return {
303
+ animated
304
+ };
305
+ };
306
+ var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null;
307
+
308
+ export { Animated, AnimatedArray, AnimatedObject, AnimatedString, AnimatedValue, createHost, getAnimated, getAnimatedType, getPayload, isAnimated, setAnimated };