@appica/ui-react 1.1.0 → 1.2.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 +26 -0
- package/README.md +1 -1
- package/agent-rules.md +2 -2
- package/appica.css +1 -1
- package/dist/components/accordion/accordion.js +1 -0
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.js +1 -0
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +1 -0
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +1 -0
- package/dist/components/autocomplete/autocomplete.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/avatar.js +1 -0
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts +2 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.js +3 -1
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.d.ts +3 -2
- package/dist/components/background-pattern/background-pattern-shared.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.js +47 -15
- package/dist/components/background-pattern/background-pattern-shared.js.map +1 -1
- package/dist/components/background-pattern/background-pattern.d.ts +1 -1
- package/dist/components/background-pattern/background-pattern.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern.js +12 -3
- package/dist/components/background-pattern/background-pattern.js.map +1 -1
- package/dist/components/background-pattern/index.js +1 -0
- package/dist/components/background-pattern/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts +2 -2
- package/dist/components/badge/badge.js +1 -0
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/border-beam/border-beam.js +1 -0
- package/dist/components/border-beam/border-beam.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button-variants.d.ts +2 -2
- package/dist/components/button/button-variants.js +1 -0
- package/dist/components/button/button-variants.js.map +1 -1
- package/dist/components/button/button.js +1 -0
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/button-group-context.js +1 -0
- package/dist/components/button-group/button-group-context.js.map +1 -1
- package/dist/components/button-group/button-group.js +1 -0
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/calendar/calendar.js +1 -0
- package/dist/components/calendar/calendar.js.map +1 -1
- package/dist/components/card/card.js +2 -1
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/carousel/carousel.d.ts +3 -3
- package/dist/components/carousel/carousel.d.ts.map +1 -1
- package/dist/components/carousel/carousel.js +23 -0
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +1 -0
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +1 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/chip/chip.d.ts +1 -1
- package/dist/components/chip/chip.js +1 -0
- package/dist/components/chip/chip.js.map +1 -1
- package/dist/components/collapsible/collapsible.js +1 -0
- package/dist/components/collapsible/collapsible.js.map +1 -1
- package/dist/components/color-area/color-area.js +1 -0
- package/dist/components/color-area/color-area.js.map +1 -1
- package/dist/components/color-picker/color-picker.js +1 -0
- package/dist/components/color-picker/color-picker.js.map +1 -1
- package/dist/components/color-slider/color-slider.js +1 -0
- package/dist/components/color-slider/color-slider.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.d.ts +1 -1
- package/dist/components/color-swatch/color-swatch.js +1 -0
- package/dist/components/color-swatch/color-swatch.js.map +1 -1
- package/dist/components/color-swatch-picker/color-swatch-picker.d.ts +1 -1
- package/dist/components/color-swatch-picker/color-swatch-picker.js +1 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.js.map +1 -1
- package/dist/components/combobox/combobox.js +1 -0
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/context-menu/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu/context-menu.js +6 -0
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/copy-button/copy-button.d.ts +3 -1
- package/dist/components/copy-button/copy-button.d.ts.map +1 -1
- package/dist/components/copy-button/copy-button.js +5 -4
- package/dist/components/copy-button/copy-button.js.map +1 -1
- package/dist/components/countdown/countdown.js +1 -0
- package/dist/components/countdown/countdown.js.map +1 -1
- package/dist/components/date-field/date-field.js +1 -0
- package/dist/components/date-field/date-field.js.map +1 -1
- package/dist/components/date-picker/date-picker.js +1 -0
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/dialog/dialog.js +1 -0
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.js +1 -0
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +6 -0
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field.js +1 -0
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.js +1 -0
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/form/form.js +1 -0
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts +6 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.js +4 -2
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -1
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/input-variants.d.ts +1 -1
- package/dist/components/input/input-variants.js +1 -0
- package/dist/components/input/input-variants.js.map +1 -1
- package/dist/components/input/input.js +1 -0
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/kbd/kbd.js +1 -0
- package/dist/components/kbd/kbd.js.map +1 -1
- package/dist/components/loader/loader.js +1 -0
- package/dist/components/loader/loader.js.map +1 -1
- package/dist/components/menubar/menubar.js +1 -0
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/meter/meter.js +1 -0
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/navigation-context.js +1 -0
- package/dist/components/navigation/navigation-context.js.map +1 -1
- package/dist/components/navigation/navigation-link-variants.d.ts +2 -2
- package/dist/components/navigation/navigation-link-variants.js +1 -0
- package/dist/components/navigation/navigation-link-variants.js.map +1 -1
- package/dist/components/navigation/navigation-link.js +1 -0
- package/dist/components/navigation/navigation-link.js.map +1 -1
- package/dist/components/navigation/navigation.js +1 -0
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +1 -0
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/number-field/number-field.js +1 -0
- package/dist/components/number-field/number-field.js.map +1 -1
- package/dist/components/otp-field/otp-field.js +1 -0
- package/dist/components/otp-field/otp-field.js.map +1 -1
- package/dist/components/pagination/pagination.js +1 -0
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/popover/popover.js +1 -0
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/preview-card/preview-card.js +1 -0
- package/dist/components/preview-card/preview-card.js.map +1 -1
- package/dist/components/progress/progress.js +1 -0
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.js +1 -0
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio-group/radio-group.js +1 -0
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/rating/rating.js +1 -0
- package/dist/components/rating/rating.js.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +1 -0
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/select/select.js +1 -0
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.js +1 -0
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/skeleton/skeleton.js +1 -0
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.js +1 -0
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/sparkline/sparkline.js +1 -0
- package/dist/components/sparkline/sparkline.js.map +1 -1
- package/dist/components/spinner/spinner.js +1 -0
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/switch/switch.d.ts +15 -15
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +1 -0
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table.js +1 -0
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +1 -0
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text-animate/text-animate.js +1 -0
- package/dist/components/text-animate/text-animate.js.map +1 -1
- package/dist/components/textarea/textarea.js +1 -0
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/thumbnail/thumbnail.d.ts +2 -2
- package/dist/components/thumbnail/thumbnail.js +1 -0
- package/dist/components/thumbnail/thumbnail.js.map +1 -1
- package/dist/components/time-field/time-field.js +1 -0
- package/dist/components/time-field/time-field.js.map +1 -1
- package/dist/components/toast/toast.js +1 -0
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toc/toc.js +1 -0
- package/dist/components/toc/toc.js.map +1 -1
- package/dist/components/toggle/toggle.js +1 -0
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/toggle-group/toggle-group.js +1 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/toolbar/toolbar.js +1 -0
- package/dist/components/toolbar/toolbar.js.map +1 -1
- package/dist/components/tooltip/tooltip.js +1 -0
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/hooks/use-direction.js +1 -0
- package/dist/hooks/use-direction.js.map +1 -1
- package/dist/hooks/use-dismissible.js +1 -0
- package/dist/hooks/use-dismissible.js.map +1 -1
- package/dist/hooks/use-local-storage.js +1 -0
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-media-query.js +1 -0
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-reduced-motion.js +1 -0
- package/dist/hooks/use-reduced-motion.js.map +1 -1
- package/dist/hooks/use-theme.js +1 -0
- package/dist/hooks/use-theme.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/color-control.d.ts +9 -9
- package/dist/internal/color-control.d.ts.map +1 -1
- package/dist/internal/color-control.js +1 -0
- package/dist/internal/color-control.js.map +1 -1
- package/dist/internal/color-math.js +1 -0
- package/dist/internal/color-math.js.map +1 -1
- package/dist/internal/color-picker-context.js +1 -0
- package/dist/internal/color-picker-context.js.map +1 -1
- package/dist/internal/floating.d.ts +2 -2
- package/dist/internal/floating.d.ts.map +1 -1
- package/dist/internal/floating.js +1 -0
- package/dist/internal/floating.js.map +1 -1
- package/dist/internal/modal.d.ts +1 -1
- package/dist/internal/modal.d.ts.map +1 -1
- package/dist/internal/modal.js +1 -0
- package/dist/internal/modal.js.map +1 -1
- package/dist/internal/utils.d.ts +2 -2
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +1 -0
- package/dist/internal/utils.js.map +1 -1
- package/dist/lib/color.js +1 -0
- package/dist/lib/color.js.map +1 -1
- package/dist/providers/direction-provider.js +1 -0
- package/dist/providers/direction-provider.js.map +1 -1
- package/dist/providers/reduced-motion-provider.js +1 -0
- package/dist/providers/reduced-motion-provider.js.map +1 -1
- package/dist/providers/theme-provider/index.js +1 -0
- package/dist/providers/theme-provider/index.js.map +1 -1
- package/dist/providers/theme-provider/theme-provider.js +1 -0
- package/dist/providers/theme-provider/theme-provider.js.map +1 -1
- package/dist/providers/theme-provider/theme-script.js +1 -0
- package/dist/providers/theme-provider/theme-script.js.map +1 -1
- package/package.json +29 -27
- package/src/components/background-pattern/background-pattern-interactive.tsx +3 -1
- package/src/components/background-pattern/background-pattern-shared.tsx +55 -18
- package/src/components/background-pattern/background-pattern.test.tsx +35 -0
- package/src/components/background-pattern/background-pattern.tsx +11 -4
- package/src/components/card/card.tsx +1 -1
- package/src/components/carousel/carousel.test.tsx +24 -0
- package/src/components/carousel/carousel.tsx +26 -3
- package/src/components/context-menu/context-menu.test.tsx +28 -0
- package/src/components/context-menu/context-menu.tsx +5 -0
- package/src/components/copy-button/copy-button.test.tsx +13 -0
- package/src/components/copy-button/copy-button.tsx +11 -5
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +28 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +5 -0
- package/src/components/gradient-glow/gradient-glow.test.tsx +6 -0
- package/src/components/gradient-glow/gradient-glow.tsx +18 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-script.js","sources":["../../../src/providers/theme-provider/theme-script.tsx"],"sourcesContent":["// Server-safe: a pure inline-script generator plus a <script> component.\n// No 'use client' - `getThemeScript` can be called in any environment (Vite\n// main entry, Astro `is:inline`, etc.) and `ThemeScript` can render in a\n// Server Component <head>.\n\nimport * as React from 'react'\n\nexport interface ThemeScriptOptions {\n storageKey?: string\n defaultTheme?: string\n forcedTheme?: string\n themes?: string[]\n value?: Record<string, string>\n enableSystem?: boolean\n enableColorScheme?: boolean\n}\n\n// Serialized via `.toString()` and injected as an inline <script> that runs\n// before hydration to set the theme class on <html> with no flash. It must be\n// fully self-contained (no external references) so the stringified output is\n// valid, runnable code.\nfunction themeScript(\n storageKey: string,\n defaultTheme: string,\n forcedTheme: string | null,\n themes: string[],\n value: Record<string, string> | null,\n enableSystem: boolean,\n enableColorScheme: boolean,\n) {\n const el = document.documentElement\n const system = ['light', 'dark']\n const classFor = (t: string) => (value && value[t] ? value[t] : t)\n const updateDOM = (theme: string) => {\n el.classList.remove(...themes.map(classFor))\n el.classList.add(classFor(theme))\n if (enableColorScheme && system.indexOf(theme) !== -1) {\n el.style.colorScheme = theme\n }\n }\n if (forcedTheme) {\n updateDOM(forcedTheme)\n } else {\n try {\n const stored = localStorage.getItem(storageKey) || defaultTheme\n const resolved =\n enableSystem && stored === 'system'\n ? window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n : stored\n updateDOM(resolved)\n } catch (e) {\n // storage unavailable - leave the default\n }\n }\n}\n\n/**\n * Returns the inline no-flash script as a string, ready to drop into a\n * `<script>` before hydration. Use this directly when your framework doesn't\n * render React on the server (e.g. a Vite SPA `index.html`, or Astro\n * `<script is:inline>`); otherwise prefer the `<ThemeScript />` component.\n */\nexport function getThemeScript(options: ThemeScriptOptions = {}): string {\n const {\n storageKey = 'theme',\n enableSystem = true,\n defaultTheme = enableSystem ? 'system' : 'light',\n forcedTheme,\n themes = ['light', 'dark'],\n value,\n enableColorScheme = true,\n } = options\n // JSON.stringify turns `undefined` into `null` inside arrays, so slicing the\n // brackets yields a valid argument list (unlike a manual comma-join).\n const args = JSON.stringify([\n storageKey,\n defaultTheme,\n forcedTheme ?? null,\n themes,\n value ?? null,\n enableSystem,\n enableColorScheme,\n ]).slice(1, -1)\n return `(${themeScript.toString()})(${args})`\n}\n\nexport interface ThemeScriptProps extends ThemeScriptOptions {\n nonce?: string\n scriptProps?: React.ScriptHTMLAttributes<HTMLScriptElement>\n}\n\n/**\n * Renders the inline no-flash script. The `<ThemeProvider>` mounts this for you;\n * render it manually (e.g. in a Next.js `<head>`) only if you need to control its\n * placement.\n */\nexport function ThemeScript({ nonce, scriptProps, ...options }: ThemeScriptProps) {\n return (\n <script\n {...scriptProps}\n suppressHydrationWarning\n nonce={typeof window === 'undefined' ? nonce : ''}\n dangerouslySetInnerHTML={{ __html: getThemeScript(options) }}\n />\n )\n}\n"],"names":[],"mappings":";;AAqBA,SAAS,YACP,UAAA,EACA,YAAA,EACA,aACA,MAAA,EACA,KAAA,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WAAA;AAAA,IACA,MAAA,GAAS,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,IACzB,KAAA;AAAA,IACA,iBAAA,GAAoB;AAAA,GACtB,GAAI,OAAA;AAGJ,EAAA,MAAM,IAAA,GAAO,KAAK,SAAA,CAAU;AAAA,IAC1B,UAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA,IAAe,IAAA;AAAA,IACf,MAAA;AAAA,IACA,KAAA,IAAS,IAAA;AAAA,IACT,YAAA;AAAA,IACA;AAAA,GACD,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACd,EAAA,OAAO,CAAA,CAAA,EAAI,WAAA,CAAY,QAAA,EAAU,KAAK,IAAI,CAAA,CAAA,CAAA;AAC5C;AAYO,SAAS,YAAY,EAAE,KAAA,EAAO,WAAA,EAAa,GAAG,SAAQ,EAAqB;AAChF,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACE,GAAG,WAAA;AAAA,MACJ,wBAAA,EAAwB,IAAA;AAAA,MACxB,KAAA,EAAO,OAAO,MAAA,KAAW,WAAA,GAAc,KAAA,GAAQ,EAAA;AAAA,MAC/C,uBAAA,EAAyB,EAAE,MAAA,EAAQ,cAAA,CAAe,OAAO,CAAA;AAAE;AAAA,GAC7D;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"theme-script.js","sources":["../../../src/providers/theme-provider/theme-script.tsx"],"sourcesContent":["// Server-safe: a pure inline-script generator plus a <script> component.\n// No 'use client' - `getThemeScript` can be called in any environment (Vite\n// main entry, Astro `is:inline`, etc.) and `ThemeScript` can render in a\n// Server Component <head>.\n\nimport * as React from 'react'\n\nexport interface ThemeScriptOptions {\n storageKey?: string\n defaultTheme?: string\n forcedTheme?: string\n themes?: string[]\n value?: Record<string, string>\n enableSystem?: boolean\n enableColorScheme?: boolean\n}\n\n// Serialized via `.toString()` and injected as an inline <script> that runs\n// before hydration to set the theme class on <html> with no flash. It must be\n// fully self-contained (no external references) so the stringified output is\n// valid, runnable code.\nfunction themeScript(\n storageKey: string,\n defaultTheme: string,\n forcedTheme: string | null,\n themes: string[],\n value: Record<string, string> | null,\n enableSystem: boolean,\n enableColorScheme: boolean,\n) {\n const el = document.documentElement\n const system = ['light', 'dark']\n const classFor = (t: string) => (value && value[t] ? value[t] : t)\n const updateDOM = (theme: string) => {\n el.classList.remove(...themes.map(classFor))\n el.classList.add(classFor(theme))\n if (enableColorScheme && system.indexOf(theme) !== -1) {\n el.style.colorScheme = theme\n }\n }\n if (forcedTheme) {\n updateDOM(forcedTheme)\n } else {\n try {\n const stored = localStorage.getItem(storageKey) || defaultTheme\n const resolved =\n enableSystem && stored === 'system'\n ? window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light'\n : stored\n updateDOM(resolved)\n } catch (e) {\n // storage unavailable - leave the default\n }\n }\n}\n\n/**\n * Returns the inline no-flash script as a string, ready to drop into a\n * `<script>` before hydration. Use this directly when your framework doesn't\n * render React on the server (e.g. a Vite SPA `index.html`, or Astro\n * `<script is:inline>`); otherwise prefer the `<ThemeScript />` component.\n */\nexport function getThemeScript(options: ThemeScriptOptions = {}): string {\n const {\n storageKey = 'theme',\n enableSystem = true,\n defaultTheme = enableSystem ? 'system' : 'light',\n forcedTheme,\n themes = ['light', 'dark'],\n value,\n enableColorScheme = true,\n } = options\n // JSON.stringify turns `undefined` into `null` inside arrays, so slicing the\n // brackets yields a valid argument list (unlike a manual comma-join).\n const args = JSON.stringify([\n storageKey,\n defaultTheme,\n forcedTheme ?? null,\n themes,\n value ?? null,\n enableSystem,\n enableColorScheme,\n ]).slice(1, -1)\n return `(${themeScript.toString()})(${args})`\n}\n\nexport interface ThemeScriptProps extends ThemeScriptOptions {\n nonce?: string\n scriptProps?: React.ScriptHTMLAttributes<HTMLScriptElement>\n}\n\n/**\n * Renders the inline no-flash script. The `<ThemeProvider>` mounts this for you;\n * render it manually (e.g. in a Next.js `<head>`) only if you need to control its\n * placement.\n */\nexport function ThemeScript({ nonce, scriptProps, ...options }: ThemeScriptProps) {\n return (\n <script\n {...scriptProps}\n suppressHydrationWarning\n nonce={typeof window === 'undefined' ? nonce : ''}\n dangerouslySetInnerHTML={{ __html: getThemeScript(options) }}\n />\n )\n}\n"],"names":[],"mappings":";;;AAqBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EACP,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,YAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GACA,iBAAA,CAAA,CACA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,IAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACpB,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,MAAM,CAAA;AAC/B,CAAA,CAAA,MAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,KAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,EAAM,CAAC,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CA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AAA,CAAA,CAAA,CAAA,EAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAQ,CAAA,CAAA;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC/C,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAyB,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAe,OAAO,CAAA,CAAA;AAAE,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA,CAAA,CAC7D;AAEJ;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appica/ui-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Appica UI components library for React applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Appica UI",
|
|
@@ -466,44 +466,46 @@
|
|
|
466
466
|
"CHANGELOG.md"
|
|
467
467
|
],
|
|
468
468
|
"dependencies": {
|
|
469
|
-
"@base-ui/react": "^1.
|
|
469
|
+
"@base-ui/react": "^1.8.0",
|
|
470
470
|
"class-variance-authority": "^0.7.1",
|
|
471
471
|
"clsx": "^2.1.1",
|
|
472
472
|
"date-fns": "^4.4.0",
|
|
473
|
-
"embla-carousel": "9.0.0-
|
|
474
|
-
"embla-carousel-accessibility": "9.0.0-
|
|
475
|
-
"embla-carousel-auto-height": "9.0.0-
|
|
476
|
-
"embla-carousel-auto-scroll": "9.0.0-
|
|
477
|
-
"embla-carousel-autoplay": "9.0.0-
|
|
478
|
-
"embla-carousel-class-names": "9.0.0-
|
|
479
|
-
"embla-carousel-fade": "9.0.0-
|
|
480
|
-
"embla-carousel-react": "9.0.0-
|
|
481
|
-
"embla-carousel-wheel-gestures": "9.0.0-
|
|
482
|
-
"motion": "^13.
|
|
473
|
+
"embla-carousel": "9.0.0-rc03",
|
|
474
|
+
"embla-carousel-accessibility": "9.0.0-rc03",
|
|
475
|
+
"embla-carousel-auto-height": "9.0.0-rc03",
|
|
476
|
+
"embla-carousel-auto-scroll": "9.0.0-rc03",
|
|
477
|
+
"embla-carousel-autoplay": "9.0.0-rc03",
|
|
478
|
+
"embla-carousel-class-names": "9.0.0-rc03",
|
|
479
|
+
"embla-carousel-fade": "9.0.0-rc03",
|
|
480
|
+
"embla-carousel-react": "9.0.0-rc03",
|
|
481
|
+
"embla-carousel-wheel-gestures": "9.0.0-rc02",
|
|
482
|
+
"motion": "^13.4.1",
|
|
483
483
|
"react-day-picker": "^10.0.1",
|
|
484
|
-
"tailwind-merge": "^3.
|
|
484
|
+
"tailwind-merge": "^3.7.0"
|
|
485
485
|
},
|
|
486
486
|
"devDependencies": {
|
|
487
487
|
"@tailwindcss/postcss": "^4.3.3",
|
|
488
|
-
"@testing-library/dom": "^10.4.
|
|
488
|
+
"@testing-library/dom": "^10.4.2",
|
|
489
489
|
"@testing-library/jest-dom": "^7.0.1",
|
|
490
|
-
"@testing-library/react": "^16.3.
|
|
491
|
-
"@testing-library/user-event": "^14.6.
|
|
492
|
-
"@types/react": "^19.
|
|
493
|
-
"@types/react-dom": "^19.
|
|
494
|
-
"@
|
|
495
|
-
"@
|
|
490
|
+
"@testing-library/react": "^16.3.3",
|
|
491
|
+
"@testing-library/user-event": "^14.6.7",
|
|
492
|
+
"@types/react": "^19.3.0",
|
|
493
|
+
"@types/react-dom": "^19.3.0",
|
|
494
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
495
|
+
"@vitejs/plugin-react": "^6.1.1",
|
|
496
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
496
497
|
"axe-core": "^4.13.0",
|
|
497
|
-
"jsdom": "^30.
|
|
498
|
-
"postcss": "^8.5.
|
|
499
|
-
"react": "^19.
|
|
500
|
-
"react-dom": "^19.
|
|
501
|
-
"rollup": "^4.
|
|
498
|
+
"jsdom": "^30.1.1",
|
|
499
|
+
"postcss": "^8.5.28",
|
|
500
|
+
"react": "^19.3.0",
|
|
501
|
+
"react-dom": "^19.3.0",
|
|
502
|
+
"rollup": "^4.63.4",
|
|
502
503
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
503
504
|
"rollup-preserve-directives": "^1.1.3",
|
|
504
505
|
"tailwindcss": "^4.3.3",
|
|
505
|
-
"typescript": "
|
|
506
|
-
"
|
|
506
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
507
|
+
"vite": "^8.3.0",
|
|
508
|
+
"vitest": "^5.0.1",
|
|
507
509
|
"vitest-axe": "^0.1.0"
|
|
508
510
|
},
|
|
509
511
|
"peerDependencies": {
|
|
@@ -7,6 +7,7 @@ import { PatternLayer, patternSpotlight, type BackgroundPatternVariant } from '.
|
|
|
7
7
|
|
|
8
8
|
interface BackgroundPatternInteractiveProps {
|
|
9
9
|
variant: BackgroundPatternVariant
|
|
10
|
+
cell: number
|
|
10
11
|
persistent?: boolean
|
|
11
12
|
track?: 'self' | 'window'
|
|
12
13
|
}
|
|
@@ -18,6 +19,7 @@ const FADE_DURATION = 1200
|
|
|
18
19
|
|
|
19
20
|
function BackgroundPatternInteractive({
|
|
20
21
|
variant,
|
|
22
|
+
cell,
|
|
21
23
|
persistent: persistentProp = false,
|
|
22
24
|
track = 'self',
|
|
23
25
|
}: BackgroundPatternInteractiveProps) {
|
|
@@ -85,7 +87,7 @@ function BackgroundPatternInteractive({
|
|
|
85
87
|
)}
|
|
86
88
|
style={{ WebkitMaskImage: SPOTLIGHT, maskImage: SPOTLIGHT }}
|
|
87
89
|
>
|
|
88
|
-
<PatternLayer variant={variant} className={patternSpotlight(variant)} />
|
|
90
|
+
<PatternLayer variant={variant} cell={cell} className={patternSpotlight(variant)} />
|
|
89
91
|
</div>
|
|
90
92
|
)
|
|
91
93
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cn } from '../../internal/utils'
|
|
2
2
|
|
|
3
|
-
type BackgroundPatternVariant = 'dots' | 'grid' | '
|
|
3
|
+
type BackgroundPatternVariant = 'dots' | 'grid' | 'hexagons' | 'rings' | 'checkerboard'
|
|
4
4
|
|
|
5
5
|
interface MaskSpec {
|
|
6
|
-
maskImage: string
|
|
6
|
+
maskImage: string | ((cell: number) => string)
|
|
7
7
|
maskSize?: string
|
|
8
8
|
maskRepeat?: string
|
|
9
9
|
cell: number
|
|
@@ -14,30 +14,53 @@ interface MaskSpec {
|
|
|
14
14
|
|
|
15
15
|
const CELL = 'var(--pattern-cell) var(--pattern-cell)'
|
|
16
16
|
|
|
17
|
+
const GRID_DOT_RADIUS = 1
|
|
18
|
+
const GRID_GAP = 3
|
|
19
|
+
const RING_RADIUS = 4.5
|
|
20
|
+
const RING_STROKE = 2
|
|
21
|
+
|
|
17
22
|
function svgMask(body: string, width = 12, height = width) {
|
|
18
23
|
const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'>${body}</svg>`
|
|
19
24
|
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`
|
|
20
25
|
}
|
|
21
26
|
|
|
27
|
+
function corners(cell: number): [number, number][] {
|
|
28
|
+
return [
|
|
29
|
+
[0, 0],
|
|
30
|
+
[cell, 0],
|
|
31
|
+
[0, cell],
|
|
32
|
+
[cell, cell],
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function gridMask(cell: number) {
|
|
37
|
+
const start = 0.5 + GRID_DOT_RADIUS + GRID_GAP
|
|
38
|
+
const end = cell + 0.5 - GRID_DOT_RADIUS - GRID_GAP
|
|
39
|
+
const lines = end > start ? `<path d='M${start} .5H${end}M.5 ${start}V${end}' stroke='#000'/>` : ''
|
|
40
|
+
const dots = corners(cell)
|
|
41
|
+
.map(([x, y]) => `<circle cx='${x + 0.5}' cy='${y + 0.5}' r='${GRID_DOT_RADIUS}'/>`)
|
|
42
|
+
.join('')
|
|
43
|
+
return svgMask(lines + dots, cell)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ringsMask(cell: number) {
|
|
47
|
+
const centers: [number, number][] = [...corners(cell), [cell / 2, cell / 2]]
|
|
48
|
+
const rings = centers.map(([x, y]) => `<circle cx='${x}' cy='${y}' r='${RING_RADIUS}'/>`).join('')
|
|
49
|
+
return svgMask(`<g fill='none' stroke='#000' stroke-width='${RING_STROKE}'>${rings}</g>`, cell)
|
|
50
|
+
}
|
|
51
|
+
|
|
22
52
|
const PATTERN_MASKS: Record<BackgroundPatternVariant, MaskSpec> = {
|
|
23
53
|
dots: {
|
|
24
54
|
maskImage: 'radial-gradient(circle at 1px 1px, #000 1px, transparent 1.5px)',
|
|
25
55
|
cell: 14,
|
|
26
|
-
tint: 'bg-current/
|
|
27
|
-
spotlight: 'bg-current/
|
|
56
|
+
tint: 'bg-current/14',
|
|
57
|
+
spotlight: 'bg-current/62 dark:bg-current/68',
|
|
28
58
|
},
|
|
29
59
|
grid: {
|
|
30
|
-
maskImage:
|
|
31
|
-
'linear-gradient(to right, #000 0 1px, transparent 1px), linear-gradient(to bottom, #000 0 1px, transparent 1px)',
|
|
32
|
-
cell: 28,
|
|
33
|
-
tint: 'bg-current/7',
|
|
34
|
-
spotlight: 'bg-current/28 dark:bg-current/34',
|
|
35
|
-
},
|
|
36
|
-
'dashed-grid': {
|
|
37
|
-
maskImage: svgMask(`<path d='M0 0H12 M0 0V12' stroke='#000' stroke-width='1' stroke-dasharray='2 2'/>`),
|
|
60
|
+
maskImage: gridMask,
|
|
38
61
|
cell: 28,
|
|
39
|
-
tint: 'bg-current/
|
|
40
|
-
spotlight: 'bg-current/
|
|
62
|
+
tint: 'bg-current/9',
|
|
63
|
+
spotlight: 'bg-current/32 dark:bg-current/38',
|
|
41
64
|
},
|
|
42
65
|
hexagons: {
|
|
43
66
|
maskImage: svgMask(
|
|
@@ -47,8 +70,21 @@ const PATTERN_MASKS: Record<BackgroundPatternVariant, MaskSpec> = {
|
|
|
47
70
|
),
|
|
48
71
|
maskSize: 'var(--pattern-cell) calc(var(--pattern-cell) * 1.7320508)',
|
|
49
72
|
cell: 40,
|
|
50
|
-
tint: 'bg-current/
|
|
51
|
-
spotlight: 'bg-current/
|
|
73
|
+
tint: 'bg-current/9',
|
|
74
|
+
spotlight: 'bg-current/32 dark:bg-current/38',
|
|
75
|
+
},
|
|
76
|
+
rings: {
|
|
77
|
+
maskImage: ringsMask,
|
|
78
|
+
cell: 48,
|
|
79
|
+
tint: 'bg-current/9',
|
|
80
|
+
spotlight: 'bg-current/32 dark:bg-current/38',
|
|
81
|
+
},
|
|
82
|
+
checkerboard: {
|
|
83
|
+
maskImage: 'repeating-conic-gradient(#000 0% 25%, transparent 0% 50%)',
|
|
84
|
+
maskSize: 'calc(var(--pattern-cell) * 2) calc(var(--pattern-cell) * 2)',
|
|
85
|
+
cell: 16,
|
|
86
|
+
tint: 'bg-current/5',
|
|
87
|
+
spotlight: 'bg-current/12 dark:bg-current/14',
|
|
52
88
|
},
|
|
53
89
|
}
|
|
54
90
|
|
|
@@ -66,12 +102,13 @@ function patternSpotlight(variant: BackgroundPatternVariant) {
|
|
|
66
102
|
|
|
67
103
|
interface PatternLayerProps {
|
|
68
104
|
variant: BackgroundPatternVariant
|
|
105
|
+
cell: number
|
|
69
106
|
className?: string
|
|
70
107
|
}
|
|
71
108
|
|
|
72
|
-
function PatternLayer({ variant, className }: PatternLayerProps) {
|
|
109
|
+
function PatternLayer({ variant, cell, className }: PatternLayerProps) {
|
|
73
110
|
const spec = PATTERN_MASKS[variant]
|
|
74
|
-
const maskImage = spec.maskImage
|
|
111
|
+
const maskImage = typeof spec.maskImage === 'function' ? spec.maskImage(cell) : spec.maskImage
|
|
75
112
|
const maskSize = spec.maskSize ?? CELL
|
|
76
113
|
const maskRepeat = spec.maskRepeat ?? 'repeat'
|
|
77
114
|
|
|
@@ -80,6 +80,41 @@ describe('BackgroundPattern', () => {
|
|
|
80
80
|
expect(root).not.toHaveClass('bg-background-subtle')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
+
it.each([
|
|
84
|
+
['dots', 14],
|
|
85
|
+
['grid', 28],
|
|
86
|
+
['hexagons', 40],
|
|
87
|
+
['rings', 48],
|
|
88
|
+
['checkerboard', 16],
|
|
89
|
+
] as const)('paints one masked %s layer at its default cell size', (variant, cell) => {
|
|
90
|
+
const { container } = render(<BackgroundPattern variant={variant} />)
|
|
91
|
+
const root = container.querySelector('[data-slot="background-pattern"]') as HTMLElement
|
|
92
|
+
const layers = container.querySelectorAll<HTMLElement>('[data-slot="background-pattern-layer"]')
|
|
93
|
+
expect(root.style.getPropertyValue('--pattern-cell')).toBe(`${cell}px`)
|
|
94
|
+
expect(layers).toHaveLength(1)
|
|
95
|
+
expect(layers[0]!.style.getPropertyValue('mask-image')).not.toBe('')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('draws the grid and rings tiles at the resolved cell size', () => {
|
|
99
|
+
const tile = (variant: 'grid' | 'rings', cellSize?: number) => {
|
|
100
|
+
const { container, unmount } = render(<BackgroundPattern variant={variant} cellSize={cellSize} />)
|
|
101
|
+
const mask = container
|
|
102
|
+
.querySelector<HTMLElement>('[data-slot="background-pattern-layer"]')!
|
|
103
|
+
.style.getPropertyValue('mask-image')
|
|
104
|
+
unmount()
|
|
105
|
+
return decodeURIComponent(mask)
|
|
106
|
+
}
|
|
107
|
+
expect(tile('grid')).toContain("width='28' height='28'")
|
|
108
|
+
expect(tile('grid', 40)).toContain("width='40' height='40'")
|
|
109
|
+
expect(tile('rings', 32)).toContain("width='32' height='32'")
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('tiles the checkerboard two cells wide so cellSize sets one square', () => {
|
|
113
|
+
const { container } = render(<BackgroundPattern variant="checkerboard" />)
|
|
114
|
+
const layer = container.querySelector<HTMLElement>('[data-slot="background-pattern-layer"]')!
|
|
115
|
+
expect(layer.style.getPropertyValue('mask-size')).toContain('calc(var(--pattern-cell) * 2)')
|
|
116
|
+
})
|
|
117
|
+
|
|
83
118
|
it('forwards cellSize as a CSS variable', () => {
|
|
84
119
|
const { container } = render(<BackgroundPattern cellSize={20} />)
|
|
85
120
|
const root = container.querySelector('[data-slot="background-pattern"]') as HTMLElement
|
|
@@ -17,7 +17,7 @@ interface BackgroundPatternProps extends React.ComponentProps<'div'> {
|
|
|
17
17
|
* @default false
|
|
18
18
|
*/
|
|
19
19
|
spotlight?: boolean | number | string | SpotlightConfig
|
|
20
|
-
/** Cell size in px; overrides the per-variant default (dots 14, grid
|
|
20
|
+
/** Cell size in px; overrides the per-variant default (dots 14, grid 28, hexagons 40, rings 48; checkerboard 16, per square). */
|
|
21
21
|
cellSize?: number
|
|
22
22
|
/**
|
|
23
23
|
* Where the spotlight reads pointer movement. `'self'` tracks over this element; `'window'` tracks anywhere - for a
|
|
@@ -47,8 +47,9 @@ function BackgroundPattern({
|
|
|
47
47
|
...props
|
|
48
48
|
}: BackgroundPatternProps) {
|
|
49
49
|
const spot = resolveSpotlight(spotlight)
|
|
50
|
+
const cell = cellSize ?? patternCell(variant)
|
|
50
51
|
const cssVars = {
|
|
51
|
-
'--pattern-cell': `${
|
|
52
|
+
'--pattern-cell': `${cell}px`,
|
|
52
53
|
...(spot?.size != null && {
|
|
53
54
|
'--spotlight-size': typeof spot.size === 'number' ? `${spot.size}px` : spot.size,
|
|
54
55
|
}),
|
|
@@ -64,8 +65,14 @@ function BackgroundPattern({
|
|
|
64
65
|
style={{ ...cssVars, ...style }}
|
|
65
66
|
{...props}
|
|
66
67
|
>
|
|
67
|
-
<PatternLayer
|
|
68
|
-
|
|
68
|
+
<PatternLayer
|
|
69
|
+
variant={variant}
|
|
70
|
+
cell={cell}
|
|
71
|
+
className={cn('-z-10 text-(--pattern-color)', patternTint(variant))}
|
|
72
|
+
/>
|
|
73
|
+
{spot ? (
|
|
74
|
+
<BackgroundPatternInteractive variant={variant} cell={cell} persistent={spot.persistent} track={track} />
|
|
75
|
+
) : null}
|
|
69
76
|
{children}
|
|
70
77
|
</div>
|
|
71
78
|
)
|
|
@@ -29,7 +29,7 @@ type CardFrame = 'none' | 'solid' | 'glass'
|
|
|
29
29
|
|
|
30
30
|
const frameVariants: Record<CardFrame, string> = {
|
|
31
31
|
none: 'rounded-(--card-radius)',
|
|
32
|
-
solid: cn(FRAME_RADIUS, 'bg-background-
|
|
32
|
+
solid: cn(FRAME_RADIUS, 'bg-background-muted/60 p-2 backdrop-blur-xl dark:bg-background-subtle'),
|
|
33
33
|
glass: cn(FRAME_RADIUS, 'border border-white/15 bg-white/10 p-2 backdrop-blur-sm'),
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -547,6 +547,30 @@ describe('useCarousel + lifecycle', () => {
|
|
|
547
547
|
expect(subscribed).toEqual(expect.arrayContaining(['reinit', 'select', 'scroll', 'slidesinview', 'slideschanged']))
|
|
548
548
|
})
|
|
549
549
|
|
|
550
|
+
it('pauses autoplay on an on-axis wheel when wheel gestures are on', () => {
|
|
551
|
+
const viewport = document.createElement('div')
|
|
552
|
+
const autoplay = {
|
|
553
|
+
options: { delay: 4000 },
|
|
554
|
+
isPlaying: vi.fn(() => true),
|
|
555
|
+
play: vi.fn(),
|
|
556
|
+
stop: vi.fn(),
|
|
557
|
+
reset: vi.fn(),
|
|
558
|
+
}
|
|
559
|
+
stubApi.plugins.mockReturnValue({ wheelGestures: {}, autoplay })
|
|
560
|
+
stubApi.rootNode.mockReturnValue(viewport)
|
|
561
|
+
stubApi.internalEngine.mockReturnValue({ options: { axis: 'x' } })
|
|
562
|
+
try {
|
|
563
|
+
render(<Basic autoplay wheelGestures />)
|
|
564
|
+
viewport.dispatchEvent(new WheelEvent('wheel', { deltaX: 2, deltaY: 40 }))
|
|
565
|
+
expect(autoplay.stop).not.toHaveBeenCalled()
|
|
566
|
+
viewport.dispatchEvent(new WheelEvent('wheel', { deltaX: 40, deltaY: 2 }))
|
|
567
|
+
expect(autoplay.stop).toHaveBeenCalledTimes(1)
|
|
568
|
+
} finally {
|
|
569
|
+
stubApi.rootNode.mockReset()
|
|
570
|
+
stubApi.internalEngine.mockReset()
|
|
571
|
+
}
|
|
572
|
+
})
|
|
573
|
+
|
|
550
574
|
it('does not re-run the sync effect when re-rendered with a new-but-equal autoplay object', () => {
|
|
551
575
|
const { rerender } = render(<Basic autoplay={{ delay: 3000 }} />)
|
|
552
576
|
const initialOnCalls = stubApi.on.mock.calls.length
|
|
@@ -93,8 +93,8 @@ interface CarouselProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'onS
|
|
|
93
93
|
* @default 'trimSnaps'
|
|
94
94
|
*/
|
|
95
95
|
containScroll?: false | 'trimSnaps' | 'keepSnaps'
|
|
96
|
-
/** Release snap points
|
|
97
|
-
dragFree?: boolean
|
|
96
|
+
/** Release snap points and glide to a momentum stop. `'snap'` glides, then settles on the nearest snap point. */
|
|
97
|
+
dragFree?: boolean | 'snap'
|
|
98
98
|
/** Index of the slide to start on. */
|
|
99
99
|
startSnap?: number
|
|
100
100
|
/**
|
|
@@ -103,7 +103,7 @@ interface CarouselProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'onS
|
|
|
103
103
|
*/
|
|
104
104
|
active?: boolean
|
|
105
105
|
/**
|
|
106
|
-
* Whether pointer dragging is enabled
|
|
106
|
+
* Whether pointer dragging is enabled.
|
|
107
107
|
* @default true
|
|
108
108
|
*/
|
|
109
109
|
draggable?: boolean
|
|
@@ -294,8 +294,10 @@ function Carousel({
|
|
|
294
294
|
emblaApi.internalEngine().scrollBody.useDuration(0)
|
|
295
295
|
}
|
|
296
296
|
emblaApi.on('pointerup', snapToTargetInstantly)
|
|
297
|
+
emblaApi.on('scroll', snapToTargetInstantly)
|
|
297
298
|
return () => {
|
|
298
299
|
emblaApi.off('pointerup', snapToTargetInstantly)
|
|
300
|
+
emblaApi.off('scroll', snapToTargetInstantly)
|
|
299
301
|
}
|
|
300
302
|
}, [emblaApi, reducedMotion])
|
|
301
303
|
|
|
@@ -451,6 +453,26 @@ function Carousel({
|
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
|
|
456
|
+
let cleanupWheel: (() => void) | undefined
|
|
457
|
+
if (emblaApi.plugins().wheelGestures && (autoplayPlugin || autoScrollPlugin)) {
|
|
458
|
+
const viewport = emblaApi.rootNode()
|
|
459
|
+
const vertical = emblaApi.internalEngine().options.axis === 'y'
|
|
460
|
+
const onWheel = (event: WheelEvent) => {
|
|
461
|
+
const along = Math.abs(vertical ? event.deltaY : event.deltaX)
|
|
462
|
+
const across = Math.abs(vertical ? event.deltaX : event.deltaY)
|
|
463
|
+
if (along <= across) return
|
|
464
|
+
if (autoplayPlugin?.isPlaying()) {
|
|
465
|
+
autoplayPlugin.stop()
|
|
466
|
+
scheduleResume(() => emblaApi.plugins().autoplay?.play())
|
|
467
|
+
} else if (autoScrollPlugin?.isPlaying()) {
|
|
468
|
+
autoScrollPlugin.stop()
|
|
469
|
+
scheduleResume(() => emblaApi.plugins().autoScroll?.play())
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
viewport.addEventListener('wheel', onWheel, { passive: true })
|
|
473
|
+
cleanupWheel = () => viewport.removeEventListener('wheel', onWheel)
|
|
474
|
+
}
|
|
475
|
+
|
|
454
476
|
return () => {
|
|
455
477
|
emblaApi.off('reinit', handleReInit)
|
|
456
478
|
emblaApi.off('select', handleSelect)
|
|
@@ -459,6 +481,7 @@ function Carousel({
|
|
|
459
481
|
emblaApi.off('slideschanged', syncFull)
|
|
460
482
|
cleanupAutoplay?.()
|
|
461
483
|
cleanupAutoScroll?.()
|
|
484
|
+
cleanupWheel?.()
|
|
462
485
|
clearResumeTimer()
|
|
463
486
|
}
|
|
464
487
|
}, [emblaApi, autoplayEnabled, autoScrollEnabled, resumeAfterMs])
|
|
@@ -86,6 +86,34 @@ describe('ContextMenu', () => {
|
|
|
86
86
|
expect(item.className).toContain('text-base')
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
+
it('marks every item kind with data-orientation="vertical"', async () => {
|
|
90
|
+
const user = setupUser()
|
|
91
|
+
render(
|
|
92
|
+
<ContextMenu>
|
|
93
|
+
<ContextMenuTrigger data-testid="trigger">Right click here</ContextMenuTrigger>
|
|
94
|
+
<ContextMenuContent>
|
|
95
|
+
<ContextMenuItem>Item</ContextMenuItem>
|
|
96
|
+
<ContextMenuLinkItem href="https://example.com">Link</ContextMenuLinkItem>
|
|
97
|
+
<ContextMenuCheckboxItem>Check</ContextMenuCheckboxItem>
|
|
98
|
+
<ContextMenuRadioGroup value="a">
|
|
99
|
+
<ContextMenuRadioItem value="a">Radio</ContextMenuRadioItem>
|
|
100
|
+
</ContextMenuRadioGroup>
|
|
101
|
+
<ContextMenuSub>
|
|
102
|
+
<ContextMenuSubTrigger>More</ContextMenuSubTrigger>
|
|
103
|
+
<ContextMenuSubContent>
|
|
104
|
+
<ContextMenuItem>Nested</ContextMenuItem>
|
|
105
|
+
</ContextMenuSubContent>
|
|
106
|
+
</ContextMenuSub>
|
|
107
|
+
</ContextMenuContent>
|
|
108
|
+
</ContextMenu>,
|
|
109
|
+
)
|
|
110
|
+
await user.pointer({ keys: '[MouseRight]', target: screen.getByTestId('trigger') })
|
|
111
|
+
await screen.findByRole('menuitem', { name: 'Item' })
|
|
112
|
+
const items = document.querySelectorAll('[data-slot$="-item"], [data-slot="context-menu-sub-trigger"]')
|
|
113
|
+
expect(items).toHaveLength(5)
|
|
114
|
+
items.forEach((item) => expect(item).toHaveAttribute('data-orientation', 'vertical'))
|
|
115
|
+
})
|
|
116
|
+
|
|
89
117
|
it('renders the popup with size-driven radius', async () => {
|
|
90
118
|
const user = setupUser()
|
|
91
119
|
render(<BasicMenu size="sm" />)
|
|
@@ -119,6 +119,7 @@ function ContextMenuItem({ className, ...props }: ContextMenuItemProps) {
|
|
|
119
119
|
return (
|
|
120
120
|
<BaseContextMenu.Item
|
|
121
121
|
data-slot="context-menu-item"
|
|
122
|
+
data-orientation="vertical"
|
|
122
123
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
123
124
|
{...props}
|
|
124
125
|
/>
|
|
@@ -132,6 +133,7 @@ function ContextMenuLinkItem({ className, ...props }: ContextMenuLinkItemProps)
|
|
|
132
133
|
return (
|
|
133
134
|
<BaseContextMenu.LinkItem
|
|
134
135
|
data-slot="context-menu-link-item"
|
|
136
|
+
data-orientation="vertical"
|
|
135
137
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
136
138
|
{...props}
|
|
137
139
|
/>
|
|
@@ -188,6 +190,7 @@ function ContextMenuRadioItem({ className, children, ...props }: ContextMenuRadi
|
|
|
188
190
|
return (
|
|
189
191
|
<BaseContextMenu.RadioItem
|
|
190
192
|
data-slot="context-menu-radio-item"
|
|
193
|
+
data-orientation="vertical"
|
|
191
194
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
192
195
|
{...props}
|
|
193
196
|
>
|
|
@@ -210,6 +213,7 @@ function ContextMenuCheckboxItem({ className, children, ...props }: ContextMenuC
|
|
|
210
213
|
return (
|
|
211
214
|
<BaseContextMenu.CheckboxItem
|
|
212
215
|
data-slot="context-menu-checkbox-item"
|
|
216
|
+
data-orientation="vertical"
|
|
213
217
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
214
218
|
{...props}
|
|
215
219
|
>
|
|
@@ -239,6 +243,7 @@ function ContextMenuSubTrigger({ className, children, ...props }: ContextMenuSub
|
|
|
239
243
|
<BaseContextMenu.SubmenuTrigger className="group/submenu-trigger outline-hidden" {...props}>
|
|
240
244
|
<span
|
|
241
245
|
data-slot="context-menu-sub-trigger"
|
|
246
|
+
data-orientation="vertical"
|
|
242
247
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
243
248
|
>
|
|
244
249
|
<span className={cn('flex flex-1 items-center', ITEM_TEXT[size])}>{children}</span>
|
|
@@ -39,6 +39,19 @@ describe('CopyButton', () => {
|
|
|
39
39
|
expect(screen.getAllByText('Copied').length).toBeGreaterThanOrEqual(1)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
it('renders a custom resting icon in place of the copy glyph and still swaps to the check', async () => {
|
|
43
|
+
const { user } = setup()
|
|
44
|
+
render(<CopyButton value="hello" icon={<svg data-testid="link-icon" />} />)
|
|
45
|
+
const button = screen.getByRole('button', { name: 'Copy' })
|
|
46
|
+
expect(screen.getByTestId('link-icon')).toBeInTheDocument()
|
|
47
|
+
expect(button.querySelectorAll('svg')).toHaveLength(2)
|
|
48
|
+
|
|
49
|
+
await user.click(button)
|
|
50
|
+
|
|
51
|
+
await waitFor(() => expect(button).toHaveAttribute('data-copied'))
|
|
52
|
+
expect(screen.getByTestId('link-icon')).toBeInTheDocument()
|
|
53
|
+
})
|
|
54
|
+
|
|
42
55
|
it('copies the string value on click', async () => {
|
|
43
56
|
const { user, writeText } = setup()
|
|
44
57
|
const onCopy = vi.fn()
|
|
@@ -69,6 +69,8 @@ interface CopyButtonProps extends Omit<ButtonProps, 'value' | 'onCopy'> {
|
|
|
69
69
|
onCopy?: (value: string) => void
|
|
70
70
|
/** Called if reading the value or writing to the clipboard fails. */
|
|
71
71
|
onCopyError?: (error: unknown) => void
|
|
72
|
+
/** Icon shown at rest, cross-faded to the drawn check after a copy. Defaults to a built-in copy glyph. */
|
|
73
|
+
icon?: React.ReactNode
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
function CopyButton({
|
|
@@ -78,6 +80,7 @@ function CopyButton({
|
|
|
78
80
|
copiedLabel = 'Copied',
|
|
79
81
|
onCopy,
|
|
80
82
|
onCopyError,
|
|
83
|
+
icon,
|
|
81
84
|
onClick,
|
|
82
85
|
variant = 'ghost',
|
|
83
86
|
size = 'icon-sm',
|
|
@@ -120,16 +123,19 @@ function CopyButton({
|
|
|
120
123
|
{...props}
|
|
121
124
|
>
|
|
122
125
|
<span data-icon={children != null ? 'start' : undefined} className="grid place-items-center *:[grid-area:1/1]">
|
|
123
|
-
<
|
|
124
|
-
{...ICON_SVG_PROPS}
|
|
126
|
+
<span
|
|
125
127
|
className={cn(
|
|
126
|
-
'transition-[opacity,scale] delay-150 duration-150 ease-out group-data-copied/copy:delay-0',
|
|
128
|
+
'grid place-items-center transition-[opacity,scale] delay-150 duration-150 ease-out group-data-copied/copy:delay-0',
|
|
127
129
|
'group-data-copied/copy:scale-50 group-data-copied/copy:opacity-0',
|
|
128
130
|
'motion-reduce:transition-none',
|
|
129
131
|
)}
|
|
130
132
|
>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
{icon ?? (
|
|
134
|
+
<svg {...ICON_SVG_PROPS}>
|
|
135
|
+
<path d="M4.012 16.737c-.307-.175-.562-.427-.739-.732S3.001 15.353 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1M7 9.667c0-.707.281-1.386.781-1.886S8.96 7 9.667 7h8.666c.35 0 .697.069 1.021.203s.618.33.865.578.444.542.578.865A2.67 2.67 0 0 1 21 9.667v8.666a2.67 2.67 0 0 1-.781 1.886 2.67 2.67 0 0 1-1.886.781H9.667a2.67 2.67 0 0 1-1.021-.203c-.324-.134-.618-.331-.865-.578s-.444-.542-.578-.865S7 18.683 7 18.333V9.667z" />
|
|
136
|
+
</svg>
|
|
137
|
+
)}
|
|
138
|
+
</span>
|
|
133
139
|
<svg {...ICON_SVG_PROPS}>
|
|
134
140
|
<path
|
|
135
141
|
d={CHECK_PATH}
|
|
@@ -86,6 +86,34 @@ describe('DropdownMenu', () => {
|
|
|
86
86
|
expect(item.className).toContain('text-base')
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
+
it('marks every item kind with data-orientation="vertical"', async () => {
|
|
90
|
+
const user = setupUser()
|
|
91
|
+
render(
|
|
92
|
+
<DropdownMenu>
|
|
93
|
+
<DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
94
|
+
<DropdownMenuContent>
|
|
95
|
+
<DropdownMenuItem>Item</DropdownMenuItem>
|
|
96
|
+
<DropdownMenuLinkItem href="https://example.com">Link</DropdownMenuLinkItem>
|
|
97
|
+
<DropdownMenuCheckboxItem>Check</DropdownMenuCheckboxItem>
|
|
98
|
+
<DropdownMenuRadioGroup value="a">
|
|
99
|
+
<DropdownMenuRadioItem value="a">Radio</DropdownMenuRadioItem>
|
|
100
|
+
</DropdownMenuRadioGroup>
|
|
101
|
+
<DropdownMenuSub>
|
|
102
|
+
<DropdownMenuSubTrigger>More</DropdownMenuSubTrigger>
|
|
103
|
+
<DropdownMenuSubContent>
|
|
104
|
+
<DropdownMenuItem>Nested</DropdownMenuItem>
|
|
105
|
+
</DropdownMenuSubContent>
|
|
106
|
+
</DropdownMenuSub>
|
|
107
|
+
</DropdownMenuContent>
|
|
108
|
+
</DropdownMenu>,
|
|
109
|
+
)
|
|
110
|
+
await user.click(screen.getByRole('button', { name: 'Open' }))
|
|
111
|
+
await screen.findByRole('menuitem', { name: 'Item' })
|
|
112
|
+
const items = document.querySelectorAll('[data-slot$="-item"], [data-slot="dropdown-menu-sub-trigger"]')
|
|
113
|
+
expect(items).toHaveLength(5)
|
|
114
|
+
items.forEach((item) => expect(item).toHaveAttribute('data-orientation', 'vertical'))
|
|
115
|
+
})
|
|
116
|
+
|
|
89
117
|
it('renders the popup with size-driven radius', async () => {
|
|
90
118
|
const user = setupUser()
|
|
91
119
|
render(<BasicMenu size="sm" />)
|