@react-md/core 1.0.0-next.1 → 1.0.0-next.2
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +8 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/DefaultToastRenderer.tsx.html +166 -112
- package/coverage/lcov-report/Snackbar.tsx.html +360 -402
- package/coverage/lcov-report/Toast.tsx.html +868 -0
- package/coverage/lcov-report/ToastManager.tsx.html +1783 -0
- package/coverage/lcov-report/ToastManagerProvider.tsx.html +216 -216
- package/coverage/lcov-report/icon/FontIcon.tsx.html +28 -28
- package/coverage/lcov-report/icon/index.html +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/snackbar/Snackbar.tsx.html +55 -97
- package/coverage/lcov-report/snackbar/Toast.tsx.html +546 -501
- package/coverage/lcov-report/snackbar/ToastManager.tsx.html +269 -269
- package/coverage/lcov-report/snackbar/ToastManagerProvider.tsx.html +23 -23
- package/coverage/lcov-report/snackbar/index.html +59 -14
- package/coverage/lcov-report/snackbar/snackbarStyles.ts.html +12 -87
- package/coverage/lcov-report/snackbar/toastStyles.ts.html +206 -146
- package/coverage/lcov-report/snackbar/useCurrentToastActions.ts.html +226 -0
- package/coverage/lcov-report/snackbarStyles.ts.html +46 -121
- package/coverage/lcov-report/transition/config.ts.html +5 -5
- package/coverage/lcov-report/transition/index.html +1 -1
- package/coverage/lcov-report/typography/Typography.tsx.html +108 -402
- package/coverage/lcov-report/typography/index.html +10 -10
- package/dist/_core.scss +34 -1
- package/dist/_utils.scss +57 -0
- package/dist/app-bar/_app-bar.scss +15 -23
- package/dist/avatar/_avatar.scss +25 -34
- package/dist/badge/_badge.scss +71 -44
- package/dist/box/_box.scss +18 -29
- package/dist/button/_button.scss +50 -62
- package/dist/card/_card.scss +14 -23
- package/dist/chip/_chip.scss +33 -46
- package/dist/dialog/_dialog.scss +95 -93
- package/dist/divider/Divider.d.ts +0 -1
- package/dist/divider/Divider.js.map +1 -1
- package/dist/divider/_divider.scss +33 -43
- package/dist/form/Label.d.ts +5 -5
- package/dist/form/Label.js.map +1 -1
- package/dist/form/TextArea.js +1 -1
- package/dist/form/TextArea.js.map +1 -1
- package/dist/form/TextFieldContainerStyles.d.ts +7 -7
- package/dist/form/TextFieldContainerStyles.js.map +1 -1
- package/dist/form/_form.scss +200 -203
- package/dist/form/textAreaStyles.d.ts +2 -2
- package/dist/form/textAreaStyles.js.map +1 -1
- package/dist/form/types.d.ts +0 -2
- package/dist/form/types.js.map +1 -1
- package/dist/icon/_icon.scss +31 -47
- package/dist/interaction/_interaction.scss +47 -57
- package/dist/layout/_layout.scss +14 -19
- package/dist/link/_link.scss +15 -23
- package/dist/list/_list.scss +53 -63
- package/dist/menu/_menu.scss +16 -27
- package/dist/overlay/_overlay.scss +14 -19
- package/dist/progress/_progress.scss +25 -30
- package/dist/segmented-button/_segmented-button.scss +32 -43
- package/dist/sheet/_sheet.scss +24 -42
- package/dist/snackbar/DefaultToastRenderer.js +1 -1
- package/dist/snackbar/DefaultToastRenderer.js.map +1 -1
- package/dist/snackbar/Snackbar.d.ts +1 -3
- package/dist/snackbar/Snackbar.js +2 -3
- package/dist/snackbar/Snackbar.js.map +1 -1
- package/dist/snackbar/Toast.d.ts +1 -1
- package/dist/snackbar/Toast.js +5 -1
- package/dist/snackbar/Toast.js.map +1 -1
- package/dist/snackbar/ToastManager.d.ts +2 -1
- package/dist/snackbar/ToastManager.js +1 -1
- package/dist/snackbar/ToastManager.js.map +1 -1
- package/dist/snackbar/_snackbar.scss +15 -23
- package/dist/table/_table.scss +55 -70
- package/dist/tabs/_tabs.scss +25 -30
- package/dist/theme/_theme.scss +31 -89
- package/dist/tooltip/_tooltip.scss +16 -25
- package/dist/transition/_transition.scss +38 -37
- package/dist/tree/_tree.scss +102 -109
- package/dist/typography/_typography.scss +17 -22
- package/dist/window-splitter/_window-splitter.scss +19 -45
- package/package.json +1 -1
- package/src/_core.scss +34 -1
- package/src/_utils.scss +57 -0
- package/src/app-bar/_app-bar.scss +15 -23
- package/src/avatar/_avatar.scss +25 -34
- package/src/badge/_badge.scss +71 -44
- package/src/box/_box.scss +18 -29
- package/src/button/_button.scss +50 -62
- package/src/card/_card.scss +14 -23
- package/src/chip/_chip.scss +33 -46
- package/src/dialog/_dialog.scss +95 -93
- package/src/divider/Divider.tsx +0 -1
- package/src/divider/_divider.scss +33 -43
- package/src/form/Label.tsx +5 -5
- package/src/form/TextArea.tsx +1 -1
- package/src/form/TextFieldContainerStyles.ts +7 -7
- package/src/form/_form.scss +200 -203
- package/src/form/textAreaStyles.ts +2 -2
- package/src/form/types.ts +0 -2
- package/src/icon/_icon.scss +31 -47
- package/src/interaction/_interaction.scss +47 -57
- package/src/layout/_layout.scss +14 -19
- package/src/link/_link.scss +15 -23
- package/src/list/_list.scss +53 -63
- package/src/menu/_menu.scss +16 -27
- package/src/overlay/_overlay.scss +14 -19
- package/src/progress/_progress.scss +25 -30
- package/src/segmented-button/_segmented-button.scss +32 -43
- package/src/sheet/_sheet.scss +24 -42
- package/src/snackbar/DefaultToastRenderer.tsx +1 -1
- package/src/snackbar/Snackbar.tsx +17 -25
- package/src/snackbar/Toast.tsx +7 -2
- package/src/snackbar/ToastManager.tsx +3 -2
- package/src/snackbar/__tests__/Snackbar.tsx +12 -11
- package/src/snackbar/__tests__/ToastManagerProvider.tsx +20 -42
- package/src/snackbar/__tests__/__snapshots__/Snackbar.tsx.snap +127 -27
- package/src/snackbar/__tests__/__snapshots__/ToastManagerProvider.tsx.snap +23 -8
- package/src/snackbar/_snackbar.scss +15 -23
- package/src/table/_table.scss +55 -70
- package/src/tabs/_tabs.scss +25 -30
- package/src/theme/_theme.scss +31 -89
- package/src/tooltip/_tooltip.scss +16 -25
- package/src/transition/_transition.scss +38 -37
- package/src/tree/_tree.scss +102 -109
- package/src/typography/_typography.scss +17 -22
- package/src/window-splitter/_window-splitter.scss +19 -45
- package/.turbo/turbo-lint.log +0 -12
- package/.turbo/turbo-test.log +0 -166
- package/.turbo/turbo-typecheck.log +0 -4
- package/dist/divider/VerticalDivider.d.ts +0 -32
- package/dist/divider/useVerticalDividerHeight.d.ts +0 -37
- package/dist/icon/MaterialIconsProvider.d.ts +0 -12
- package/dist/icon/MaterialIconsProvider.js +0 -17
- package/dist/icon/MaterialIconsProvider.js.map +0 -1
- package/dist/icon/MaterialSymbolsProvider.d.ts +0 -145
- package/dist/icon/MaterialSymbolsProvider.js +0 -60
- package/dist/icon/MaterialSymbolsProvider.js.map +0 -1
- package/dist/link/LinkProvider.d.ts +0 -29
- package/dist/menu/menuConfig.d.ts +0 -60
- package/dist/tooltip/useOverflowTooltip.d.ts +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snackbar/ToastManager.tsx"],"sourcesContent":["import { nanoid } from \"nanoid\";\nimport { type ConfigurableToastProps } from \"./Toast.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport const DEFAULT_TOAST_VISIBLE_TIME = 5000;\n\n/**\n * - `\"normal\"` - the toast will be added to the end of the queue\n * - `\"next\"` - the toast will be inserted next-in-line in the queue, waiting\n * for the current visible toast to exit before being shown. If the toast does\n * not support duplicates, the existing toast will be moved instead and merged\n * with the toast.\n * - `\"replace\"` - if there is a currently visible toast, it will start the\n * leave transition and display the newly added toast instead.\n * - `\"immediate\"` - the same behavior as `\"replace\"` except that if there was a\n * currently visible toast, it will be shown once the newly added toast again.\n *\n * @remarks \\@since 6.0.0 Renamed from `MessagePriority` to `ToastPriority`\n */\nexport type ToastPriority = \"normal\" | \"next\" | \"replace\" | \"immediate\";\n\n/**\n * - `\"allow\"` - toasts with the same `toastId` can be added into the queue, but\n * the leave timeout behavior might not work if multiple toasts can be shown\n * at the same time.\n * - `\"restart\"` - (default) toasts that have the same `toastId` as a toast\n * being shown will restart the exit timeout and update the toast with any\n * differences in the toast. If the toast is not currently being shown, a new\n * toast will not be added.\n * - `\"update\"` - toasts that have the same `toastId` will just update the toast\n * with the latest content while maintaining any existing timeouts\n *\n * @remarks \\@since 6.0.0 Renamed from `DuplicateBehavior`\n */\nexport type ToastDuplicateBehavior = \"allow\" | \"restart\" | \"update\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface ToastMeta {\n /**\n * This will be `true` if the exit timeout has been paused either by hovering\n * the toast or the page has become inactive through blur or minimizing.\n */\n paused: boolean;\n\n /**\n * This will be `true` when the toast should be visible and `false` during the\n * exit animation.\n */\n visible: boolean;\n\n /**\n * The current toast's id which can be used with the:\n * - {@link ToastManager.removeToast}\n * - {@link ToastManager.startRemoveTimeout}\n * - {@link ToastManager.pauseRemoveTimeout}\n * - {@link ToastManager.resumeRemoveTimeout}\n */\n toastId: string;\n priority: ToastPriority;\n duplicates: ToastDuplicateBehavior;\n visibleTime: number | null;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface CreateToastOptions extends ConfigurableToastProps {\n /**\n * @defaultValue `nanoid()`\n */\n toastId?: string;\n\n /**\n * @see {@link ToastDuplicateBehavior}\n * @defaultValue `\"restart\"`\n */\n duplicates?: ToastDuplicateBehavior;\n\n /**\n * @see {@link ToastPriority}\n * @defaultValue `\"normal\"`\n */\n priority?: ToastPriority;\n\n /**\n * Set this to `null` to prevent the toast from automatically hiding,\n * otherwise set this to the number of milliseconds to remain visible.\n *\n * @see {@link DEFAULT_TOAST_VISIBLE_TIME}\n * @defaultValue `DEFAULT_TOAST_VISIBLE_TIME`\n */\n visibleTime?: number | null;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface QueuedToast extends ConfigurableToastProps, ToastMeta {}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type ToastQueue = readonly Readonly<QueuedToast>[];\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type ToastCallback = (queue: ToastQueue) => void;\n\n/**\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport interface ToastVisibilityTimers {\n inactive: boolean;\n startTime: number;\n elapsedTime: number;\n exitTimeout?: number;\n}\n\n/**\n * @see {@link ToastManagerProvider}\n *\n * @remarks \\@since 6.0.0\n */\nexport class ToastManager {\n #queue: QueuedToast[];\n #timers: Map<string, ToastVisibilityTimers>;\n #listeners: ToastCallback[];\n\n constructor() {\n this.#queue = [];\n this.#timers = new Map();\n this.#listeners = [];\n\n // All of the class methods must be arrow functions to preserve the correct\n // `this` value. If they aren't arrow functions, I'd have to wrap each call\n // in an arrow function to work.\n //\n // i.e.\n // useSyncExternalStore(\n // (cb) => manager.subscribe(cb),\n // () => manager.getQueue(),\n // () => manager.getQueue(),\n // );\n }\n\n #emit = (): void => {\n // shallow clone to ensure react updates\n this.#queue = [...this.#queue];\n this.#listeners.forEach((callback) => {\n callback(this.#queue);\n });\n };\n\n #getToastIndex = (toastId: string | undefined): number => {\n if (!toastId) {\n return -1;\n }\n\n return this.#queue.findIndex((toast) => toast.toastId === toastId);\n };\n\n #getToast = (toastId: string | undefined): QueuedToast | undefined => {\n return this.#queue[this.#getToastIndex(toastId)];\n };\n\n /**\n * Starts the exit transition for the currently shown toast and adds the next\n * toast into the queue. This requires a manual call to `this.#emit()`\n * afterwards.\n */\n #addToastImmediately = (nextToast: QueuedToast): void => {\n const [current] = this.#queue;\n this.clearTimer(current.toastId);\n this.#queue[0] = {\n ...current,\n visible: false,\n };\n if (nextToast.priority === \"immediate\") {\n this.#queue.splice(1, 0, nextToast, current);\n } else {\n this.#queue.splice(1, 0, nextToast);\n }\n };\n\n /**\n * This calls `this.#emit()` if the toast was updated\n */\n #updateToast = (\n toastIdOrIndex: string | number,\n patch: Partial<QueuedToast>\n ): void => {\n const index =\n typeof toastIdOrIndex === \"number\"\n ? toastIdOrIndex\n : this.#getToastIndex(toastIdOrIndex);\n\n if (index === -1) {\n return;\n }\n\n this.#queue[index] = {\n ...this.#queue[index],\n ...patch,\n };\n this.#emit();\n };\n\n /**\n * This is just used to subscribe to changes in the {@link useToastQueue}.\n *\n * ```tsx\n * useSyncExternalStore(\n * toastManager.subscribe,\n * toastManager.getQueue,\n * toastManager.getQueue,\n * );\n * ```\n *\n * @internal\n */\n subscribe = (callback: ToastCallback): (() => void) => {\n this.#listeners.push(callback);\n\n return () => {\n this.#listeners = this.#listeners.filter((cb) => cb !== callback);\n };\n };\n\n /**\n * @see {@link subscribe}\n * @internal\n */\n getQueue = (): ToastQueue => {\n return this.#queue;\n };\n\n /**\n * Either adds the toast to the queue or updates an existing toast when using\n * an existing `toastId`.\n *\n * @example\n * Adding toasts\n * ```tsx\n * // create a toast when the user is offline that will not disappear\n * addToast({ toastId: \"offline\", visibleTime: null });\n *\n * // add a new toast that displays `\"Toast\"` to the queue\n * addToast({ children: \"Toast!\" });\n *\n * // add an online toast notification. since these three use the same toast\n * // id, the hide timer will be reset each time\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n *\n * // add a server error toast to the queue where the second one will be\n * // ignored\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * addToast({\n * children: \"Hello, world!\",\n * action: \"Goodbye\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * // and a custom click handler\n * addToast({\n * children: \"Hello, world!\",\n * action: {\n * onClick: () => {\n * logout();\n * },\n * children: \"Goodbye\",\n * },\n * });\n *\n * // add a toast to the queue that renders a react component in the content,\n * // a custom action button implementation (using `ToastActionButton`), and a\n * // close button\n * addToast({\n * children: <SomeCustomComponent />,\n * actionButton: <SomeCustomActionButton />,\n * closeButton: true,\n * });\n * ```\n */\n addToast = (toast: CreateToastOptions): void => {\n const {\n toastId = nanoid(),\n visibleTime = DEFAULT_TOAST_VISIBLE_TIME,\n role = visibleTime === null ? \"alert\" : undefined,\n priority = \"normal\",\n duplicates = \"restart\",\n } = toast;\n\n const existingIndex = this.#getToastIndex(toast.toastId);\n if (existingIndex !== -1 && duplicates !== \"allow\") {\n const existingToast = this.#queue[existingIndex];\n\n // reorder/move the existing toast to be the next item in the queue by:\n // - removing the toast from the queue\n // - inserting it into the next position with the updates\n if (priority === \"next\" && existingIndex > 1) {\n this.#queue.splice(existingIndex, 1);\n this.#queue.splice(1, 0, { ...existingToast, ...toast });\n this.#emit();\n return;\n }\n\n // only need to reorder the queue if it is not being shown\n if (\n (priority === \"replace\" || priority === \"immediate\") &&\n existingIndex !== 0\n ) {\n this.#queue.splice(existingIndex, 1);\n this.#addToastImmediately({\n ...existingToast,\n ...toast,\n });\n this.#emit();\n return;\n }\n\n const timers = this.#timers.get(toastId);\n if (existingToast.visible && duplicates === \"restart\" && timers) {\n this.#timers.set(toastId, { ...timers, elapsedTime: 0 });\n this.startRemoveTimeout(toastId);\n }\n\n this.#updateToast(existingIndex, toast);\n return;\n }\n\n const nextToast: QueuedToast = {\n ...toast,\n role,\n paused: false,\n visible: true,\n toastId,\n priority,\n duplicates,\n visibleTime,\n };\n\n const queueSize = this.#queue.length;\n if (priority === \"next\" && queueSize > 1) {\n this.#queue.splice(1, 0, nextToast);\n } else if (\n (priority === \"replace\" || priority === \"immediate\") &&\n queueSize > 0\n ) {\n this.#addToastImmediately(nextToast);\n } else {\n this.#queue.push(nextToast);\n }\n\n this.#emit();\n };\n\n /**\n * Attempts to start the timeout for removing the toast when the `visibleTime`\n * is not null for a toast.\n *\n * @param toastId - The specific toastId to update\n */\n startRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n if (!toast) {\n return;\n }\n\n const { visibleTime } = toast;\n if (visibleTime === null) {\n // Must manually be closed\n return;\n }\n\n const cached = this.#timers.get(toastId);\n const timers = (cached && { ...cached }) || {\n inactive: false,\n startTime: Date.now(),\n elapsedTime: 0,\n };\n window.clearTimeout(timers.exitTimeout);\n\n let duration = visibleTime;\n if (timers.elapsedTime) {\n duration -= timers.elapsedTime;\n }\n\n timers.inactive = false;\n timers.exitTimeout = window.setTimeout(() => {\n this.removeToast(toastId, true);\n }, duration);\n this.#timers.set(toastId, timers);\n };\n\n /**\n * Pauses the remove timeout for a specific toast normally with hover events\n * or the browser becoming inactive.\n *\n * @param toastId - The specific toastId to pause\n */\n pauseRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n const cached = this.#timers.get(toastId);\n if (!toast || !cached || cached.inactive) {\n return;\n }\n\n window.clearTimeout(cached.exitTimeout);\n const timers = { ...cached };\n timers.inactive = true;\n timers.elapsedTime = Date.now() - timers.startTime + timers.elapsedTime;\n this.#timers.set(toastId, timers);\n this.#updateToast(toastId, { paused: true });\n };\n\n /**\n * Resumes the current remove timeout if it was paused by\n * {@link pauseRemoveTimeout}.\n *\n * @param toastId - The specific toastId to resume\n */\n resumeRemoveTimeout = (toastId: string): void => {\n const toastIndex = this.#getToastIndex(toastId);\n const timers = this.#timers.get(toastId);\n if (toastIndex === -1 || !timers?.startTime) {\n return;\n }\n\n this.#updateToast(toastIndex, { paused: false });\n this.startRemoveTimeout(toastId);\n };\n\n /**\n * Removes a toast by id from the queue without any exit animation.\n *\n * @param toastId - The specific {@link QueuedToast.toastId}\n * @param transition - Set this to `true` to remove the toast by the exit\n * transition instead of immediately.\n */\n removeToast = (toastId: string, transition: boolean): void => {\n const toastIndex = this.#getToastIndex(toastId);\n if (toastIndex === -1) {\n return;\n }\n\n if (transition) {\n this.clearTimer(toastId);\n this.#updateToast(toastIndex, { visible: false });\n return;\n }\n\n this.#queue.splice(toastIndex, 1);\n this.#emit();\n };\n\n /**\n * Clears any pending timers for the provided toast id. This should generally\n * be used in the `useEffect` cleanup effect for any custom toast renderer\n * implementations.\n *\n * @example\n * ```tsx\n * const { toastId } = toast;\n * const toastManager = useToastManager();\n *\n * useEffect(() => {\n * return () => {\n * toastManager.clearTimer(toastId):\n * }\n * }, [toastManager, toastId]);\n * ```\n */\n clearTimer = (toastId: string): void => {\n const timer = this.#timers.get(toastId);\n window.clearTimeout(timer?.exitTimeout);\n this.#timers.delete(toastId);\n };\n\n /**\n * Removes first toast from the queue without any exit animation. You most\n * likely want to use {@link removeToast} instead.\n */\n popToast = (): void => {\n this.#queue.pop();\n this.#emit();\n };\n\n /**\n * Removes all toasts from the queue. There will be no exit animation.\n *\n * @param disableEmit - Set this to `true` to disable emitting the empty queue.\n * Mostly used for tests.\n */\n clearToasts = (disableEmit = false): void => {\n this.#queue = [];\n this.#timers.forEach((meta) => {\n window.clearTimeout(meta.exitTimeout);\n });\n this.#timers.clear();\n if (!disableEmit) {\n this.#emit();\n }\n };\n}\n\n/**\n * The default toast manager for react-md apps that will allow toasts to be\n * added without setting up the {@link ToastManagerProvider}.\n *\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport const toastManager = new ToastManager();\n\n/**\n * @see {@link ToastManager.addToast}\n * @remarks \\@since 6.0.0\n */\nexport const addToast: ToastManager[\"addToast\"] = (toast) =>\n toastManager.addToast(toast);\n\n/**\n * @see {@link ToastManager.startRemoveTimeout}\n * @remarks \\@since 6.0.0\n */\nexport const startRemoveToastTimeout: ToastManager[\"startRemoveTimeout\"] = (\n toastId\n) => toastManager.startRemoveTimeout(toastId);\n\n/**\n * @see {@link ToastManager.popToast}\n * @remarks \\@since 6.0.0\n */\nexport const popToast: ToastManager[\"popToast\"] = () => toastManager.popToast();\n\n/**\n * @see {@link ToastManager.removeToast}\n * @remarks \\@since 6.0.0\n */\nexport const removeToast: ToastManager[\"removeToast\"] = (toastId, transition) =>\n toastManager.removeToast(toastId, transition);\n\n/**\n * @see {@link ToastManager.clearToasts}\n * @remarks \\@since 6.0.0\n */\nexport const clearToasts = (): void => toastManager.clearToasts();\n"],"names":["nanoid","DEFAULT_TOAST_VISIBLE_TIME","ToastManager","constructor","queue","listeners","forEach","callback","toastId","findIndex","toast","getToastIndex","nextToast","current","clearTimer","visible","priority","splice","toastIdOrIndex","patch","index","emit","subscribe","push","filter","cb","getQueue","addToast","visibleTime","role","undefined","duplicates","existingIndex","existingToast","addToastImmediately","timers","get","set","elapsedTime","startRemoveTimeout","updateToast","paused","queueSize","length","getToast","cached","inactive","startTime","Date","now","window","clearTimeout","exitTimeout","duration","setTimeout","removeToast","pauseRemoveTimeout","resumeRemoveTimeout","toastIndex","transition","timer","delete","popToast","pop","clearToasts","disableEmit","meta","clear","Map","toastManager","startRemoveToastTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAGhC;;CAEC,GACD,OAAO,MAAMC,6BAA6B,KAAK;IA4H7C,sCACA,uCACA,0CAmBA,qCAQA,8CAQA,yCAIA;;;;GAIC,GACD,oDAcA;;GAEC,GACD;AArEF;;;;CAIC,GACD,OAAO,MAAMC;IAKXC,aAAc;QAJd,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAA,KAAA;;QACA,gCAAA;;mBAAA,KAAA;;QAmBA,gCAAA;;mBAAQ;gBACN,wCAAwC;+CAClCC,QAAQ;gDAAI,IAAI,EAAEA;iBAAM;gBAC9B,yBAAA,IAAI,EAAEC,YAAUC,OAAO,CAAC,CAACC;oBACvBA,kCAAS,IAAI,EAAEH;gBACjB;YACF;;QAEA,gCAAA;;mBAAiB,CAACI;gBAChB,IAAI,CAACA,SAAS;oBACZ,OAAO,CAAC;gBACV;gBAEA,OAAO,yBAAA,IAAI,EAAEJ,QAAMK,SAAS,CAAC,CAACC,QAAUA,MAAMF,OAAO,KAAKA;YAC5D;;QAEA,gCAAA;;mBAAY,CAACA;gBACX,OAAO,yBAAA,IAAI,EAAEJ,OAAK,CAAC,yBAAA,IAAI,EAAEO,qBAAN,IAAI,EAAgBH,SAAS;YAClD;;QAOA,gCAAA;;mBAAuB,CAACI;gBACtB,MAAM,CAACC,QAAQ,4BAAG,IAAI,EAAET;gBACxB,IAAI,CAACU,UAAU,CAACD,QAAQL,OAAO;gBAC/B,yBAAA,IAAI,EAAEJ,OAAK,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,MAAMK,cAAc,IAAYK,aAAaL,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../src/snackbar/ToastManager.tsx"],"sourcesContent":["import { nanoid } from \"nanoid\";\nimport { type ConfigurableToastProps } from \"./Toast.js\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport const DEFAULT_TOAST_VISIBLE_TIME = 5000;\n\n/**\n * - `\"normal\"` - the toast will be added to the end of the queue\n * - `\"next\"` - the toast will be inserted next-in-line in the queue, waiting\n * for the current visible toast to exit before being shown. If the toast does\n * not support duplicates, the existing toast will be moved instead and merged\n * with the toast.\n * - `\"replace\"` - if there is a currently visible toast, it will start the\n * leave transition and display the newly added toast instead.\n * - `\"immediate\"` - the same behavior as `\"replace\"` except that if there was a\n * currently visible toast, the toast will be shown again once the `\"immediate\"`\n * toast is hidden.\n *\n * @remarks \\@since 6.0.0 Renamed from `MessagePriority` to `ToastPriority`\n */\nexport type ToastPriority = \"normal\" | \"next\" | \"replace\" | \"immediate\";\n\n/**\n * - `\"allow\"` - toasts with the same `toastId` can be added into the queue, but\n * the leave timeout behavior might not work if multiple toasts can be shown\n * at the same time.\n * - `\"restart\"` - (default) toasts that have the same `toastId` as a toast\n * being shown will restart the exit timeout and update the toast with any\n * differences in the toast. If the toast is not currently being shown, a new\n * toast will not be added.\n * - `\"update\"` - toasts that have the same `toastId` will just update the toast\n * with the latest content while maintaining any existing timeouts\n *\n * @remarks \\@since 6.0.0 Renamed from `DuplicateBehavior`\n */\nexport type ToastDuplicateBehavior = \"allow\" | \"restart\" | \"update\";\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface ToastMeta {\n /**\n * This will be `true` if the exit timeout has been paused either by hovering\n * the toast or the page has become inactive through blur or minimizing.\n */\n paused: boolean;\n\n /**\n * This will be `true` when the toast should be visible and `false` during the\n * exit animation.\n */\n visible: boolean;\n\n /**\n * The current toast's id which can be used with the:\n * - {@link ToastManager.removeToast}\n * - {@link ToastManager.startRemoveTimeout}\n * - {@link ToastManager.pauseRemoveTimeout}\n * - {@link ToastManager.resumeRemoveTimeout}\n */\n toastId: string;\n priority: ToastPriority;\n duplicates: ToastDuplicateBehavior;\n visibleTime: number | null;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface CreateToastOptions extends ConfigurableToastProps {\n /**\n * @defaultValue `nanoid()`\n */\n toastId?: string;\n\n /**\n * @see {@link ToastDuplicateBehavior}\n * @defaultValue `\"restart\"`\n */\n duplicates?: ToastDuplicateBehavior;\n\n /**\n * @see {@link ToastPriority}\n * @defaultValue `\"normal\"`\n */\n priority?: ToastPriority;\n\n /**\n * Set this to `null` to prevent the toast from automatically hiding,\n * otherwise set this to the number of milliseconds to remain visible.\n *\n * @see {@link DEFAULT_TOAST_VISIBLE_TIME}\n * @defaultValue `DEFAULT_TOAST_VISIBLE_TIME`\n */\n visibleTime?: number | null;\n}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport interface QueuedToast extends ConfigurableToastProps, ToastMeta {}\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type ToastQueue = readonly Readonly<QueuedToast>[];\n\n/**\n * @remarks \\@since 6.0.0\n */\nexport type ToastCallback = (queue: ToastQueue) => void;\n\n/**\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport interface ToastVisibilityTimers {\n inactive: boolean;\n startTime: number;\n elapsedTime: number;\n exitTimeout?: number;\n}\n\n/**\n * @see {@link ToastManagerProvider}\n *\n * @remarks \\@since 6.0.0\n */\nexport class ToastManager {\n #queue: QueuedToast[];\n #timers: Map<string, ToastVisibilityTimers>;\n #listeners: ToastCallback[];\n\n constructor() {\n this.#queue = [];\n this.#timers = new Map();\n this.#listeners = [];\n\n // All of the class methods must be arrow functions to preserve the correct\n // `this` value. If they aren't arrow functions, I'd have to wrap each call\n // in an arrow function to work.\n //\n // i.e.\n // useSyncExternalStore(\n // (cb) => manager.subscribe(cb),\n // () => manager.getQueue(),\n // () => manager.getQueue(),\n // );\n }\n\n #emit = (): void => {\n // shallow clone to ensure react updates\n this.#queue = [...this.#queue];\n this.#listeners.forEach((callback) => {\n callback(this.#queue);\n });\n };\n\n #getToastIndex = (toastId: string | undefined): number => {\n if (!toastId) {\n return -1;\n }\n\n return this.#queue.findIndex((toast) => toast.toastId === toastId);\n };\n\n #getToast = (toastId: string | undefined): QueuedToast | undefined => {\n return this.#queue[this.#getToastIndex(toastId)];\n };\n\n /**\n * Starts the exit transition for the currently shown toast and adds the next\n * toast into the queue. This requires a manual call to `this.#emit()`\n * afterwards.\n */\n #addToastImmediately = (nextToast: QueuedToast): void => {\n const [current] = this.#queue;\n this.clearTimer(current.toastId);\n this.#queue[0] = {\n ...current,\n visible: false,\n };\n if (nextToast.priority === \"immediate\") {\n this.#queue.splice(1, 0, nextToast, current);\n } else {\n this.#queue.splice(1, 0, nextToast);\n }\n };\n\n /**\n * This calls `this.#emit()` if the toast was updated\n */\n #updateToast = (\n toastIdOrIndex: string | number,\n patch: Partial<QueuedToast>\n ): void => {\n const index =\n typeof toastIdOrIndex === \"number\"\n ? toastIdOrIndex\n : this.#getToastIndex(toastIdOrIndex);\n\n if (index === -1) {\n return;\n }\n\n this.#queue[index] = {\n ...this.#queue[index],\n ...patch,\n };\n this.#emit();\n };\n\n /**\n * This is just used to subscribe to changes in the {@link useToastQueue}.\n *\n * ```tsx\n * useSyncExternalStore(\n * toastManager.subscribe,\n * toastManager.getQueue,\n * toastManager.getQueue,\n * );\n * ```\n *\n * @internal\n */\n subscribe = (callback: ToastCallback): (() => void) => {\n this.#listeners.push(callback);\n\n return () => {\n this.#listeners = this.#listeners.filter((cb) => cb !== callback);\n };\n };\n\n /**\n * @see {@link subscribe}\n * @internal\n */\n getQueue = (): ToastQueue => {\n return this.#queue;\n };\n\n /**\n * Either adds the toast to the queue or updates an existing toast when using\n * an existing `toastId`.\n *\n * @example\n * Adding toasts\n * ```tsx\n * // create a toast when the user is offline that will not disappear\n * addToast({ toastId: \"offline\", visibleTime: null });\n *\n * // add a new toast that displays `\"Toast\"` to the queue\n * addToast({ children: \"Toast!\" });\n *\n * // add an online toast notification. since these three use the same toast\n * // id, the hide timer will be reset each time\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n * addToast({ toastId: \"online\" });\n *\n * // add a server error toast to the queue where the second one will be\n * // ignored\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n * addToast({\n * toastId: \"ServerError\",\n * theme: \"error\",\n * duplicates: \"prevent\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * addToast({\n * children: \"Hello, world!\",\n * action: \"Goodbye\",\n * });\n *\n * // add a toast to the queue that has an action button that says \"Goodbye\"\n * // and a custom click handler\n * addToast({\n * children: \"Hello, world!\",\n * action: {\n * onClick: () => {\n * logout();\n * },\n * children: \"Goodbye\",\n * },\n * });\n *\n * // add a toast to the queue that renders a react component in the content,\n * // a custom action button implementation (using `ToastActionButton`), and a\n * // close button\n * addToast({\n * children: <SomeCustomComponent />,\n * actionButton: <SomeCustomActionButton />,\n * closeButton: true,\n * });\n * ```\n */\n addToast = (toast: CreateToastOptions): void => {\n const {\n toastId = nanoid(),\n visibleTime = DEFAULT_TOAST_VISIBLE_TIME,\n role = visibleTime === null ? \"alert\" : \"status\",\n priority = \"normal\",\n duplicates = \"restart\",\n } = toast;\n\n const existingIndex = this.#getToastIndex(toast.toastId);\n if (existingIndex !== -1 && duplicates !== \"allow\") {\n const existingToast = this.#queue[existingIndex];\n\n // reorder/move the existing toast to be the next item in the queue by:\n // - removing the toast from the queue\n // - inserting it into the next position with the updates\n if (priority === \"next\" && existingIndex > 1) {\n this.#queue.splice(existingIndex, 1);\n this.#queue.splice(1, 0, { ...existingToast, ...toast });\n this.#emit();\n return;\n }\n\n // only need to reorder the queue if it is not being shown\n if (\n (priority === \"replace\" || priority === \"immediate\") &&\n existingIndex !== 0\n ) {\n this.#queue.splice(existingIndex, 1);\n this.#addToastImmediately({\n ...existingToast,\n ...toast,\n });\n this.#emit();\n return;\n }\n\n const timers = this.#timers.get(toastId);\n if (existingToast.visible && duplicates === \"restart\" && timers) {\n this.#timers.set(toastId, { ...timers, elapsedTime: 0 });\n this.startRemoveTimeout(toastId);\n }\n\n this.#updateToast(existingIndex, toast);\n return;\n }\n\n const nextToast: QueuedToast = {\n ...toast,\n role,\n paused: false,\n visible: true,\n toastId,\n priority,\n duplicates,\n visibleTime,\n };\n\n const queueSize = this.#queue.length;\n if (priority === \"next\" && queueSize > 1) {\n this.#queue.splice(1, 0, nextToast);\n } else if (\n (priority === \"replace\" || priority === \"immediate\") &&\n queueSize > 0\n ) {\n this.#addToastImmediately(nextToast);\n } else {\n this.#queue.push(nextToast);\n }\n\n this.#emit();\n };\n\n /**\n * Attempts to start the timeout for removing the toast when the `visibleTime`\n * is not null for a toast.\n *\n * @param toastId - The specific toastId to update\n */\n startRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n if (!toast) {\n return;\n }\n\n const { visibleTime } = toast;\n if (visibleTime === null) {\n // Must manually be closed\n return;\n }\n\n const cached = this.#timers.get(toastId);\n const timers = (cached && { ...cached }) || {\n inactive: false,\n startTime: Date.now(),\n elapsedTime: 0,\n };\n window.clearTimeout(timers.exitTimeout);\n\n let duration = visibleTime;\n if (timers.elapsedTime) {\n duration -= timers.elapsedTime;\n }\n\n timers.inactive = false;\n timers.exitTimeout = window.setTimeout(() => {\n this.removeToast(toastId, true);\n }, duration);\n this.#timers.set(toastId, timers);\n };\n\n /**\n * Pauses the remove timeout for a specific toast normally with hover events\n * or the browser becoming inactive.\n *\n * @param toastId - The specific toastId to pause\n */\n pauseRemoveTimeout = (toastId: string): void => {\n const toast = this.#getToast(toastId);\n const cached = this.#timers.get(toastId);\n if (!toast || !cached || cached.inactive) {\n return;\n }\n\n window.clearTimeout(cached.exitTimeout);\n const timers = { ...cached };\n timers.inactive = true;\n timers.elapsedTime = Date.now() - timers.startTime + timers.elapsedTime;\n this.#timers.set(toastId, timers);\n this.#updateToast(toastId, { paused: true });\n };\n\n /**\n * Resumes the current remove timeout if it was paused by\n * {@link pauseRemoveTimeout}.\n *\n * @param toastId - The specific toastId to resume\n */\n resumeRemoveTimeout = (toastId: string): void => {\n const toastIndex = this.#getToastIndex(toastId);\n const timers = this.#timers.get(toastId);\n if (toastIndex === -1 || !timers?.startTime) {\n return;\n }\n\n this.#updateToast(toastIndex, { paused: false });\n this.startRemoveTimeout(toastId);\n };\n\n /**\n * Removes a toast by id from the queue without any exit animation.\n *\n * @param toastId - The specific {@link QueuedToast.toastId}\n * @param transition - Set this to `true` to remove the toast by the exit\n * transition instead of immediately.\n */\n removeToast = (toastId: string, transition: boolean): void => {\n const toastIndex = this.#getToastIndex(toastId);\n if (toastIndex === -1) {\n return;\n }\n\n if (transition) {\n this.clearTimer(toastId);\n this.#updateToast(toastIndex, { visible: false });\n return;\n }\n\n this.#queue.splice(toastIndex, 1);\n this.#emit();\n };\n\n /**\n * Clears any pending timers for the provided toast id. This should generally\n * be used in the `useEffect` cleanup effect for any custom toast renderer\n * implementations.\n *\n * @example\n * ```tsx\n * const { toastId } = toast;\n * const toastManager = useToastManager();\n *\n * useEffect(() => {\n * return () => {\n * toastManager.clearTimer(toastId):\n * }\n * }, [toastManager, toastId]);\n * ```\n */\n clearTimer = (toastId: string): void => {\n const timer = this.#timers.get(toastId);\n window.clearTimeout(timer?.exitTimeout);\n this.#timers.delete(toastId);\n };\n\n /**\n * Removes first toast from the queue without any exit animation. You most\n * likely want to use {@link removeToast} instead.\n */\n popToast = (): void => {\n this.#queue.pop();\n this.#emit();\n };\n\n /**\n * Removes all toasts from the queue. There will be no exit animation.\n *\n * @param disableEmit - Set this to `true` to disable emitting the empty queue.\n * Mostly used for tests.\n */\n clearToasts = (disableEmit = false): void => {\n this.#queue = [];\n this.#timers.forEach((meta) => {\n window.clearTimeout(meta.exitTimeout);\n });\n this.#timers.clear();\n if (!disableEmit) {\n this.#emit();\n }\n };\n}\n\n/**\n * The default toast manager for react-md apps that will allow toasts to be\n * added without setting up the {@link ToastManagerProvider}.\n *\n * @internal\n * @remarks \\@since 6.0.0\n */\nexport const toastManager = new ToastManager();\n\n/**\n * @see {@link ToastManager.addToast}\n * @remarks \\@since 6.0.0\n */\nexport const addToast: ToastManager[\"addToast\"] = (toast) =>\n toastManager.addToast(toast);\n\n/**\n * @see {@link ToastManager.startRemoveTimeout}\n * @remarks \\@since 6.0.0\n */\nexport const startRemoveToastTimeout: ToastManager[\"startRemoveTimeout\"] = (\n toastId\n) => toastManager.startRemoveTimeout(toastId);\n\n/**\n * @see {@link ToastManager.popToast}\n * @remarks \\@since 6.0.0\n */\nexport const popToast: ToastManager[\"popToast\"] = () => toastManager.popToast();\n\n/**\n * @see {@link ToastManager.removeToast}\n * @remarks \\@since 6.0.0\n */\nexport const removeToast: ToastManager[\"removeToast\"] = (toastId, transition) =>\n toastManager.removeToast(toastId, transition);\n\n/**\n * @see {@link ToastManager.clearToasts}\n * @remarks \\@since 6.0.0\n */\nexport const clearToasts = (): void => toastManager.clearToasts();\n"],"names":["nanoid","DEFAULT_TOAST_VISIBLE_TIME","ToastManager","constructor","queue","listeners","forEach","callback","toastId","findIndex","toast","getToastIndex","nextToast","current","clearTimer","visible","priority","splice","toastIdOrIndex","patch","index","emit","subscribe","push","filter","cb","getQueue","addToast","visibleTime","role","duplicates","existingIndex","existingToast","addToastImmediately","timers","get","set","elapsedTime","startRemoveTimeout","updateToast","paused","queueSize","length","getToast","cached","inactive","startTime","Date","now","window","clearTimeout","exitTimeout","duration","setTimeout","removeToast","pauseRemoveTimeout","resumeRemoveTimeout","toastIndex","transition","timer","delete","popToast","pop","clearToasts","disableEmit","meta","clear","Map","toastManager","startRemoveToastTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,SAAS;AAGhC;;CAEC,GACD,OAAO,MAAMC,6BAA6B,KAAK;IA6H7C,sCACA,uCACA,0CAmBA,qCAQA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AAC2D;gBACpBhB,OAAOC,YAAY,CAACe,KAAKd,WAAW;YACtC;YACA,yBAAA,IAAI,EAAEjB,SAAOgC,KAAK;YAClB,IAAI,CAACF,aAAa;gBAChB,yBAAA,IAAI,EAAE3C,YAAN,IAAI;YACN;QACF;uCAlYQjB,QAAQ,EAAE;uCACV8B,SAAS,IAAIiC;uCACb9D,YAAY,EAAE;IAEpB,2EAA2E;IAC3E,2EAA2E;IAC3E,gCAAgC;IAChC,EAAE;IACF,OAAO;IACP,wBAAwB;IACxB,mCAAmC;IACnC,8BAA8B;IAC9B,8BAA8B;IAC9B,KAAK;IACP;AAqXF;AAEA;;;;;;CAMC,GACD,OAAO,MAAM+D,eAAe,IAAIlE,eAAe;AAE/C;;;CAGC,GACD,OAAO,MAAMyB,WAAqC,CAACjB,QACjD0D,aAAazC,QAAQ,CAACjB,OAAO;AAE/B;;;CAGC,GACD,OAAO,MAAM2D,0BAA8D,CACzE7D,UACG4D,aAAa9B,kBAAkB,CAAC9B,SAAS;AAE9C;;;CAGC,GACD,OAAO,MAAMqD,WAAqC,IAAMO,aAAaP,QAAQ,GAAG;AAEhF;;;CAGC,GACD,OAAO,MAAMP,cAA2C,CAAC9C,SAASkD,aAChEU,aAAad,WAAW,CAAC9C,SAASkD,YAAY;AAEhD;;;CAGC,GACD,OAAO,MAAMK,cAAc,IAAYK,aAAaL,WAAW,GAAG"}
|
|
@@ -60,43 +60,35 @@ $background-color: theme.get-default-color(
|
|
|
60
60
|
) !default;
|
|
61
61
|
$color: theme.get-default-color($light-theme-color, $dark-theme-color) !default;
|
|
62
62
|
|
|
63
|
-
$
|
|
64
|
-
color: (
|
|
65
|
-
var: --rmd-toast-color,
|
|
66
|
-
value: $color,
|
|
67
|
-
),
|
|
68
|
-
background-color: (
|
|
69
|
-
var: --rmd-toast-background-color,
|
|
70
|
-
value: $background-color,
|
|
71
|
-
),
|
|
72
|
-
offset: (
|
|
73
|
-
var: --rmd-snackbar-offset,
|
|
74
|
-
value: 0,
|
|
75
|
-
),
|
|
76
|
-
);
|
|
63
|
+
$variables: (background-color, color, offset);
|
|
77
64
|
|
|
78
65
|
@function get-var($name, $fallback: null) {
|
|
79
|
-
$
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
@if $value {
|
|
84
|
-
@return var(#{$var}, #{$value});
|
|
66
|
+
$var: utils.get-var-name($variables, $name, "snackbar");
|
|
67
|
+
@if $fallback {
|
|
68
|
+
@return var(#{$var}, #{$fallback});
|
|
85
69
|
}
|
|
86
70
|
|
|
87
71
|
@return var(#{$var});
|
|
88
72
|
}
|
|
89
73
|
|
|
90
74
|
@mixin set-var($name, $value) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
@if $value {
|
|
76
|
+
#{utils.get-var-name($variables, $name, "snackbar")}: #{$value};
|
|
77
|
+
}
|
|
94
78
|
}
|
|
95
79
|
|
|
96
80
|
@mixin use-var($property, $name: $property, $fallback: null) {
|
|
97
81
|
#{$property}: get-var($name, $fallback);
|
|
98
82
|
}
|
|
99
83
|
|
|
84
|
+
@mixin variables {
|
|
85
|
+
@if not $disable-everything {
|
|
86
|
+
@include set-var(background-color, $background-color);
|
|
87
|
+
@include set-var(color, $color);
|
|
88
|
+
@include set-var(offset, 0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
100
92
|
@mixin styles {
|
|
101
93
|
@if not $disable-everything {
|
|
102
94
|
.rmd-snackbar {
|
package/dist/table/_table.scss
CHANGED
|
@@ -108,85 +108,37 @@ $sticky-footer-active-styles: $sticky-header-active-styles !default;
|
|
|
108
108
|
$row-hover-color: interaction.get-var(hover-background-color) !default;
|
|
109
109
|
$row-selected-color: interaction.get-var(selected-background-color) !default;
|
|
110
110
|
|
|
111
|
-
$
|
|
112
|
-
background-color
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
header
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
),
|
|
128
|
-
cell-color: (
|
|
129
|
-
var: --rmd-table-cell-color,
|
|
130
|
-
value: $cell-color,
|
|
131
|
-
),
|
|
132
|
-
cell-height: (
|
|
133
|
-
var: --rmd-table-cell-height,
|
|
134
|
-
value: $cell-height,
|
|
135
|
-
),
|
|
136
|
-
cell-horizontal-padding: (
|
|
137
|
-
var: --rmd-table-cell-horizontal-padding,
|
|
138
|
-
value: $cell-horizontal-padding,
|
|
139
|
-
),
|
|
140
|
-
cell-vertical-padding: (
|
|
141
|
-
var: --rmd-table-cell-vertical-padding,
|
|
142
|
-
value: $cell-vertical-padding,
|
|
143
|
-
),
|
|
144
|
-
header-cell-height: (
|
|
145
|
-
var: --rmd-table-header-cell-height,
|
|
146
|
-
value: $cell-header-height,
|
|
147
|
-
),
|
|
148
|
-
hover-color: (
|
|
149
|
-
var: --rmd-table-hover-color,
|
|
150
|
-
value: $row-hover-color,
|
|
151
|
-
),
|
|
152
|
-
selected-color: (
|
|
153
|
-
var: --rmd-table-selected-color,
|
|
154
|
-
value: $row-selected-color,
|
|
155
|
-
),
|
|
156
|
-
sticky-cell: (
|
|
157
|
-
var: --rmd-table-sticky-cell,
|
|
158
|
-
value: $sticky-cell-position,
|
|
159
|
-
),
|
|
160
|
-
sticky-header: (
|
|
161
|
-
var: --rmd-table-sticky-header,
|
|
162
|
-
value: $sticky-header-position,
|
|
163
|
-
),
|
|
164
|
-
sticky-footer: (
|
|
165
|
-
var: --rmd-table-sticky-footer,
|
|
166
|
-
value: $sticky-footer-position,
|
|
167
|
-
),
|
|
168
|
-
sticky-background-color: (
|
|
169
|
-
var: --rmd-table-sticky-background-color,
|
|
170
|
-
value: $sticky-background-color,
|
|
171
|
-
),
|
|
111
|
+
$variables: (
|
|
112
|
+
background-color,
|
|
113
|
+
border-size,
|
|
114
|
+
border-color,
|
|
115
|
+
header-background-color,
|
|
116
|
+
cell-color,
|
|
117
|
+
cell-height,
|
|
118
|
+
cell-horizontal-padding,
|
|
119
|
+
cell-vertical-padding,
|
|
120
|
+
header-cell-height,
|
|
121
|
+
hover-color,
|
|
122
|
+
selected-color,
|
|
123
|
+
sticky-cell,
|
|
124
|
+
sticky-header,
|
|
125
|
+
sticky-footer,
|
|
126
|
+
sticky-background-color
|
|
172
127
|
);
|
|
173
128
|
|
|
174
129
|
@function get-var($name, $fallback: null) {
|
|
175
|
-
$
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
@if $value {
|
|
180
|
-
@return var(#{$var}, #{$value});
|
|
130
|
+
$var: utils.get-var-name($variables, $name, "table");
|
|
131
|
+
@if $fallback {
|
|
132
|
+
@return var(#{$var}, #{$fallback});
|
|
181
133
|
}
|
|
182
134
|
|
|
183
135
|
@return var(#{$var});
|
|
184
136
|
}
|
|
185
137
|
|
|
186
138
|
@mixin set-var($name, $value) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
139
|
+
@if $value {
|
|
140
|
+
#{utils.get-var-name($variables, $name, "table")}: #{$value};
|
|
141
|
+
}
|
|
190
142
|
}
|
|
191
143
|
|
|
192
144
|
@mixin use-var($property, $name: $property, $fallback: null) {
|
|
@@ -227,6 +179,39 @@ $row-selected-styles: (
|
|
|
227
179
|
}
|
|
228
180
|
}
|
|
229
181
|
|
|
182
|
+
@mixin variables {
|
|
183
|
+
@if not $disable-everything {
|
|
184
|
+
@include set-var(background-color, $background-color);
|
|
185
|
+
@include set-var(header-background-color, $header-background-color);
|
|
186
|
+
@include set-var(cell-color, $cell-color);
|
|
187
|
+
@include set-var(cell-height, $cell-height);
|
|
188
|
+
@include set-var(cell-horizontal-padding, $cell-horizontal-padding);
|
|
189
|
+
@include set-var(cell-vertical-padding, $cell-vertical-padding);
|
|
190
|
+
@include set-var(header-cell-height, $cell-header-height);
|
|
191
|
+
@include set-var(selected-color, $row-selected-color);
|
|
192
|
+
|
|
193
|
+
@if not $disable-bordered {
|
|
194
|
+
@include set-var(border-size, $border-size);
|
|
195
|
+
@include set-var(border-color, $border-color);
|
|
196
|
+
}
|
|
197
|
+
@if not $disable-hoverable {
|
|
198
|
+
@include set-var(hover-color, $row-hover-color);
|
|
199
|
+
}
|
|
200
|
+
@if not $disable-sticky-cell {
|
|
201
|
+
@include set-var(sticky-cell, $sticky-cell-position);
|
|
202
|
+
}
|
|
203
|
+
@if not $disable-sticky-header {
|
|
204
|
+
@include set-var(sticky-header, $sticky-header-position);
|
|
205
|
+
}
|
|
206
|
+
@if not $disable-sticky-footer {
|
|
207
|
+
@include set-var(sticky-footer, $sticky-footer-position);
|
|
208
|
+
}
|
|
209
|
+
@if not $disable-sticky-header or not $disable-sticky-footer {
|
|
210
|
+
@include set-var(sticky-background-color, $sticky-background-color);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
230
215
|
@mixin styles {
|
|
231
216
|
@if not $disable-everything {
|
|
232
217
|
@if not $disable-container {
|
package/dist/tabs/_tabs.scss
CHANGED
|
@@ -42,45 +42,27 @@ $tablist-scroller-background-color: theme.theme-get-var(
|
|
|
42
42
|
inherit
|
|
43
43
|
) !default;
|
|
44
44
|
|
|
45
|
-
$
|
|
46
|
-
color
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var: --rmd-tab-active-color,
|
|
52
|
-
value: $active-color,
|
|
53
|
-
),
|
|
54
|
-
inactive-color: (
|
|
55
|
-
var: --rmd-tab-inactive-color,
|
|
56
|
-
value: $inactive-color,
|
|
57
|
-
),
|
|
58
|
-
disabled-color: (
|
|
59
|
-
var: --rmd-tab-disabled-color,
|
|
60
|
-
value: $disabled-color,
|
|
61
|
-
),
|
|
62
|
-
indicator-background: (
|
|
63
|
-
var: --rmd-tab-indicator-background,
|
|
64
|
-
value: $indicator-background,
|
|
65
|
-
),
|
|
45
|
+
$variables: (
|
|
46
|
+
color,
|
|
47
|
+
active-color,
|
|
48
|
+
inactive-color,
|
|
49
|
+
disabled-color,
|
|
50
|
+
indicator-background
|
|
66
51
|
);
|
|
67
52
|
|
|
68
53
|
@function get-var($name, $fallback: null) {
|
|
69
|
-
$
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@if $value {
|
|
74
|
-
@return var(#{$var}, #{$value});
|
|
54
|
+
$var: utils.get-var-name($variables, $name, "tab");
|
|
55
|
+
@if $fallback {
|
|
56
|
+
@return var(#{$var}, #{$fallback});
|
|
75
57
|
}
|
|
76
58
|
|
|
77
59
|
@return var(#{$var});
|
|
78
60
|
}
|
|
79
61
|
|
|
80
62
|
@mixin set-var($name, $value) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
@if $value {
|
|
64
|
+
#{utils.get-var-name($variables, $name, "tab")}: #{$value};
|
|
65
|
+
}
|
|
84
66
|
}
|
|
85
67
|
|
|
86
68
|
@mixin use-var($property, $name: $property, $fallback: null) {
|
|
@@ -248,6 +230,19 @@ $var-lookup: (
|
|
|
248
230
|
}
|
|
249
231
|
}
|
|
250
232
|
|
|
233
|
+
@mixin variables {
|
|
234
|
+
@if not $disable-everything {
|
|
235
|
+
@include set-var(color, $inactive-color);
|
|
236
|
+
@include set-var(active-color, $active-color);
|
|
237
|
+
@include set-var(inactive-color, $inactive-color);
|
|
238
|
+
@include set-var(disabled-color, $disabled-color);
|
|
239
|
+
|
|
240
|
+
@if not $disable-indicator {
|
|
241
|
+
@include set-var(indicator-background, $indicator-background);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
251
246
|
@mixin styles {
|
|
252
247
|
@if not $disable-everything {
|
|
253
248
|
@include tablist-styles;
|
package/dist/theme/_theme.scss
CHANGED
|
@@ -129,96 +129,34 @@ $_validated_color_scheme: utils.validate(
|
|
|
129
129
|
"$color-scheme"
|
|
130
130
|
);
|
|
131
131
|
|
|
132
|
-
$theme-
|
|
133
|
-
background-color
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
on-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
secondary-color: (
|
|
154
|
-
var: --rmd-secondary-color,
|
|
155
|
-
value: $secondary-color,
|
|
156
|
-
),
|
|
157
|
-
on-secondary-color: (
|
|
158
|
-
var: --rmd-on-secondary-color,
|
|
159
|
-
value: $on-secondary-color,
|
|
160
|
-
),
|
|
161
|
-
warning-color: (
|
|
162
|
-
var: --rmd-warning-color,
|
|
163
|
-
value: $warning-color,
|
|
164
|
-
),
|
|
165
|
-
on-warning-color: (
|
|
166
|
-
var: --rmd-on-warning-color,
|
|
167
|
-
value: $on-warning-color,
|
|
168
|
-
),
|
|
169
|
-
error-color: (
|
|
170
|
-
var: --rmd-error-color,
|
|
171
|
-
value: $error-color,
|
|
172
|
-
),
|
|
173
|
-
on-error-color: (
|
|
174
|
-
var: --rmd-on-error-color,
|
|
175
|
-
value: $on-error-color,
|
|
176
|
-
),
|
|
177
|
-
success-color: (
|
|
178
|
-
var: --rmd-success-color,
|
|
179
|
-
value: $success-color,
|
|
180
|
-
),
|
|
181
|
-
on-success-color: (
|
|
182
|
-
var: --rmd-on-success-color,
|
|
183
|
-
value: $on-success-color,
|
|
184
|
-
),
|
|
185
|
-
text-primary-color: (
|
|
186
|
-
var: --rmd-text-primary-color,
|
|
187
|
-
value: $text-primary-color,
|
|
188
|
-
),
|
|
189
|
-
text-secondary-color: (
|
|
190
|
-
var: --rmd-text-secondary-color,
|
|
191
|
-
value: $text-secondary-color,
|
|
192
|
-
),
|
|
193
|
-
text-hint-color: (
|
|
194
|
-
var: --rmd-text-hint-color,
|
|
195
|
-
value: $text-hint-color,
|
|
196
|
-
),
|
|
197
|
-
text-disabled-color: (
|
|
198
|
-
var: --rmd-text-disabled-color,
|
|
199
|
-
value: $text-disabled-color,
|
|
200
|
-
),
|
|
201
|
-
outline-width: (
|
|
202
|
-
var: --rmd-outline-width,
|
|
203
|
-
value: $outline-width,
|
|
204
|
-
),
|
|
205
|
-
outline-color: (
|
|
206
|
-
var: --rmd-outline-color,
|
|
207
|
-
value: $outline-color,
|
|
208
|
-
),
|
|
209
|
-
outline-grey-color: (
|
|
210
|
-
var: --rmd-outline-grey-color,
|
|
211
|
-
value: $outline-grey-color,
|
|
212
|
-
),
|
|
132
|
+
$theme-variables: (
|
|
133
|
+
background-color,
|
|
134
|
+
on-background-color,
|
|
135
|
+
surface-color,
|
|
136
|
+
primary-color,
|
|
137
|
+
on-primary-color,
|
|
138
|
+
secondary-color,
|
|
139
|
+
on-secondary-color,
|
|
140
|
+
warning-color,
|
|
141
|
+
on-warning-color,
|
|
142
|
+
success-color,
|
|
143
|
+
on-success-color,
|
|
144
|
+
error-color,
|
|
145
|
+
on-error-color,
|
|
146
|
+
text-primary-color,
|
|
147
|
+
text-secondary-color,
|
|
148
|
+
text-hint-color,
|
|
149
|
+
text-disabled-color,
|
|
150
|
+
outline-width,
|
|
151
|
+
outline-color,
|
|
152
|
+
outline-grey-color
|
|
213
153
|
);
|
|
214
154
|
|
|
215
155
|
@function theme-get-var($name, $fallback: null) {
|
|
216
|
-
$
|
|
217
|
-
$var: map.get($found, var);
|
|
218
|
-
$value: if($fallback, $fallback, map.get($found, value));
|
|
156
|
+
$var: utils.get-var-name($theme-variables, $name, "theme");
|
|
219
157
|
|
|
220
|
-
@if $
|
|
221
|
-
@return var(#{$var}, #{$
|
|
158
|
+
@if $fallback {
|
|
159
|
+
@return var(#{$var}, #{$fallback});
|
|
222
160
|
}
|
|
223
161
|
|
|
224
162
|
@return var(#{$var});
|
|
@@ -237,9 +175,9 @@ $theme-var-lookup: (
|
|
|
237
175
|
}
|
|
238
176
|
|
|
239
177
|
@mixin theme-set-var($name, $value-or-theme-name) {
|
|
240
|
-
$var:
|
|
178
|
+
$var: utils.get-var-name($theme-variables, $name, "theme");
|
|
241
179
|
$value: $value-or-theme-name;
|
|
242
|
-
@if
|
|
180
|
+
@if list.index($theme-variables, $value-or-theme-name) {
|
|
243
181
|
$name: $value-or-theme-name;
|
|
244
182
|
$value: theme-get-var($name);
|
|
245
183
|
}
|
|
@@ -291,7 +229,7 @@ $theme-var-lookup: (
|
|
|
291
229
|
}
|
|
292
230
|
}
|
|
293
231
|
|
|
294
|
-
@mixin
|
|
232
|
+
@mixin theme-variables {
|
|
295
233
|
@include theme-set-var(background-color, $background-color);
|
|
296
234
|
@if $disable-dark-elevation {
|
|
297
235
|
@include theme-set-var(surface-color, $surface-color);
|
|
@@ -317,6 +255,10 @@ $theme-var-lookup: (
|
|
|
317
255
|
@include set-dark-elevation-color($z-value, $background-color);
|
|
318
256
|
}
|
|
319
257
|
}
|
|
258
|
+
|
|
259
|
+
@include theme-set-var(outline-width, $outline-width);
|
|
260
|
+
@include theme-set-var(outline-color, $outline-color);
|
|
261
|
+
@include theme-set-var(outline-grey-color, $outline-grey-color);
|
|
320
262
|
}
|
|
321
263
|
|
|
322
264
|
@mixin create-surface($z-value, $disable-colors: $disable-dark-elevation) {
|
|
@@ -45,45 +45,36 @@ $leave-duration: transition.$linear-duration !default;
|
|
|
45
45
|
$leave-timing-function: transition.$acceleration-timing-function !default;
|
|
46
46
|
$transition-distance: 0.5rem !default;
|
|
47
47
|
|
|
48
|
-
$
|
|
49
|
-
background-color: (
|
|
50
|
-
var: --rmd-tooltip-background-color,
|
|
51
|
-
value: $background-color,
|
|
52
|
-
),
|
|
53
|
-
color: (
|
|
54
|
-
var: --rmd-tooltip-color,
|
|
55
|
-
value: $color,
|
|
56
|
-
),
|
|
57
|
-
spacing: (
|
|
58
|
-
// this is only added so you can safely do:
|
|
59
|
-
// @include react-md.tooltip-set-var(spacing, $custom-spacing);
|
|
60
|
-
var: --rmd-tooltip-spacing,
|
|
61
|
-
value: $spacing,
|
|
62
|
-
),
|
|
63
|
-
);
|
|
48
|
+
$variables: (background-color, color, spacing);
|
|
64
49
|
|
|
65
50
|
@function get-var($name, $fallback: null) {
|
|
66
|
-
$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@if $value {
|
|
71
|
-
@return var(#{$var}, #{$value});
|
|
51
|
+
$var: utils.get-var-name($variables, $name, "tooltip");
|
|
52
|
+
@if $fallback {
|
|
53
|
+
@return var(#{$var}, #{$fallback});
|
|
72
54
|
}
|
|
73
55
|
|
|
74
56
|
@return var(#{$var});
|
|
75
57
|
}
|
|
76
58
|
|
|
77
59
|
@mixin set-var($name, $value) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
@if $value {
|
|
61
|
+
#{utils.get-var-name($variables, $name, "tooltip")}: #{$value};
|
|
62
|
+
}
|
|
81
63
|
}
|
|
82
64
|
|
|
83
65
|
@mixin use-var($property, $name: $property, $fallback: null) {
|
|
84
66
|
#{$property}: get-var($name, $fallback);
|
|
85
67
|
}
|
|
86
68
|
|
|
69
|
+
@mixin variables {
|
|
70
|
+
@if not $disable-everything {
|
|
71
|
+
@include set-var(background-color, $background-color);
|
|
72
|
+
@include set-var(color, $color);
|
|
73
|
+
|
|
74
|
+
// do not include spacing
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
87
78
|
@mixin styles {
|
|
88
79
|
@if not $disable-everything {
|
|
89
80
|
.rmd-tooltip {
|