@senvenli/react 0.3.2 → 0.3.4

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 (97) hide show
  1. package/dist/action/fab.d.ts +7 -0
  2. package/dist/action/fab.js +22 -3
  3. package/dist/action/fab.js.map +1 -1
  4. package/dist/collection/data-table.d.ts +1 -1
  5. package/dist/collection/data-table.js +2 -2
  6. package/dist/collection/data-table.js.map +1 -1
  7. package/dist/collection/table.d.ts +7 -2
  8. package/dist/collection/table.js +17 -7
  9. package/dist/collection/table.js.map +1 -1
  10. package/dist/i18n.d.ts +8 -0
  11. package/dist/i18n.js +18 -1
  12. package/dist/i18n.js.map +1 -1
  13. package/dist/navigation/index.d.ts +2 -2
  14. package/dist/navigation/index.js +1 -1
  15. package/dist/navigation/index.js.map +1 -1
  16. package/dist/navigation/sidebar.d.ts +18 -0
  17. package/dist/navigation/sidebar.js +26 -2
  18. package/dist/navigation/sidebar.js.map +1 -1
  19. package/dist/overlay/floating.js +4 -1
  20. package/dist/overlay/floating.js.map +1 -1
  21. package/dist/overlay/index.d.ts +2 -0
  22. package/dist/overlay/index.js +2 -1
  23. package/dist/overlay/index.js.map +1 -1
  24. package/dist/overlay/tour.d.ts +88 -0
  25. package/dist/overlay/tour.js +302 -0
  26. package/dist/overlay/tour.js.map +1 -0
  27. package/manifests/data-table.json +1 -1
  28. package/manifests/index.json +2 -1
  29. package/manifests/sidebar.json +55 -2
  30. package/manifests/table.json +2 -2
  31. package/package.json +2 -2
  32. package/dist/action/files.d.ts +0 -70
  33. package/dist/action/files.js +0 -156
  34. package/dist/action/files.js.map +0 -1
  35. package/dist/action/theme-toggle.d.ts +0 -43
  36. package/dist/action/theme-toggle.js +0 -259
  37. package/dist/action/theme-toggle.js.map +0 -1
  38. package/dist/display/image-crop.d.ts +0 -106
  39. package/dist/display/image-crop.js +0 -117
  40. package/dist/display/image-crop.js.map +0 -1
  41. package/dist/display/image-cropper.d.ts +0 -68
  42. package/dist/display/image-cropper.js +0 -284
  43. package/dist/display/image-cropper.js.map +0 -1
  44. package/dist/display/lozenge.d.ts +0 -30
  45. package/dist/display/lozenge.js +0 -55
  46. package/dist/display/lozenge.js.map +0 -1
  47. package/dist/display/scroll-area.d.ts +0 -29
  48. package/dist/display/scroll-area.js +0 -95
  49. package/dist/display/scroll-area.js.map +0 -1
  50. package/dist/feedback/cooldown.d.ts +0 -17
  51. package/dist/feedback/cooldown.js +0 -59
  52. package/dist/feedback/cooldown.js.map +0 -1
  53. package/dist/feedback/status-dot.d.ts +0 -23
  54. package/dist/feedback/status-dot.js +0 -37
  55. package/dist/feedback/status-dot.js.map +0 -1
  56. package/dist/form/input-otp.d.ts +0 -35
  57. package/dist/form/input-otp.js +0 -83
  58. package/dist/form/input-otp.js.map +0 -1
  59. package/dist/layout/auth-form-layout.d.ts +0 -71
  60. package/dist/layout/auth-form-layout.js +0 -61
  61. package/dist/layout/auth-form-layout.js.map +0 -1
  62. package/dist/layout/auth-layout.d.ts +0 -59
  63. package/dist/layout/auth-layout.js +0 -26
  64. package/dist/layout/auth-layout.js.map +0 -1
  65. package/dist/layout/pressable.d.ts +0 -40
  66. package/dist/layout/pressable.js +0 -65
  67. package/dist/layout/pressable.js.map +0 -1
  68. package/dist/layout/reset-sent-card.d.ts +0 -39
  69. package/dist/layout/reset-sent-card.js +0 -22
  70. package/dist/layout/reset-sent-card.js.map +0 -1
  71. package/dist/navigation/dock.d.ts +0 -27
  72. package/dist/navigation/dock.js +0 -47
  73. package/dist/navigation/dock.js.map +0 -1
  74. package/dist/navigation/footer.d.ts +0 -43
  75. package/dist/navigation/footer.js +0 -43
  76. package/dist/navigation/footer.js.map +0 -1
  77. package/dist/navigation/language-names.d.ts +0 -19
  78. package/dist/navigation/language-names.js +0 -79
  79. package/dist/navigation/language-names.js.map +0 -1
  80. package/dist/navigation/language-switcher.d.ts +0 -55
  81. package/dist/navigation/language-switcher.js +0 -53
  82. package/dist/navigation/language-switcher.js.map +0 -1
  83. package/dist/navigation/panel-header.d.ts +0 -37
  84. package/dist/navigation/panel-header.js +0 -50
  85. package/dist/navigation/panel-header.js.map +0 -1
  86. package/dist/navigation/toolbar.d.ts +0 -37
  87. package/dist/navigation/toolbar.js +0 -334
  88. package/dist/navigation/toolbar.js.map +0 -1
  89. package/dist/overlay/command-palette.d.ts +0 -53
  90. package/dist/overlay/command-palette.js +0 -130
  91. package/dist/overlay/command-palette.js.map +0 -1
  92. package/dist/overlay/overlay.d.ts +0 -299
  93. package/dist/overlay/overlay.js +0 -558
  94. package/dist/overlay/overlay.js.map +0 -1
  95. package/dist/selection/radio-card.d.ts +0 -31
  96. package/dist/selection/radio-card.js +0 -29
  97. package/dist/selection/radio-card.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme-toggle.js","sourceRoot":"","sources":["../../src/action/theme-toggle.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,IAAI,IAAI,QAAQ,EAChB,QAAQ,IAAI,YAAY,EACxB,WAAW,EACX,OAAO,IAAI,WAAW,EACtB,YAAY,IAAI,gBAAgB,EAChC,iBAAiB,IAAI,qBAAqB,EAC1C,OAAO,IAAI,WAAW,EACtB,cAAc,EACd,SAAS,GAEV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAMvE,MAAM,OAAO,GAA0C;IACrD,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KA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ACoB,GAClB,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Button as AriaButton,\n Menu as AriaMenu,\n MenuItem as AriaMenuItem,\n MenuTrigger,\n Popover as AriaPopover,\n ToggleButton as AriaToggleButton,\n ToggleButtonGroup as AriaToggleButtonGroup,\n Tooltip as AriaTooltip,\n TooltipTrigger,\n useLocale,\n type Key,\n} from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { IconGlyph, type IconName } from \"../display/icon\";\nimport { contentLang, themeLabels } from \"../i18n\";\nimport { DARK_QUERY, DEFAULT_THEME_STORAGE_KEY } from \"./theme-script\";\n\nexport type ThemeChoice = \"system\" | \"light\" | \"dark\";\nexport type ResolvedTheme = \"light\" | \"dark\";\nexport type ThemeLabels = ReturnType<typeof themeLabels>;\n\nconst CHOICES: { id: ThemeChoice; icon: IconName }[] = [\n { id: \"system\", icon: \"monitor\" },\n { id: \"light\", icon: \"sun\" },\n { id: \"dark\", icon: \"moon\" },\n];\n\nfunction readStored(key: string): ThemeChoice {\n try {\n const value = window.localStorage.getItem(key);\n return value === \"light\" || value === \"dark\" ? value : \"system\";\n } catch {\n // Storage blocked (privacy mode, sandboxed frame): the choice lasts the session only.\n return \"system\";\n }\n}\n\n/** Writes the choice; false when storage is unusable (the in-memory choice is then the only copy). */\nfunction writeStored(key: string, choice: ThemeChoice): boolean {\n try {\n if (choice === \"system\") window.localStorage.removeItem(key);\n else window.localStorage.setItem(key, choice);\n return true;\n } catch {\n // As above: without storage the control still works for this page.\n return false;\n }\n}\n\n/**\n * One choice per storage key for the whole page: every toggle and hook reading the key sees the same\n * value (the Navbar segments and the phone-menu list stay in step), and other tabs reach it through\n * the storage event.\n */\ntype ChoiceStore = {\n value: ThemeChoice | undefined;\n listeners: Set<() => void>;\n onStorage?: (event: StorageEvent) => void;\n /** This key's last write could not reach storage, so its in-memory choice is the only copy. */\n writeFailed?: boolean;\n};\nconst stores = new Map<string, ChoiceStore>();\n\n/** Test isolation only (not exported from the package): forget every page-wide choice and write failure. */\nexport function resetThemeStoresForTests() {\n for (const store of stores.values()) if (store.onStorage) window.removeEventListener(\"storage\", store.onStorage);\n stores.clear();\n}\nfunction storeFor(key: string): ChoiceStore {\n let store = stores.get(key);\n if (!store) {\n store = { value: undefined, listeners: new Set() };\n stores.set(key, store);\n }\n return store;\n}\nfunction notify(store: ChoiceStore) {\n for (const listener of store.listeners) listener();\n}\nfunction getChoice(key: string): ThemeChoice {\n const store = storeFor(key);\n if (store.value === undefined) store.value = readStored(key);\n return store.value;\n}\nfunction setStoredChoice(key: string, next: ThemeChoice) {\n const store = storeFor(key);\n store.writeFailed = !writeStored(key, next);\n store.value = next;\n notify(store);\n}\nfunction subscribeChoice(key: string, listener: () => void) {\n const store = storeFor(key);\n store.listeners.add(listener);\n if (!store.onStorage) {\n store.onStorage = (event: StorageEvent) => {\n // A key cleared everywhere (event.key === null) or this key changed in another tab.\n if (event.key !== key && event.key !== null) return;\n store.value = readStored(key);\n notify(store);\n };\n window.addEventListener(\"storage\", store.onStorage);\n }\n return () => {\n store.listeners.delete(listener);\n if (store.listeners.size === 0 && store.onStorage) {\n window.removeEventListener(\"storage\", store.onStorage);\n store.onStorage = undefined;\n // Read fresh next time something mounts, unless storage is unusable: then the in-memory choice\n // is all there is, and it must survive the last toggle unmounting (a phone drawer closing).\n if (!store.writeFailed) store.value = undefined;\n }\n };\n}\n\nfunction systemIsDark() {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" && window.matchMedia(DARK_QUERY).matches;\n}\nfunction subscribeSystem(listener: () => void) {\n if (typeof window.matchMedia !== \"function\") return () => {};\n const media = window.matchMedia(DARK_QUERY);\n if (typeof media.addEventListener === \"function\") {\n media.addEventListener(\"change\", listener);\n return () => media.removeEventListener(\"change\", listener);\n }\n // Safari 13 and older only have the deprecated listener API.\n media.addListener?.(listener);\n return () => media.removeListener?.(listener);\n}\n\n/** Freezes transitions for one frame while the theme swaps; a constructable sheet, so a strict CSP style-src allows it. */\nlet freezeSheet: CSSStyleSheet | undefined;\nfunction freezeTransitions() {\n if (typeof CSSStyleSheet === \"undefined\" || !(\"adoptedStyleSheets\" in document)) return () => {};\n try {\n if (!freezeSheet) {\n freezeSheet = new CSSStyleSheet();\n freezeSheet.replaceSync(\"*,*::before,*::after{transition:none!important}\");\n }\n const sheet = freezeSheet;\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n return () => {\n document.adoptedStyleSheets = document.adoptedStyleSheets.filter((item) => item !== sheet);\n };\n } catch {\n return () => {};\n }\n}\n\n/** Sets data-theme on <html>, recolouring at once: no page transition runs on the swap. */\nfunction applyTheme(theme: ResolvedTheme) {\n const root = document.documentElement;\n if (root.getAttribute(\"data-theme\") === theme) return;\n const thaw = freezeTransitions();\n root.setAttribute(\"data-theme\", theme);\n // Flush the styles with transitions off, then let them run again.\n void window.getComputedStyle(root).color;\n window.requestAnimationFrame(thaw);\n}\n\n/**\n * The visitor's theme: `system` (the default, following prefers-color-scheme live) or a stored\n * `light` / `dark`. One value per storage key across the page, followed across tabs; applies\n * data-theme on <html>. Renders `system` on the server and during hydration, then the stored value;\n * the theme is applied only once the real value is known, so nothing writes a wrong theme on mount.\n */\nexport function useThemePreference(\n storageKey: string = DEFAULT_THEME_STORAGE_KEY,\n /** `false` when someone else owns the theme (a controlled ThemeToggle): no storage, no data-theme. */\n { manage = true }: { manage?: boolean } = {},\n) {\n const choice = React.useSyncExternalStore<ThemeChoice>(\n React.useCallback((listener) => (manage ? subscribeChoice(storageKey, listener) : () => {}), [storageKey, manage]),\n () => (manage ? getChoice(storageKey) : \"system\"),\n () => \"system\",\n );\n const prefersDark = React.useSyncExternalStore(subscribeSystem, systemIsDark, () => false);\n const [mounted, setMounted] = React.useState(false);\n React.useLayoutEffect(() => setMounted(true), []);\n\n const resolved: ResolvedTheme = choice === \"system\" ? (prefersDark ? \"dark\" : \"light\") : choice;\n React.useEffect(() => {\n if (manage && mounted) applyTheme(resolved);\n }, [resolved, manage, mounted]);\n\n const setChoice = React.useCallback(\n (next: ThemeChoice) => {\n if (manage) setStoredChoice(storageKey, next);\n },\n [storageKey, manage],\n );\n return { choice, setChoice, resolved, systemTheme: (prefersDark ? \"dark\" : \"light\") as ResolvedTheme };\n}\n\nexport type ThemeToggleProps = {\n /** Controlled choice; leave out to let the toggle manage, store and apply it. */\n value?: ThemeChoice;\n onChange?: (choice: ThemeChoice) => void;\n /** Localized names; the locale's built-in strings by default. */\n labels?: Partial<ThemeLabels>;\n storageKey?: string;\n /**\n * `segmented`: three icon buttons. `menu`: one icon button (the theme in effect) that opens System / Light / Dark,\n * the compact form for a busy header. `list`: a three-option list with a check, for the phone menu.\n */\n appearance?: \"segmented\" | \"menu\" | \"list\";\n};\n\nconst SEGMENT =\n \"grid size-7 cursor-pointer place-items-center rounded-ds-small text-ds-icon-subtle outline-hidden \" +\n \"data-[hovered]:text-ds-icon data-[selected]:bg-ds-background-segment-selected data-[selected]:text-ds-icon data-[selected]:shadow-ds-raised \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\";\n\nconst ROW =\n \"flex h-ds-control w-full cursor-pointer items-center gap-ds-150 rounded-ds-small px-ds-150 text-start text-body text-ds-text outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\";\n\n/**\n * System, Light or Dark for a public site, as a radio group: Tab enters and leaves once, arrow keys\n * move and select. System is the default and follows the device; a choice is kept in localStorage.\n * One per page, in the Navbar's end area (`segmented` or `menu`); `appearance=\"list\"` in the phone menu. Put\n * `themeScript(nonce)` in <head> so the first paint already has the theme.\n */\nexport function ThemeToggle({ value, onChange, labels: given, storageKey, appearance = \"segmented\" }: ThemeToggleProps) {\n const { locale, direction } = useLocale();\n const labelId = `${React.useId()}-label`;\n const labels = { ...themeLabels(locale), ...given };\n // Controlled, the parent owns the theme (and usually calls useThemePreference itself).\n const preference = useThemePreference(storageKey, { manage: value === undefined });\n const choice = value ?? preference.choice;\n const choose = (next: ThemeChoice) => {\n if (value === undefined) preference.setChoice(next);\n onChange?.(next);\n };\n const name = (id: ThemeChoice) => labels[id];\n const onSelectionChange = (keys: Set<Key>) => {\n const [next] = Array.from(keys) as ThemeChoice[];\n if (next) choose(next);\n };\n\n // A radio group: Tab enters at the checked option and leaves (the others are out of the tab order).\n // React Aria's group moves focus with the arrow keys in the reading direction; a radio reached that\n // way is selected. Focus from anywhere else (a screen reader's cursor, focus coming back to the page,\n // a click) never changes the theme by itself.\n const arrowed = React.useRef(false);\n const buttons = React.useRef(new Map<ThemeChoice, HTMLElement>());\n const register = (id: ThemeChoice) => (element: HTMLElement | null) => {\n if (element) buttons.current.set(id, element);\n else buttons.current.delete(id);\n };\n // The radio pattern, handled here for both orientations: Right/Down move forward and Left/Up back\n // (Left forward in RTL), wrapping at the ends; Home and End jump. React Aria's own toolbar keys only\n // follow the group's orientation and stop at the ends, so they never see these keys.\n const onKeyDownCapture = (event: React.KeyboardEvent) => {\n const forward = [\"ArrowDown\", direction === \"rtl\" ? \"ArrowLeft\" : \"ArrowRight\"];\n const backward = [\"ArrowUp\", direction === \"rtl\" ? \"ArrowRight\" : \"ArrowLeft\"];\n const at = CHOICES.findIndex(({ id }) => buttons.current.get(id) === document.activeElement);\n const last = CHOICES.length - 1;\n let target: number | undefined;\n if (event.key === \"Home\") target = 0;\n else if (event.key === \"End\") target = last;\n else if (forward.includes(event.key)) target = at === last ? 0 : at + 1;\n else if (backward.includes(event.key)) target = at <= 0 ? last : at - 1;\n if (target === undefined) return;\n event.preventDefault();\n event.stopPropagation();\n arrowed.current = true;\n buttons.current.get(CHOICES[target].id)?.focus();\n arrowed.current = false;\n };\n const selectOnFocus = (id: ThemeChoice) => () => {\n if (!arrowed.current) return;\n arrowed.current = false;\n if (id !== choice) choose(id);\n };\n\n if (appearance === \"menu\") {\n // The menu is React Aria's, styled as the library's Menu (overlay/floating.tsx), which this file cannot import\n // without a cycle (overlay imports the action family).\n const shown = choice === \"system\" ? (preference.systemTheme === \"dark\" ? \"moon\" : \"sun\") : CHOICES.find(({ id }) => id === choice)!.icon;\n return (\n <MenuTrigger>\n <AriaButton\n aria-label={`${labels.theme}: ${name(choice)}`}\n data-slot=\"theme-toggle\"\n data-appearance=\"menu\"\n className={\n \"grid size-8 cursor-pointer place-items-center rounded-ds-medium text-ds-icon-subtle outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-icon data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\"\n }\n >\n <IconGlyph name={shown} />\n </AriaButton>\n <AriaPopover\n placement=\"bottom end\"\n offset={4}\n data-slot=\"theme-toggle-popover\"\n className={\n \"min-w-40 rounded-ds-xlarge bg-ds-surface-overlay p-ds-050 text-ds-text shadow-ds-overlay outline-hidden \" +\n \"transition-opacity duration-(--ds-duration-medium) data-[entering]:opacity-0 data-[exiting]:opacity-0 motion-reduce:transition-none\"\n }\n >\n <AriaMenu\n aria-label={labels.theme}\n selectionMode=\"single\"\n disallowEmptySelection\n selectedKeys={[choice]}\n onSelectionChange={(keys) => keys !== \"all\" && onSelectionChange(keys as Set<Key>)}\n className=\"flex flex-col outline-hidden\"\n >\n {CHOICES.map(({ id, icon }) => (\n <AriaMenuItem\n key={id}\n id={id}\n textValue={name(id)}\n data-slot=\"theme-toggle-option\"\n className={\n \"flex min-h-8 cursor-default items-center gap-ds-100 rounded-ds-small px-ds-100 text-body outline-hidden select-none \" +\n \"data-[focused]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed\"\n }\n >\n {({ isSelected }) => (\n <>\n <IconGlyph name={icon} color=\"subtle\" />\n <span className=\"flex-1\">{name(id)}</span>\n {isSelected && <IconGlyph name=\"check\" data-slot=\"theme-toggle-check\" />}\n </>\n )}\n </AriaMenuItem>\n ))}\n </AriaMenu>\n </AriaPopover>\n </MenuTrigger>\n );\n }\n\n if (appearance === \"list\") {\n return (\n <div data-slot=\"theme-toggle\" data-appearance=\"list\" className=\"flex flex-col gap-ds-050\">\n <span id={labelId} lang={contentLang(locale)} data-slot=\"theme-toggle-label\" className=\"px-ds-150 text-heading-xxsmall text-ds-text-subtle uppercase\">\n {labels.theme}\n </span>\n <div className=\"contents\" onKeyDownCapture={onKeyDownCapture}>\n <AriaToggleButtonGroup\n aria-labelledby={labelId}\n selectionMode=\"single\"\n disallowEmptySelection\n orientation=\"vertical\"\n selectedKeys={[choice]}\n onSelectionChange={onSelectionChange}\n className=\"flex flex-col\"\n >\n {CHOICES.map(({ id, icon }) => (\n <AriaToggleButton key={id} id={id} ref={register(id)} excludeFromTabOrder={id !== choice} onFocus={selectOnFocus(id)} data-slot=\"theme-toggle-option\" className={ROW}>\n <IconGlyph name={icon} color=\"subtle\" />\n <span className=\"flex-1\">{name(id)}</span>\n {choice === id && <IconGlyph name=\"check\" data-slot=\"theme-toggle-check\" />}\n </AriaToggleButton>\n ))}\n </AriaToggleButtonGroup>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"contents\" onKeyDownCapture={onKeyDownCapture}>\n <AriaToggleButtonGroup\n aria-label={labels.theme}\n selectionMode=\"single\"\n disallowEmptySelection\n selectedKeys={[choice]}\n onSelectionChange={onSelectionChange}\n data-slot=\"theme-toggle\"\n data-appearance=\"segmented\"\n className=\"inline-flex gap-0.5 rounded-ds-medium bg-ds-background-neutral p-0.5\"\n >\n {CHOICES.map(({ id, icon }) => {\n // System says what is in effect right now (\"Theme: System · now dark\").\n const tip =\n id === \"system\"\n ? `${labels.theme}: ${labels.system} · ${preference.systemTheme === \"dark\" ? labels.nowDark : labels.nowLight}`\n : `${labels.theme}: ${name(id)}`;\n return (\n <TooltipTrigger key={id} delay={300} closeDelay={0}>\n <AriaToggleButton\n id={id}\n ref={register(id)}\n excludeFromTabOrder={id !== choice}\n onFocus={selectOnFocus(id)}\n // The group already says \"Tema\"; the tooltip keeps \"Tema: …\" for sighted users.\n aria-label={name(id)}\n data-slot=\"theme-toggle-option\"\n className={SEGMENT}\n >\n <IconGlyph name={icon} />\n </AriaToggleButton>\n {/* React Aria's Tooltip styled per the Tooltip README; swap to the DS Tooltip when F2 exports it. */}\n <AriaTooltip\n offset={6}\n data-slot=\"theme-toggle-tooltip\"\n className=\"max-w-[240px] rounded-ds-small bg-ds-background-neutral-bold px-ds-100 py-ds-050 text-body-small text-ds-text-inverse\"\n >\n {tip}\n </AriaTooltip>\n </TooltipTrigger>\n );\n })}\n </AriaToggleButtonGroup>\n </div>\n );\n}\n"]}
