@hoardodile/ui 0.0.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/LICENSE +18 -0
- package/README.md +70 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +97 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/app-dialog.d.ts +62 -0
- package/dist/components/app-dialog.js +656 -0
- package/dist/components/app-dialog.js.map +1 -0
- package/dist/components/badge.d.ts +11 -0
- package/dist/components/badge.js +70 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.js +617 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +78 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/caption-bar.d.ts +44 -0
- package/dist/components/caption-bar.js +827 -0
- package/dist/components/caption-bar.js.map +1 -0
- package/dist/components/chart-card.d.ts +15 -0
- package/dist/components/chart-card.js +27 -0
- package/dist/components/chart-card.js.map +1 -0
- package/dist/components/checkbox.d.ts +6 -0
- package/dist/components/checkbox.js +76 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip-button.d.ts +28 -0
- package/dist/components/chip-button.js +87 -0
- package/dist/components/chip-button.js.map +1 -0
- package/dist/components/close-confirm-dialog.d.ts +19 -0
- package/dist/components/close-confirm-dialog.js +743 -0
- package/dist/components/close-confirm-dialog.js.map +1 -0
- package/dist/components/color-picker.d.ts +32 -0
- package/dist/components/color-picker.js +667 -0
- package/dist/components/color-picker.js.map +1 -0
- package/dist/components/combobox.d.ts +32 -0
- package/dist/components/combobox.js +1211 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/confirm-by-typing-dialog.d.ts +48 -0
- package/dist/components/confirm-by-typing-dialog.js +759 -0
- package/dist/components/confirm-by-typing-dialog.js.map +1 -0
- package/dist/components/confirm-dialog.d.ts +34 -0
- package/dist/components/confirm-dialog.js +710 -0
- package/dist/components/confirm-dialog.js.map +1 -0
- package/dist/components/count-badge.d.ts +13 -0
- package/dist/components/count-badge.js +39 -0
- package/dist/components/count-badge.js.map +1 -0
- package/dist/components/dialog.d.ts +40 -0
- package/dist/components/dialog.js +571 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +45 -0
- package/dist/components/dropdown-menu.js +1003 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/dropdown-select.d.ts +29 -0
- package/dist/components/dropdown-select.js +1036 -0
- package/dist/components/dropdown-select.js.map +1 -0
- package/dist/components/empty.d.ts +15 -0
- package/dist/components/empty.js +119 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/filter-rail.d.ts +48 -0
- package/dist/components/filter-rail.js +231 -0
- package/dist/components/filter-rail.js.map +1 -0
- package/dist/components/fixed-action-bar.d.ts +24 -0
- package/dist/components/fixed-action-bar.js +48 -0
- package/dist/components/fixed-action-bar.js.map +1 -0
- package/dist/components/font-picker.d.ts +45 -0
- package/dist/components/font-picker.js +759 -0
- package/dist/components/font-picker.js.map +1 -0
- package/dist/components/form.d.ts +17 -0
- package/dist/components/form.js +150 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/group-label.d.ts +12 -0
- package/dist/components/group-label.js +10 -0
- package/dist/components/group-label.js.map +1 -0
- package/dist/components/icon-tile.d.ts +16 -0
- package/dist/components/icon-tile.js +67 -0
- package/dist/components/icon-tile.js.map +1 -0
- package/dist/components/icon-toggle.d.ts +24 -0
- package/dist/components/icon-toggle.js +81 -0
- package/dist/components/icon-toggle.js.map +1 -0
- package/dist/components/icon.d.ts +2 -0
- package/dist/components/icon.js +49 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/image-crop-panel.d.ts +80 -0
- package/dist/components/image-crop-panel.js +1104 -0
- package/dist/components/image-crop-panel.js.map +1 -0
- package/dist/components/image-cropper.d.ts +63 -0
- package/dist/components/image-cropper.js +166 -0
- package/dist/components/image-cropper.js.map +1 -0
- package/dist/components/input-group.d.ts +22 -0
- package/dist/components/input-group.js +270 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +60 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +5 -0
- package/dist/components/label.js +40 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/list-empty-row.d.ts +16 -0
- package/dist/components/list-empty-row.js +40 -0
- package/dist/components/list-empty-row.js.map +1 -0
- package/dist/components/management-empty.d.ts +14 -0
- package/dist/components/management-empty.js +40 -0
- package/dist/components/management-empty.js.map +1 -0
- package/dist/components/management-skeleton.d.ts +11 -0
- package/dist/components/management-skeleton.js +72 -0
- package/dist/components/management-skeleton.js.map +1 -0
- package/dist/components/meta-chip.d.ts +17 -0
- package/dist/components/meta-chip.js +49 -0
- package/dist/components/meta-chip.js.map +1 -0
- package/dist/components/mobile-drawer.d.ts +29 -0
- package/dist/components/mobile-drawer.js +331 -0
- package/dist/components/mobile-drawer.js.map +1 -0
- package/dist/components/page-header.d.ts +20 -0
- package/dist/components/page-header.js +44 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/page-scaffold.d.ts +34 -0
- package/dist/components/page-scaffold.js +157 -0
- package/dist/components/page-scaffold.js.map +1 -0
- package/dist/components/pagination-bar.d.ts +22 -0
- package/dist/components/pagination-bar.js +703 -0
- package/dist/components/pagination-bar.js.map +1 -0
- package/dist/components/pagination.d.ts +22 -0
- package/dist/components/pagination.js +680 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/panel-toolbar.d.ts +37 -0
- package/dist/components/panel-toolbar.js +781 -0
- package/dist/components/panel-toolbar.js.map +1 -0
- package/dist/components/pill-tabs.d.ts +33 -0
- package/dist/components/pill-tabs.js +66 -0
- package/dist/components/pill-tabs.js.map +1 -0
- package/dist/components/plugin-download-consent.d.ts +52 -0
- package/dist/components/plugin-download-consent.js +780 -0
- package/dist/components/plugin-download-consent.js.map +1 -0
- package/dist/components/popover.d.ts +26 -0
- package/dist/components/popover.js +343 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +10 -0
- package/dist/components/progress.js +103 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/query-state-view.d.ts +36 -0
- package/dist/components/query-state-view.js +17 -0
- package/dist/components/query-state-view.js.map +1 -0
- package/dist/components/radio-group.d.ts +8 -0
- package/dist/components/radio-group.js +60 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/scroll-area.d.ts +7 -0
- package/dist/components/scroll-area.js +80 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/search-field.d.ts +49 -0
- package/dist/components/search-field.js +586 -0
- package/dist/components/search-field.js.map +1 -0
- package/dist/components/secondary-stat.d.ts +13 -0
- package/dist/components/secondary-stat.js +56 -0
- package/dist/components/secondary-stat.js.map +1 -0
- package/dist/components/section-header.d.ts +23 -0
- package/dist/components/section-header.js +76 -0
- package/dist/components/section-header.js.map +1 -0
- package/dist/components/section-label.d.ts +20 -0
- package/dist/components/section-label.js +46 -0
- package/dist/components/section-label.js.map +1 -0
- package/dist/components/section-tabs.d.ts +47 -0
- package/dist/components/section-tabs.js +145 -0
- package/dist/components/section-tabs.js.map +1 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +49 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +22 -0
- package/dist/components/sheet.js +469 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +69 -0
- package/dist/components/sidebar.js +1645 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.d.ts +8 -0
- package/dist/components/skeleton.js +41 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +6 -0
- package/dist/components/slider.js +75 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sortable-chip-list.d.ts +26 -0
- package/dist/components/sortable-chip-list.js +59 -0
- package/dist/components/sortable-chip-list.js.map +1 -0
- package/dist/components/spinner.d.ts +5 -0
- package/dist/components/spinner.js +65 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/surface.d.ts +13 -0
- package/dist/components/surface.js +51 -0
- package/dist/components/surface.js.map +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +53 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +129 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/textarea.d.ts +15 -0
- package/dist/components/textarea.js +58 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +19 -0
- package/dist/components/toast.js +805 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle.d.ts +12 -0
- package/dist/components/toggle.js +63 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +82 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/hooks/use-dialog-footer-actions.d.ts +18 -0
- package/dist/hooks/use-dialog-footer-actions.js +11 -0
- package/dist/hooks/use-dialog-footer-actions.js.map +1 -0
- package/dist/hooks/use-form-field.d.ts +33 -0
- package/dist/hooks/use-form-field.js +36 -0
- package/dist/hooks/use-form-field.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +34 -0
- package/dist/hooks/use-mobile.js +29 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-pinch-pan.d.ts +56 -0
- package/dist/hooks/use-pinch-pan.js +223 -0
- package/dist/hooks/use-pinch-pan.js.map +1 -0
- package/dist/hooks/useMobileBackToClose.d.ts +61 -0
- package/dist/hooks/useMobileBackToClose.js +234 -0
- package/dist/hooks/useMobileBackToClose.js.map +1 -0
- package/dist/icon-BOgL5bpL.d.ts +85 -0
- package/dist/icons/actions.d.ts +4 -0
- package/dist/icons/actions.js +520 -0
- package/dist/icons/actions.js.map +1 -0
- package/dist/icons/icon-style.d.ts +2 -0
- package/dist/icons/icon-style.js +51 -0
- package/dist/icons/icon-style.js.map +1 -0
- package/dist/icons/marks.d.ts +15 -0
- package/dist/icons/marks.js +48 -0
- package/dist/icons/marks.js.map +1 -0
- package/dist/icons/registry.d.ts +177 -0
- package/dist/icons/registry.js +1180 -0
- package/dist/icons/registry.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +653 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/merge-config.d.ts +15 -0
- package/dist/lib/merge-config.js +20 -0
- package/dist/lib/merge-config.js.map +1 -0
- package/dist/lib/pagination.d.ts +19 -0
- package/dist/lib/pagination.js +26 -0
- package/dist/lib/pagination.js.map +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +26 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles/theme.css +480 -0
- package/dist/styles/theme.css.map +1 -0
- package/dist/styles/theme.d.ts +2 -0
- package/dist/viewport.d.ts +64 -0
- package/dist/viewport.js +13 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +122 -0
- package/src/components/alert.tsx +76 -0
- package/src/components/app-dialog.tsx +187 -0
- package/src/components/badge.tsx +52 -0
- package/src/components/breadcrumb.tsx +129 -0
- package/src/components/button.tsx +70 -0
- package/src/components/caption-bar.test.tsx +151 -0
- package/src/components/caption-bar.tsx +392 -0
- package/src/components/chart-card.tsx +31 -0
- package/src/components/checkbox.tsx +28 -0
- package/src/components/chip-button.tsx +69 -0
- package/src/components/close-confirm-dialog.tsx +99 -0
- package/src/components/color-picker.tsx +186 -0
- package/src/components/combobox.tsx +335 -0
- package/src/components/confirm-by-typing-dialog.tsx +130 -0
- package/src/components/confirm-dialog.test.tsx +39 -0
- package/src/components/confirm-dialog.tsx +98 -0
- package/src/components/count-badge.tsx +23 -0
- package/src/components/dialog.tsx +315 -0
- package/src/components/dropdown-menu.tsx +311 -0
- package/src/components/dropdown-select.tsx +211 -0
- package/src/components/empty.tsx +104 -0
- package/src/components/filter-rail.tsx +139 -0
- package/src/components/fixed-action-bar.tsx +46 -0
- package/src/components/font-picker.tsx +257 -0
- package/src/components/form.tsx +127 -0
- package/src/components/group-label.tsx +13 -0
- package/src/components/icon-tile.tsx +35 -0
- package/src/components/icon-toggle.tsx +57 -0
- package/src/components/icon.tsx +66 -0
- package/src/components/image-crop-panel.test.tsx +167 -0
- package/src/components/image-crop-panel.tsx +465 -0
- package/src/components/image-cropper.test.tsx +144 -0
- package/src/components/image-cropper.tsx +265 -0
- package/src/components/input-group.tsx +156 -0
- package/src/components/input.tsx +45 -0
- package/src/components/label.tsx +20 -0
- package/src/components/list-empty-row.tsx +27 -0
- package/src/components/management-empty.tsx +25 -0
- package/src/components/management-skeleton.tsx +23 -0
- package/src/components/meta-chip.tsx +40 -0
- package/src/components/mobile-drawer.test.tsx +52 -0
- package/src/components/mobile-drawer.tsx +98 -0
- package/src/components/page-header.tsx +47 -0
- package/src/components/page-scaffold.test.tsx +24 -0
- package/src/components/page-scaffold.tsx +131 -0
- package/src/components/pagination-bar.test.tsx +87 -0
- package/src/components/pagination-bar.tsx +139 -0
- package/src/components/pagination.tsx +139 -0
- package/src/components/panel-toolbar.tsx +99 -0
- package/src/components/pill-tabs.test.tsx +84 -0
- package/src/components/pill-tabs.tsx +77 -0
- package/src/components/plugin-download-consent.test.tsx +90 -0
- package/src/components/plugin-download-consent.tsx +183 -0
- package/src/components/popover.tsx +133 -0
- package/src/components/progress.tsx +88 -0
- package/src/components/query-state-view.tsx +47 -0
- package/src/components/radio-group.tsx +36 -0
- package/src/components/scroll-area.tsx +52 -0
- package/src/components/search-field.test.tsx +86 -0
- package/src/components/search-field.tsx +119 -0
- package/src/components/secondary-stat.tsx +24 -0
- package/src/components/section-header.tsx +54 -0
- package/src/components/section-label.tsx +40 -0
- package/src/components/section-tabs.test.tsx +154 -0
- package/src/components/section-tabs.tsx +190 -0
- package/src/components/separator.tsx +38 -0
- package/src/components/sheet.tsx +170 -0
- package/src/components/sidebar.tsx +725 -0
- package/src/components/skeleton.tsx +18 -0
- package/src/components/slider.tsx +52 -0
- package/src/components/sortable-chip-list.tsx +56 -0
- package/src/components/spinner.tsx +35 -0
- package/src/components/surface.tsx +37 -0
- package/src/components/switch.tsx +30 -0
- package/src/components/table.tsx +116 -0
- package/src/components/textarea.tsx +41 -0
- package/src/components/toast.tsx +239 -0
- package/src/components/toggle.tsx +45 -0
- package/src/components/tooltip.tsx +64 -0
- package/src/hooks/use-dialog-footer-actions.ts +23 -0
- package/src/hooks/use-form-field.ts +62 -0
- package/src/hooks/use-mobile.ts +54 -0
- package/src/hooks/use-pinch-pan.test.tsx +42 -0
- package/src/hooks/use-pinch-pan.ts +340 -0
- package/src/hooks/useMobileBackToClose.test.tsx +140 -0
- package/src/hooks/useMobileBackToClose.ts +508 -0
- package/src/icons/actions.ts +10 -0
- package/src/icons/icon-style.test.tsx +69 -0
- package/src/icons/icon-style.ts +104 -0
- package/src/icons/marks.tsx +72 -0
- package/src/icons/registry.test.ts +65 -0
- package/src/icons/registry.ts +1163 -0
- package/src/index.ts +22 -0
- package/src/lib/merge-config.test.ts +109 -0
- package/src/lib/merge-config.ts +22 -0
- package/src/lib/pagination.test.ts +55 -0
- package/src/lib/pagination.ts +42 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/scan-contract.test.ts +74 -0
- package/src/styles/theme.css +798 -0
- package/src/test/i18n.tsx +22 -0
- package/src/test/setup.ts +104 -0
- package/src/viewport.ts +69 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createI18n } from "@hoardodile/i18n"
|
|
2
|
+
import { I18nProvider } from "@hoardodile/i18n/react"
|
|
3
|
+
import { render } from "@testing-library/react"
|
|
4
|
+
import type { ReactElement } from "react"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared English i18n instance for component tests. Bind it explicitly
|
|
8
|
+
* through the provider (never via react-i18next's module-global default:
|
|
9
|
+
* the workspace keeps more than one physical react-i18next copy, so the
|
|
10
|
+
* global instance is only reliable within a single package).
|
|
11
|
+
*/
|
|
12
|
+
export const testI18n = createI18n()
|
|
13
|
+
|
|
14
|
+
/** Render with the shared i18n instance so components resolve the `ui`
|
|
15
|
+
* namespace. Tests that assert non-English copy call `changeLanguage`
|
|
16
|
+
* on {@link testI18n} and restore `"en"` afterwards. */
|
|
17
|
+
export function renderWithI18n(
|
|
18
|
+
ui: ReactElement,
|
|
19
|
+
options?: Parameters<typeof render>[1],
|
|
20
|
+
): ReturnType<typeof render> {
|
|
21
|
+
return render(<I18nProvider i18n={testI18n}>{ui}</I18nProvider>, options)
|
|
22
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest"
|
|
2
|
+
|
|
3
|
+
import { cleanup } from "@testing-library/react"
|
|
4
|
+
import { afterEach } from "vitest"
|
|
5
|
+
|
|
6
|
+
// Test components that render `@hoardodile/ui` strings use the
|
|
7
|
+
// `renderWithI18n` helper (see `./i18n.ts`) — it wraps the tree in an
|
|
8
|
+
// I18nProvider bound to the shared test instance.
|
|
9
|
+
|
|
10
|
+
// jsdom does not implement matchMedia; stub it deterministically so
|
|
11
|
+
// media-query code paths (use-mobile, useMobileBackToClose) have
|
|
12
|
+
// something to consult during tests.
|
|
13
|
+
if (typeof window !== "undefined") {
|
|
14
|
+
Object.defineProperty(window, "matchMedia", {
|
|
15
|
+
writable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
value: (query: string) => ({
|
|
18
|
+
matches: false,
|
|
19
|
+
media: query,
|
|
20
|
+
onchange: null,
|
|
21
|
+
addListener: () => undefined,
|
|
22
|
+
removeListener: () => undefined,
|
|
23
|
+
addEventListener: () => undefined,
|
|
24
|
+
removeEventListener: () => undefined,
|
|
25
|
+
dispatchEvent: () => false,
|
|
26
|
+
}),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// jsdom does not implement ResizeObserver; stub it so virtual list
|
|
30
|
+
// libraries can measure the scroll container during tests.
|
|
31
|
+
class StubResizeObserver {
|
|
32
|
+
observe() {}
|
|
33
|
+
unobserve() {}
|
|
34
|
+
disconnect() {}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(window, "ResizeObserver", {
|
|
38
|
+
writable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
value: StubResizeObserver,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// jsdom does not implement IntersectionObserver; stub it so lazy-loading
|
|
44
|
+
// sentinel elements do not crash tests.
|
|
45
|
+
class StubIntersectionObserver {
|
|
46
|
+
observe() {}
|
|
47
|
+
unobserve() {}
|
|
48
|
+
disconnect() {}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(window, "IntersectionObserver", {
|
|
52
|
+
writable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
value: StubIntersectionObserver,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
Object.defineProperty(window, "scrollTo", {
|
|
58
|
+
writable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
value: () => undefined,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
Object.defineProperty(Element.prototype, "scrollTo", {
|
|
64
|
+
writable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
value: () => undefined,
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// jsdom does not implement HTMLCanvasElement#getContext; the image
|
|
71
|
+
// cropping pipeline consults it during tests. Return a no-op 2D context
|
|
72
|
+
// so cropper components can mount without noisy "canvas npm package"
|
|
73
|
+
// warnings.
|
|
74
|
+
if (typeof HTMLCanvasElement !== "undefined") {
|
|
75
|
+
Object.defineProperty(HTMLCanvasElement.prototype, "getContext", {
|
|
76
|
+
writable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
value: (contextId: string) => {
|
|
79
|
+
if (contextId !== "2d") return null
|
|
80
|
+
const noOp = () => undefined
|
|
81
|
+
return new Proxy(
|
|
82
|
+
{},
|
|
83
|
+
{
|
|
84
|
+
get(_target, prop) {
|
|
85
|
+
if (prop === "canvas") return null
|
|
86
|
+
if (prop === "getContextAttributes") return () => ({})
|
|
87
|
+
if (prop === "measureText") return () => ({ width: 0 })
|
|
88
|
+
if (prop === "getImageData") return () => ({ data: [] })
|
|
89
|
+
if (prop === "createImageData")
|
|
90
|
+
return () => ({ data: [], width: 0, height: 0 })
|
|
91
|
+
if (prop === "isPointInPath") return () => false
|
|
92
|
+
if (prop === "isPointInStroke") return () => false
|
|
93
|
+
return noOp
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
) as unknown as CanvasRenderingContext2D
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
afterEach(() => {
|
|
102
|
+
cleanup()
|
|
103
|
+
if (typeof localStorage !== "undefined") localStorage.clear()
|
|
104
|
+
})
|
package/src/viewport.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mobile viewport initial-scale factor used across the app shell and
|
|
3
|
+
* plugin iframe previews. Kept in one place so it can be changed
|
|
4
|
+
* without hunting through HTML templates and CSS rules.
|
|
5
|
+
*/
|
|
6
|
+
export const MOBILE_INITIAL_SCALE = 0.8
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Width in pixels at which the app switches from below-md to md+ layouts.
|
|
10
|
+
*
|
|
11
|
+
* This value is intentionally aligned with Tailwind's `md` breakpoint
|
|
12
|
+
* (768 px) so that JS detection and CSS responsive prefixes stay in sync.
|
|
13
|
+
* Components that need to know whether they are in the "below md" viewport
|
|
14
|
+
* should use {@link isBelowMd} or {@link useBelowMd} from @hoardodile/ui/hooks/use-mobile.
|
|
15
|
+
*/
|
|
16
|
+
export const MOBILE_BREAKPOINT_PX = 768
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Same breakpoint expressed in rems, matching Tailwind's default theme
|
|
20
|
+
* (`--breakpoint-md: 48rem`). Useful for CSS media queries and comments.
|
|
21
|
+
*/
|
|
22
|
+
export const MOBILE_BREAKPOINT_REM = MOBILE_BREAKPOINT_PX / 16
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Media query string that matches viewports below the `md` breakpoint
|
|
26
|
+
* (< 768 px). Shared between JS hooks and anywhere else that needs to detect
|
|
27
|
+
* a below-md viewport.
|
|
28
|
+
*
|
|
29
|
+
* Keep this in sync with the CSS/Tailwind breakpoint so JS and CSS never
|
|
30
|
+
* disagree about the viewport size.
|
|
31
|
+
*/
|
|
32
|
+
export const MOBILE_QUERY = `(max-width: ${MOBILE_BREAKPOINT_PX - 1}px)`
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Width in pixels at which the app switches from a drawer to a fixed left
|
|
36
|
+
* sidebar (the "app shell"). Raised above `md` so mid-size viewports keep
|
|
37
|
+
* the whole width for their content column — below this the sidebar hides
|
|
38
|
+
* behind the hamburger drawer.
|
|
39
|
+
*
|
|
40
|
+
* Use the CSS `sidebar:` / `max-sidebar:` variants (`--breakpoint-sidebar`)
|
|
41
|
+
* at call sites — this value is the single source of truth for both.
|
|
42
|
+
*/
|
|
43
|
+
export const SIDEBAR_BREAKPOINT_PX = 1150
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Media query string that matches viewports below the sidebar breakpoint
|
|
47
|
+
* (`max-sidebar`), i.e. where the shell shows the drawer instead of the fixed
|
|
48
|
+
* sidebar. Shared between JS hooks and anywhere else that needs the
|
|
49
|
+
* below-sidebar viewport.
|
|
50
|
+
*/
|
|
51
|
+
export const SIDEBAR_QUERY = `(max-width: ${SIDEBAR_BREAKPOINT_PX - 1}px)`
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Width in pixels at which the right filter rail switches from a fixed
|
|
55
|
+
* column to a drawer (DESIGN.md — Layout: "the panel becomes an
|
|
56
|
+
* overlay below 1440px"). Below this the sidebar + panel + content no
|
|
57
|
+
* longer fit comfortably, so the rail hides behind a Filters button.
|
|
58
|
+
*
|
|
59
|
+
* Use the CSS `panel:` / `max-panel:` variants (`--breakpoint-panel`)
|
|
60
|
+
* at call sites — this value is the single source of truth for both.
|
|
61
|
+
*/
|
|
62
|
+
export const PANEL_BREAKPOINT_PX = 1440
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Media query string that matches viewports below the panel breakpoint
|
|
66
|
+
* (< 1440 px), i.e. where the filter rail lives in a drawer. Shared
|
|
67
|
+
* between JS hooks and anywhere else that needs the below-panel viewport.
|
|
68
|
+
*/
|
|
69
|
+
export const PANEL_QUERY = `(max-width: ${PANEL_BREAKPOINT_PX - 1}px)`
|