@furystack/shades-common-components 13.3.0 → 13.4.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/CHANGELOG.md +28 -0
- package/esm/components/cache-view.d.ts +2 -1
- package/esm/components/cache-view.d.ts.map +1 -1
- package/esm/components/cache-view.js +9 -7
- package/esm/components/cache-view.js.map +1 -1
- package/esm/components/cache-view.spec.js +49 -0
- package/esm/components/cache-view.spec.js.map +1 -1
- package/esm/components/drawer/index.spec.js +22 -0
- package/esm/components/drawer/index.spec.js.map +1 -1
- package/esm/components/tabs.d.ts +2 -0
- package/esm/components/tabs.d.ts.map +1 -1
- package/esm/components/tabs.js +5 -4
- package/esm/components/tabs.js.map +1 -1
- package/esm/components/tabs.spec.js +57 -0
- package/esm/components/tabs.spec.js.map +1 -1
- package/esm/components/wizard/index.d.ts +2 -1
- package/esm/components/wizard/index.d.ts.map +1 -1
- package/esm/components/wizard/index.js +3 -3
- package/esm/components/wizard/index.js.map +1 -1
- package/esm/components/wizard/index.spec.js +46 -1
- package/esm/components/wizard/index.spec.js.map +1 -1
- package/package.json +2 -2
- package/src/components/cache-view.spec.tsx +77 -0
- package/src/components/cache-view.tsx +21 -8
- package/src/components/drawer/index.spec.tsx +30 -0
- package/src/components/tabs.spec.tsx +72 -0
- package/src/components/tabs.tsx +9 -4
- package/src/components/wizard/index.spec.tsx +57 -1
- package/src/components/wizard/index.tsx +5 -4
|
@@ -67,12 +67,13 @@ describe('Wizard', () => {
|
|
|
67
67
|
|
|
68
68
|
afterEach(() => {
|
|
69
69
|
document.body.innerHTML = ''
|
|
70
|
+
delete (document as unknown as Record<string, unknown>).startViewTransition
|
|
70
71
|
})
|
|
71
72
|
|
|
72
73
|
const renderWizard = async (
|
|
73
74
|
steps: Array<(props: WizardStepProps, children: ChildrenList) => JSX.Element>,
|
|
74
75
|
onFinish?: () => void,
|
|
75
|
-
options?: { stepLabels?: string[]; showProgress?: boolean },
|
|
76
|
+
options?: { stepLabels?: string[]; showProgress?: boolean; viewTransition?: boolean },
|
|
76
77
|
) => {
|
|
77
78
|
const injector = new Injector()
|
|
78
79
|
const root = document.getElementById('root')!
|
|
@@ -85,6 +86,7 @@ describe('Wizard', () => {
|
|
|
85
86
|
onFinish={onFinish}
|
|
86
87
|
stepLabels={options?.stepLabels}
|
|
87
88
|
showProgress={options?.showProgress}
|
|
89
|
+
viewTransition={options?.viewTransition}
|
|
88
90
|
/>
|
|
89
91
|
),
|
|
90
92
|
})
|
|
@@ -347,4 +349,58 @@ describe('Wizard', () => {
|
|
|
347
349
|
})
|
|
348
350
|
})
|
|
349
351
|
})
|
|
352
|
+
|
|
353
|
+
describe('view transitions', () => {
|
|
354
|
+
const mockStartViewTransition = () => {
|
|
355
|
+
const spy = vi.fn((optionsOrCallback: StartViewTransitionOptions | (() => void)) => {
|
|
356
|
+
const update = typeof optionsOrCallback === 'function' ? optionsOrCallback : optionsOrCallback.update
|
|
357
|
+
update?.()
|
|
358
|
+
return {
|
|
359
|
+
finished: Promise.resolve(),
|
|
360
|
+
ready: Promise.resolve(),
|
|
361
|
+
updateCallbackDone: Promise.resolve(),
|
|
362
|
+
skipTransition: vi.fn(),
|
|
363
|
+
} as unknown as ViewTransition
|
|
364
|
+
})
|
|
365
|
+
document.startViewTransition = spy as typeof document.startViewTransition
|
|
366
|
+
return spy
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
it('should call startViewTransition on next when viewTransition is enabled', async () => {
|
|
370
|
+
const spy = mockStartViewTransition()
|
|
371
|
+
await usingAsync(
|
|
372
|
+
await renderWizard([Step1, Step2, Step3], undefined, { viewTransition: true }),
|
|
373
|
+
async ({ clickNext, getStepName }) => {
|
|
374
|
+
spy.mockClear()
|
|
375
|
+
await clickNext()
|
|
376
|
+
expect(spy).toHaveBeenCalledTimes(1)
|
|
377
|
+
expect(getStepName()).toBe('step2')
|
|
378
|
+
},
|
|
379
|
+
)
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
it('should call startViewTransition on prev when viewTransition is enabled', async () => {
|
|
383
|
+
const spy = mockStartViewTransition()
|
|
384
|
+
await usingAsync(
|
|
385
|
+
await renderWizard([Step1, Step2, Step3], undefined, { viewTransition: true }),
|
|
386
|
+
async ({ clickNext, clickPrev, getStepName }) => {
|
|
387
|
+
await clickNext()
|
|
388
|
+
spy.mockClear()
|
|
389
|
+
await clickPrev()
|
|
390
|
+
expect(spy).toHaveBeenCalledTimes(1)
|
|
391
|
+
expect(getStepName()).toBe('step1')
|
|
392
|
+
},
|
|
393
|
+
)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
it('should not call startViewTransition when viewTransition is not set', async () => {
|
|
397
|
+
const spy = mockStartViewTransition()
|
|
398
|
+
await usingAsync(await renderWizard([Step1, Step2, Step3]), async ({ clickNext, getStepName }) => {
|
|
399
|
+
spy.mockClear()
|
|
400
|
+
await clickNext()
|
|
401
|
+
expect(spy).not.toHaveBeenCalled()
|
|
402
|
+
expect(getStepName()).toBe('step2')
|
|
403
|
+
})
|
|
404
|
+
})
|
|
405
|
+
})
|
|
350
406
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ChildrenList } from '@furystack/shades'
|
|
2
|
-
import { createComponent, Shade } from '@furystack/shades'
|
|
1
|
+
import type { ChildrenList, ViewTransitionConfig } from '@furystack/shades'
|
|
2
|
+
import { createComponent, maybeViewTransition, Shade } from '@furystack/shades'
|
|
3
3
|
import { cssVariableTheme } from '../../services/css-variable-theme.js'
|
|
4
4
|
import { Paper } from '../paper.js'
|
|
5
5
|
|
|
@@ -39,6 +39,7 @@ export interface WizardProps {
|
|
|
39
39
|
* When true, a progress bar is shown above the content.
|
|
40
40
|
*/
|
|
41
41
|
showProgress?: boolean
|
|
42
|
+
viewTransition?: boolean | ViewTransitionConfig
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export const Wizard = Shade<WizardProps>({
|
|
@@ -182,14 +183,14 @@ export const Wizard = Shade<WizardProps>({
|
|
|
182
183
|
maxPages={props.steps.length}
|
|
183
184
|
onNext={() => {
|
|
184
185
|
if (currentPage < props.steps.length - 1) {
|
|
185
|
-
setCurrentPage(currentPage + 1)
|
|
186
|
+
void maybeViewTransition(props.viewTransition, () => setCurrentPage(currentPage + 1))
|
|
186
187
|
} else {
|
|
187
188
|
props.onFinish?.()
|
|
188
189
|
}
|
|
189
190
|
}}
|
|
190
191
|
onPrev={() => {
|
|
191
192
|
if (currentPage > 0) {
|
|
192
|
-
setCurrentPage(currentPage - 1)
|
|
193
|
+
void maybeViewTransition(props.viewTransition, () => setCurrentPage(currentPage - 1))
|
|
193
194
|
}
|
|
194
195
|
}}
|
|
195
196
|
/>
|