@@ -1,106 +0,0 @@
1
- /**
2
- * ImageCropper's geometry and output, kept apart from the component so the rules the
3
- * cropper exists for are tested on their own:
4
- * - never upscale: the output is the crop region in source pixels, only ever scaled down;
5
- * - contain never paints black: an output without alpha (JPEG) fills the empty area with the
6
- * background, white by default; PNG and WebP keep it transparent.
7
- *
8
- * Coordinates are in the source's pixels after rotation ("rotated space"): a 90° turn of a 4000 × 3000
9
- * photo is a 3000 × 4000 image to crop.
10
- */
11
- export type CropFit = "cover" | "contain";
12
- export type CropOutputType = "image/jpeg" | "image/png" | "image/webp";
13
- export type CropRotation = 0 | 90 | 180 | 270;
14
- export type CropState = {
15
- /** 1 shows the whole fit; up to 4. */
16
- zoom: number;
17
- /** The crop region's centre, in rotated-space pixels. */
18
- centerX: number;
19
- centerY: number;
20
- rotation: CropRotation;
21
- };
22
- export type CropRegion = {
23
- left: number;
24
- top: number;
25
- width: number;
26
- height: number;
27
- };
28
- export declare const MIN_ZOOM = 1;
29
- export declare const MAX_ZOOM = 4;
30
- /** Outputs that keep transparency; the rest get the background under empty areas. */
31
- export declare const hasAlpha: (type: CropOutputType) => type is "image/png" | "image/webp";
32
- /** The source's size once turned. */
33
- export declare function rotatedSize(width: number, height: number, rotation: CropRotation): {
34
- width: number;
35
- height: number;
36
- };
37
- /**
38
- * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that
39
- * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).
40
- * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is
41
- * smaller than, and stays centred along a side it is larger than (only contain's empty area).
42
- */
43
- export declare function cropRegion(image: {
44
- width: number;
45
- height: number;
46
- }, aspect: number, fit: CropFit, state: Pick<CropState, "zoom" | "centerX" | "centerY">): CropRegion;
47
- export declare const clampZoom: (zoom: number) => number;
48
- /**
49
- * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.
50
- * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).
51
- */
52
- export declare function outputSize(region: CropRegion, { maxOutputSize, minOutputSize }: {
53
- maxOutputSize?: number;
54
- minOutputSize?: number;
55
- }): {
56
- width: number;
57
- height: number;
58
- scale: number;
59
- small: boolean;
60
- };
61
- /** The 2D context calls the renderer makes; a canvas's context, or a recorder in tests. */
62
- export type CropContext = Pick<CanvasRenderingContext2D, "fillStyle" | "fillRect" | "clearRect" | "save" | "restore" | "translate" | "rotate" | "scale" | "drawImage" | "imageSmoothingEnabled" | "imageSmoothingQuality">;
63
- /**
64
- * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty
65
- * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills
66
- * the canvas.
67
- */
68
- export declare function drawCrop(context: CropContext, image: CanvasImageSource, source: {
69
- width: number;
70
- height: number;
71
- }, region: CropRegion, size: {
72
- width: number;
73
- height: number;
74
- }, { rotation, outputType, background }: {
75
- rotation: CropRotation;
76
- outputType: CropOutputType;
77
- background?: string;
78
- }): void;
79
- /** The output file's extension for its type. */
80
- export declare const extensionOf: (type: CropOutputType) => "jpg" | "png" | "webp";
81
- /**
82
- * The qualities to try under a byte limit, as an image upload typically needs for a logo,
83
- * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most
84
- * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.
85
- */
86
- export declare function qualitySteps({ outputType, quality, minimumQuality, maxBytes }: {
87
- outputType: CropOutputType;
88
- quality: number;
89
- minimumQuality?: number;
90
- maxBytes?: number;
91
- }): number[];
92
- export type EncodeResult = {
93
- blob: Blob;
94
- quality: number;
95
- fits: boolean;
96
- };
97
- /**
98
- * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is
99
- * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.
100
- */
101
- export declare function encodeWithin(encode: (quality: number | undefined) => Promise<Blob | null>, options: {
102
- outputType: CropOutputType;
103
- quality: number;
104
- minimumQuality?: number;
105
- maxBytes?: number;
106
- }): Promise<EncodeResult>;
@@ -1,117 +0,0 @@
1
- /**
2
- * ImageCropper's geometry and output, kept apart from the component so the rules the
3
- * cropper exists for are tested on their own:
4
- * - never upscale: the output is the crop region in source pixels, only ever scaled down;
5
- * - contain never paints black: an output without alpha (JPEG) fills the empty area with the
6
- * background, white by default; PNG and WebP keep it transparent.
7
- *
8
- * Coordinates are in the source's pixels after rotation ("rotated space"): a 90° turn of a 4000 × 3000
9
- * photo is a 3000 × 4000 image to crop.
10
- */
11
- export const MIN_ZOOM = 1;
12
- export const MAX_ZOOM = 4;
13
- /** Outputs that keep transparency; the rest get the background under empty areas. */
14
- export const hasAlpha = (type) => type !== "image/jpeg";
15
- /** The source's size once turned. */
16
- export function rotatedSize(width, height, rotation) {
17
- return rotation % 180 === 0 ? { width, height } : { width: height, height: width };
18
- }
19
- /**
20
- * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that
21
- * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).
22
- * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is
23
- * smaller than, and stays centred along a side it is larger than (only contain's empty area).
24
- */
25
- export function cropRegion(image, aspect, fit, state) {
26
- const imageAspect = image.width / image.height;
27
- const widerFrame = aspect > imageAspect;
28
- // cover: limited by the image's short side for this shape; contain: by its long side.
29
- const baseWidth = fit === "cover" ? (widerFrame ? image.width : image.height * aspect) : widerFrame ? image.height * aspect : image.width;
30
- const zoom = clampZoom(state.zoom);
31
- const width = baseWidth / zoom;
32
- const height = width / aspect;
33
- const centerX = clampCenter(state.centerX, width, image.width);
34
- const centerY = clampCenter(state.centerY, height, image.height);
35
- return { left: centerX - width / 2, top: centerY - height / 2, width, height };
36
- }
37
- export const clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Number.isFinite(zoom) ? zoom : MIN_ZOOM));
38
- function clampCenter(center, size, extent) {
39
- if (size >= extent)
40
- return extent / 2;
41
- return Math.min(extent - size / 2, Math.max(size / 2, center));
42
- }
43
- /**
44
- * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.
45
- * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).
46
- */
47
- export function outputSize(region, { maxOutputSize, minOutputSize }) {
48
- const long = Math.max(region.width, region.height);
49
- const scale = maxOutputSize && long > maxOutputSize ? maxOutputSize / long : 1;
50
- const width = Math.max(1, Math.round(region.width * scale));
51
- const height = Math.max(1, Math.round(region.height * scale));
52
- return { width, height, scale, small: Boolean(minOutputSize && Math.max(width, height) < minOutputSize) };
53
- }
54
- /**
55
- * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty
56
- * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills
57
- * the canvas.
58
- */
59
- export function drawCrop(context, image, source, region, size, { rotation, outputType, background = "#ffffff" }) {
60
- context.clearRect(0, 0, size.width, size.height);
61
- if (!hasAlpha(outputType)) {
62
- context.fillStyle = background;
63
- context.fillRect(0, 0, size.width, size.height);
64
- }
65
- const turned = rotatedSize(source.width, source.height, rotation);
66
- // Each edge on its own: after rounding, width and height can differ by under a pixel, which would leave
67
- // a faint row of background (or transparency) along the bottom.
68
- context.save();
69
- context.imageSmoothingEnabled = true;
70
- context.imageSmoothingQuality = "high";
71
- context.scale(size.width / region.width, size.height / region.height);
72
- context.translate(-region.left, -region.top);
73
- // Into rotated space: turn about the turned image's centre, then draw the source centred on it.
74
- context.translate(turned.width / 2, turned.height / 2);
75
- context.rotate((rotation * Math.PI) / 180);
76
- context.drawImage(image, -source.width / 2, -source.height / 2, source.width, source.height);
77
- context.restore();
78
- }
79
- /** The output file's extension for its type. */
80
- export const extensionOf = (type) => (type === "image/jpeg" ? "jpg" : type === "image/png" ? "png" : "webp");
81
- /**
82
- * The qualities to try under a byte limit, as an image upload typically needs for a logo,
83
- * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most
84
- * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.
85
- */
86
- export function qualitySteps({ outputType, quality, minimumQuality, maxBytes }) {
87
- if (!maxBytes || outputType === "image/png")
88
- return [quality];
89
- const floor = Math.min(quality, Math.max(0.1, minimumQuality ?? 0.1));
90
- const steps = [];
91
- for (let index = 0;; index++) {
92
- const step = Math.round(Math.max(floor, quality - index * 0.1) * 100) / 100;
93
- if (steps[steps.length - 1] !== step)
94
- steps.push(step);
95
- if (step <= floor)
96
- break;
97
- }
98
- return steps;
99
- }
100
- /**
101
- * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is
102
- * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.
103
- */
104
- export async function encodeWithin(encode, options) {
105
- let last;
106
- for (const quality of qualitySteps(options)) {
107
- // PNG is lossless: the browser ignores a quality for it, so none is passed.
108
- const blob = await encode(options.outputType === "image/png" ? undefined : quality);
109
- if (!blob)
110
- throw new Error("export-failed");
111
- last = { blob, quality };
112
- if (!options.maxBytes || blob.size <= options.maxBytes)
113
- return { ...last, fits: true };
114
- }
115
- return { ...last, fits: false };
116
- }
117
- //# sourceMappingURL=image-crop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-crop.js","sourceRoot":"","sources":["../../src/display/image-crop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,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AG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC5E,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,IAAI,IAAI,KAAK;YAAE,MAAM;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAID;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA6D,EAC7D,OAAoG;IAEpG,IAAI,IAAiD,CAAC;IACtD,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5C,4EAA4E;QAC5E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5C,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,QAAQ;YAAE,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzF,CAAC;IACD,OAAO,EAAE,GAAG,IAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * ImageCropper's geometry and output, kept apart from the component so the rules the\n * cropper exists for are tested on their own:\n * - never upscale: the output is the crop region in source pixels, only ever scaled down;\n * - contain never paints black: an output without alpha (JPEG) fills the empty area with the\n * background, white by default; PNG and WebP keep it transparent.\n *\n * Coordinates are in the source's pixels after rotation (\"rotated space\"): a 90° turn of a 4000 × 3000\n * photo is a 3000 × 4000 image to crop.\n */\n\nexport type CropFit = \"cover\" | \"contain\";\nexport type CropOutputType = \"image/jpeg\" | \"image/png\" | \"image/webp\";\nexport type CropRotation = 0 | 90 | 180 | 270;\n\nexport type CropState = {\n /** 1 shows the whole fit; up to 4. */\n zoom: number;\n /** The crop region's centre, in rotated-space pixels. */\n centerX: number;\n centerY: number;\n rotation: CropRotation;\n};\n\nexport type CropRegion = { left: number; top: number; width: number; height: number };\n\nexport const MIN_ZOOM = 1;\nexport const MAX_ZOOM = 4;\n\n/** Outputs that keep transparency; the rest get the background under empty areas. */\nexport const hasAlpha = (type: CropOutputType) => type !== \"image/jpeg\";\n\n/** The source's size once turned. */\nexport function rotatedSize(width: number, height: number, rotation: CropRotation) {\n return rotation % 180 === 0 ? { width, height } : { width: height, height: width };\n}\n\n/**\n * The crop region for a frame aspect (width / height): at zoom 1, `cover` is the largest region of that\n * shape inside the image and `contain` the smallest that holds the whole image (the rest is empty area).\n * Zoom shrinks the region; the centre is kept so the region never leaves the image along a side it is\n * smaller than, and stays centred along a side it is larger than (only contain's empty area).\n */\nexport function cropRegion(image: { width: number; height: number }, aspect: number, fit: CropFit, state: Pick<CropState, \"zoom\" | \"centerX\" | \"centerY\">): CropRegion {\n const imageAspect = image.width / image.height;\n const widerFrame = aspect > imageAspect;\n // cover: limited by the image's short side for this shape; contain: by its long side.\n const baseWidth = fit === \"cover\" ? (widerFrame ? image.width : image.height * aspect) : widerFrame ? image.height * aspect : image.width;\n const zoom = clampZoom(state.zoom);\n const width = baseWidth / zoom;\n const height = width / aspect;\n const centerX = clampCenter(state.centerX, width, image.width);\n const centerY = clampCenter(state.centerY, height, image.height);\n return { left: centerX - width / 2, top: centerY - height / 2, width, height };\n}\n\nexport const clampZoom = (zoom: number) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, Number.isFinite(zoom) ? zoom : MIN_ZOOM));\n\nfunction clampCenter(center: number, size: number, extent: number) {\n if (size >= extent) return extent / 2;\n return Math.min(extent - size / 2, Math.max(size / 2, center));\n}\n\n/**\n * The output size: the region in source pixels, scaled down to `maxOutputSize` on the long edge, never up.\n * `small` is true when the long edge is under `minOutputSize` (the warning; it never blocks).\n */\nexport function outputSize(region: CropRegion, { maxOutputSize, minOutputSize }: { maxOutputSize?: number; minOutputSize?: number }) {\n const long = Math.max(region.width, region.height);\n const scale = maxOutputSize && long > maxOutputSize ? maxOutputSize / long : 1;\n const width = Math.max(1, Math.round(region.width * scale));\n const height = Math.max(1, Math.round(region.height * scale));\n return { width, height, scale, small: Boolean(minOutputSize && Math.max(width, height) < minOutputSize) };\n}\n\n/** The 2D context calls the renderer makes; a canvas's context, or a recorder in tests. */\nexport type CropContext = Pick<\n CanvasRenderingContext2D,\n \"fillStyle\" | \"fillRect\" | \"clearRect\" | \"save\" | \"restore\" | \"translate\" | \"rotate\" | \"scale\" | \"drawImage\" | \"imageSmoothingEnabled\" | \"imageSmoothingQuality\"\n>;\n\n/**\n * Draws the crop on a context sized `size`: the background first when the output has no alpha (so empty\n * contain areas and transparent pixels never turn black), then the turned image mapped so the region fills\n * the canvas.\n */\nexport function drawCrop(\n context: CropContext,\n image: CanvasImageSource,\n source: { width: number; height: number },\n region: CropRegion,\n size: { width: number; height: number },\n { rotation, outputType, background = \"#ffffff\" }: { rotation: CropRotation; outputType: CropOutputType; background?: string },\n) {\n context.clearRect(0, 0, size.width, size.height);\n if (!hasAlpha(outputType)) {\n context.fillStyle = background;\n context.fillRect(0, 0, size.width, size.height);\n }\n const turned = rotatedSize(source.width, source.height, rotation);\n // Each edge on its own: after rounding, width and height can differ by under a pixel, which would leave\n // a faint row of background (or transparency) along the bottom.\n context.save();\n context.imageSmoothingEnabled = true;\n context.imageSmoothingQuality = \"high\";\n context.scale(size.width / region.width, size.height / region.height);\n context.translate(-region.left, -region.top);\n // Into rotated space: turn about the turned image's centre, then draw the source centred on it.\n context.translate(turned.width / 2, turned.height / 2);\n context.rotate((rotation * Math.PI) / 180);\n context.drawImage(image, -source.width / 2, -source.height / 2, source.width, source.height);\n context.restore();\n}\n\n/** The output file's extension for its type. */\nexport const extensionOf = (type: CropOutputType) => (type === \"image/jpeg\" ? \"jpg\" : type === \"image/png\" ? \"png\" : \"webp\");\n\n/**\n * The qualities to try under a byte limit, as an image upload typically needs for a logo,\n * hero and slide uploads: from `quality` down in steps of 0.1, never under `minimumQuality` (0.1 by default, at most\n * `quality`), rounded to hundredths. Without a limit, or for PNG (lossless: its quality does nothing), one try.\n */\nexport function qualitySteps({ outputType, quality, minimumQuality, maxBytes }: { outputType: CropOutputType; quality: number; minimumQuality?: number; maxBytes?: number }) {\n if (!maxBytes || outputType === \"image/png\") return [quality];\n const floor = Math.min(quality, Math.max(0.1, minimumQuality ?? 0.1));\n const steps: number[] = [];\n for (let index = 0; ; index++) {\n const step = Math.round(Math.max(floor, quality - index * 0.1) * 100) / 100;\n if (steps[steps.length - 1] !== step) steps.push(step);\n if (step <= floor) break;\n }\n return steps;\n}\n\nexport type EncodeResult = { blob: Blob; quality: number; fits: boolean };\n\n/**\n * Encodes at each of `qualitySteps` until the file is at most `maxBytes`, and says whether it got there. `encode` is\n * the canvas's toBlob (a stub in tests); a null from it is a failed export and throws.\n */\nexport async function encodeWithin(\n encode: (quality: number | undefined) => Promise<Blob | null>,\n options: { outputType: CropOutputType; quality: number; minimumQuality?: number; maxBytes?: number },\n): Promise<EncodeResult> {\n let last: { blob: Blob; quality: number } | undefined;\n for (const quality of qualitySteps(options)) {\n // PNG is lossless: the browser ignores a quality for it, so none is passed.\n const blob = await encode(options.outputType === \"image/png\" ? undefined : quality);\n if (!blob) throw new Error(\"export-failed\");\n last = { blob, quality };\n if (!options.maxBytes || blob.size <= options.maxBytes) return { ...last, fits: true };\n }\n return { ...last!, fits: false };\n}\n"]}
@@ -1,68 +0,0 @@
1
- import * as React from "react";
2
- import { type CropFit, type CropOutputType } from "./image-crop.js";
3
- export type ImageCropperAspect = number | "free";
4
- export type ImageCropperPreset = {
5
- id: string;
6
- /** "Cover 16:9". */
7
- label: string;
8
- aspectRatio: ImageCropperAspect;
9
- /** The fit this surface uses; the cropper's `fit` otherwise. */
10
- fit?: CropFit;
11
- };
12
- export type ImageCropperResult = {
13
- width: number;
14
- height: number;
15
- type: CropOutputType;
16
- };
17
- export type ImageCropperProps = {
18
- /**
19
- * The picked file (from FileTrigger, already checked for size and type), or an image URL. A URL from
20
- * another origin is loaded with CORS so the crop can be read back: its server must send
21
- * `Access-Control-Allow-Origin`, or the image does not open (rather than failing later at save).
22
- */
23
- src: Blob | string;
24
- /** What is being cropped ("Cover photo"); names the crop frame. */
25
- label: string;
26
- /** 16:9 by default; `"free"` keeps the image's own shape. Ignored when presets are given. */
27
- aspectRatio?: ImageCropperAspect;
28
- /** Two or more shapes to choose from (a segmented control); the first is selected. */
29
- aspectPresets?: readonly ImageCropperPreset[];
30
- /** `cover` (default) fills the frame; `contain` fits the whole image and leaves empty area. */
31
- fit?: CropFit;
32
- /** The empty area's colour in `contain` when the output has no alpha (JPEG). White by default. */
33
- background?: string;
34
- /** `image/jpeg` by default. PNG and WebP keep transparency. */
35
- outputType?: CropOutputType;
36
- /** 0–1, for JPEG and WebP. 0.9 by default. */
37
- quality?: number;
38
- /**
39
- * The largest file the surface takes, in bytes. A JPEG or WebP
40
- * over it is encoded again at a quality 0.1 lower each time, down to `minimumQuality`; when even that is over, or
41
- * a PNG is, nothing is handed to `onCrop` and the cropper says the image is over the limit (a smaller crop, by
42
- * zooming in, or another image fits).
43
- */
44
- maxBytes?: number;
45
- /** The lowest quality `maxBytes` may step down to (0.9 keeps a hero or slide sharp). 0.1 by default; at most `quality`. */
46
- minimumQuality?: number;
47
- /**
48
- * The output's long edge in px at most (a surface's size, 2560 for a full-width photo): larger crops scale down,
49
- * never up. 4096 by default, so a 48 MP phone photo stays within every browser's canvas limit.
50
- */
51
- maxOutputSize?: number;
52
- /** Under this long edge the warning shows; it never blocks. */
53
- minOutputSize?: number;
54
- /** The output file's name without extension; the source file's name by default. */
55
- fileName?: string;
56
- onCrop: (file: File, result: ImageCropperResult) => unknown;
57
- onCancel?: () => void;
58
- };
59
- /**
60
- * Frames one picked image to the shape a surface needs (a 16:9 cover photo, a square logo) and hands
61
- * back the cropped file at the source's own pixel density: never upscaled, only scaled down to
62
- * `maxOutputSize`. In `contain`, the empty area takes `background` when the output has no
63
- * alpha, white by default, never black. A sunken stage dims what falls outside a white frame
64
- * with thirds guides; the toolbar holds the shapes, zoom, rotation and fit. The frame is one focusable
65
- * group: arrows move the image (Shift for 10%), + and − zoom, [ and ] rotate, and each change is announced.
66
- * The toolbar mirrors in RTL; the image and the arrows never do.
67
- */
68
- export declare function ImageCropper({ src, label, aspectRatio, aspectPresets, fit: fitProp, background: backgroundProp, outputType, quality, maxBytes, minimumQuality, maxOutputSize, minOutputSize, fileName, onCrop, onCancel, }: ImageCropperProps): React.JSX.Element;