@activecollab/components 2.0.571 → 2.0.573
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/dist/cjs/components/EditableContent/Styles.js +1 -1
- package/dist/cjs/components/EditableContent/Styles.js.map +1 -1
- package/dist/cjs/components/MainMenu/MainMenu.js +25 -13
- package/dist/cjs/components/MainMenu/MainMenu.js.map +1 -1
- package/dist/cjs/components/MainMenu/Styles.js +1 -1
- package/dist/cjs/components/MainMenu/Styles.js.map +1 -1
- package/dist/cjs/components/MainMenu/hooks.js +33 -2
- package/dist/cjs/components/MainMenu/hooks.js.map +1 -1
- package/dist/cjs/components/MainMenu/types.js +2 -1
- package/dist/cjs/components/MainMenu/types.js.map +1 -1
- package/dist/cjs/components/ScrollArea/ScrollArea.js +157 -0
- package/dist/cjs/components/ScrollArea/ScrollArea.js.map +1 -0
- package/dist/cjs/components/ScrollArea/Styles.js +17 -0
- package/dist/cjs/components/ScrollArea/Styles.js.map +1 -0
- package/dist/cjs/components/ScrollArea/index.js +17 -0
- package/dist/cjs/components/ScrollArea/index.js.map +1 -0
- package/dist/cjs/components/ViewSwitcher/Styles.js +37 -18
- package/dist/cjs/components/ViewSwitcher/Styles.js.map +1 -1
- package/dist/cjs/components/ViewSwitcher/ViewSwitcher.js +12 -1
- package/dist/cjs/components/ViewSwitcher/ViewSwitcher.js.map +1 -1
- package/dist/cjs/components/ViewSwitcher/ViewSwitcherMenu.js +12 -4
- package/dist/cjs/components/ViewSwitcher/ViewSwitcherMenu.js.map +1 -1
- package/dist/cjs/components/index.js +12 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/esm/components/EditableContent/Styles.d.ts.map +1 -1
- package/dist/esm/components/EditableContent/Styles.js +1 -1
- package/dist/esm/components/EditableContent/Styles.js.map +1 -1
- package/dist/esm/components/MainMenu/MainMenu.d.ts.map +1 -1
- package/dist/esm/components/MainMenu/MainMenu.js +25 -12
- package/dist/esm/components/MainMenu/MainMenu.js.map +1 -1
- package/dist/esm/components/MainMenu/Styles.d.ts.map +1 -1
- package/dist/esm/components/MainMenu/Styles.js +1 -1
- package/dist/esm/components/MainMenu/Styles.js.map +1 -1
- package/dist/esm/components/MainMenu/hooks.d.ts +1 -0
- package/dist/esm/components/MainMenu/hooks.d.ts.map +1 -1
- package/dist/esm/components/MainMenu/hooks.js +28 -1
- package/dist/esm/components/MainMenu/hooks.js.map +1 -1
- package/dist/esm/components/MainMenu/types.d.ts +1 -0
- package/dist/esm/components/MainMenu/types.d.ts.map +1 -1
- package/dist/esm/components/MainMenu/types.js +2 -1
- package/dist/esm/components/MainMenu/types.js.map +1 -1
- package/dist/esm/components/ScrollArea/ScrollArea.d.ts +39 -0
- package/dist/esm/components/ScrollArea/ScrollArea.d.ts.map +1 -0
- package/dist/esm/components/ScrollArea/ScrollArea.js +137 -0
- package/dist/esm/components/ScrollArea/ScrollArea.js.map +1 -0
- package/dist/esm/components/ScrollArea/Styles.d.ts +3 -0
- package/dist/esm/components/ScrollArea/Styles.d.ts.map +1 -0
- package/dist/esm/components/ScrollArea/Styles.js +10 -0
- package/dist/esm/components/ScrollArea/Styles.js.map +1 -0
- package/dist/esm/components/ScrollArea/index.d.ts +2 -0
- package/dist/esm/components/ScrollArea/index.d.ts.map +1 -0
- package/dist/esm/components/ScrollArea/index.js +2 -0
- package/dist/esm/components/ScrollArea/index.js.map +1 -0
- package/dist/esm/components/ViewSwitcher/Styles.d.ts +2 -0
- package/dist/esm/components/ViewSwitcher/Styles.d.ts.map +1 -1
- package/dist/esm/components/ViewSwitcher/Styles.js +36 -17
- package/dist/esm/components/ViewSwitcher/Styles.js.map +1 -1
- package/dist/esm/components/ViewSwitcher/ViewSwitcher.d.ts +2 -0
- package/dist/esm/components/ViewSwitcher/ViewSwitcher.d.ts.map +1 -1
- package/dist/esm/components/ViewSwitcher/ViewSwitcher.js +12 -1
- package/dist/esm/components/ViewSwitcher/ViewSwitcher.js.map +1 -1
- package/dist/esm/components/ViewSwitcher/ViewSwitcherMenu.d.ts +4 -0
- package/dist/esm/components/ViewSwitcher/ViewSwitcherMenu.d.ts.map +1 -1
- package/dist/esm/components/ViewSwitcher/ViewSwitcherMenu.js +13 -5
- package/dist/esm/components/ViewSwitcher/ViewSwitcherMenu.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/index.js +275 -43
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollArea.js","names":["React","forwardRef","useEffect","useImperativeHandle","useRef","classnames","OverlayScrollbars","SCROLL_AREA_THEME","StyledScrollArea","ratio","position","range","valuesOf","view","_ref","_ref$scrollTop","scrollTop","_ref$scrollLeft","scrollLeft","_ref$scrollWidth","scrollWidth","_ref$scrollHeight","scrollHeight","_ref$clientWidth","clientWidth","_ref$clientHeight","clientHeight","top","left","ScrollArea","_ref2","ref","children","className","style","_ref2$autoHeight","autoHeight","autoHeightMin","autoHeightMax","onScroll","onUpdate","hostRef","viewRef","handlersRef","current","getValues","getScrollLeft","_viewRef$current$scro","_viewRef$current","getScrollTop","_viewRef$current$scro2","_viewRef$current2","scrollToRight","scrollToBottom","host","viewport","undefined","update","instance","target","elements","scrollbars","theme","autoHide","autoHideDelay","initialized","updated","scroll","_instance","event","destroy","createElement","_extends","height","minHeight","maxHeight","width","displayName"],"sources":["../../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import React, {\n CSSProperties,\n ReactNode,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n} from \"react\";\n\nimport classnames from \"classnames\";\nimport { OverlayScrollbars } from \"overlayscrollbars\";\n\nimport { SCROLL_AREA_THEME, StyledScrollArea } from \"./Styles\";\n\nexport interface ScrollAreaValues {\n /** The vertical position, from 0 at the top to 1 at the bottom. */\n top: number;\n /** The horizontal position, from 0 at the left to 1 at the right. */\n left: number;\n scrollTop: number;\n scrollLeft: number;\n scrollWidth: number;\n scrollHeight: number;\n clientWidth: number;\n clientHeight: number;\n}\n\nexport interface ScrollAreaHandle {\n /** The element that scrolls. */\n readonly view: HTMLDivElement | null;\n getValues: () => ScrollAreaValues;\n getScrollLeft: () => number;\n getScrollTop: () => number;\n scrollLeft: (left?: number) => void;\n scrollTop: (top?: number) => void;\n scrollToRight: () => void;\n scrollToBottom: () => void;\n}\n\nexport interface ScrollAreaProps {\n children?: ReactNode;\n className?: string;\n style?: CSSProperties;\n /** If true, the area is as high as its content, up to autoHeightMax. */\n autoHeight?: boolean;\n autoHeightMin?: number | string;\n autoHeightMax?: number | string;\n onScroll?: (event: Event) => void;\n /** Called with the scroll values on every scroll and on every change of size. */\n onUpdate?: (values: ScrollAreaValues) => void;\n}\n\nconst ratio = (position: number, range: number) =>\n range > 0 ? position / range : 0;\n\nconst valuesOf = (view: HTMLElement | null): ScrollAreaValues => {\n const {\n scrollTop = 0,\n scrollLeft = 0,\n scrollWidth = 0,\n scrollHeight = 0,\n clientWidth = 0,\n clientHeight = 0,\n } = view ?? {};\n\n return {\n top: ratio(scrollTop, scrollHeight - clientHeight),\n left: ratio(scrollLeft, scrollWidth - clientWidth),\n scrollTop,\n scrollLeft,\n scrollWidth,\n scrollHeight,\n clientWidth,\n clientHeight,\n };\n};\n\n/** Scrollbars that look the same in every browser: they show while the content scrolls, and grow under the pointer. Needs the overlayscrollbars CSS once in the app. */\nexport const ScrollArea = forwardRef<ScrollAreaHandle, ScrollAreaProps>(\n (\n {\n children,\n className,\n style,\n autoHeight = false,\n autoHeightMin,\n autoHeightMax,\n onScroll,\n onUpdate,\n },\n ref\n ) => {\n const hostRef = useRef<HTMLDivElement>(null);\n const viewRef = useRef<HTMLDivElement>(null);\n const handlersRef = useRef({ onScroll, onUpdate });\n\n handlersRef.current = { onScroll, onUpdate };\n\n useImperativeHandle(\n ref,\n () => ({\n get view() {\n return viewRef.current;\n },\n getValues: () => valuesOf(viewRef.current),\n getScrollLeft: () => viewRef.current?.scrollLeft ?? 0,\n getScrollTop: () => viewRef.current?.scrollTop ?? 0,\n scrollLeft: (left = 0) => {\n if (viewRef.current) viewRef.current.scrollLeft = left;\n },\n scrollTop: (top = 0) => {\n if (viewRef.current) viewRef.current.scrollTop = top;\n },\n scrollToRight: () => {\n if (viewRef.current) {\n viewRef.current.scrollLeft = viewRef.current.scrollWidth;\n }\n },\n scrollToBottom: () => {\n if (viewRef.current) {\n viewRef.current.scrollTop = viewRef.current.scrollHeight;\n }\n },\n }),\n []\n );\n\n useEffect(() => {\n const host = hostRef.current;\n const viewport = viewRef.current;\n\n if (!host || !viewport) return undefined;\n\n const update = () =>\n handlersRef.current.onUpdate?.(valuesOf(viewRef.current));\n\n const instance = OverlayScrollbars(\n { target: host, elements: { viewport } },\n {\n scrollbars: {\n theme: SCROLL_AREA_THEME,\n autoHide: \"scroll\",\n autoHideDelay: 800,\n },\n },\n {\n initialized: update,\n updated: update,\n scroll: (_instance, event) => {\n handlersRef.current.onScroll?.(event);\n update();\n },\n }\n );\n\n return () => instance.destroy();\n }, []);\n\n return (\n <StyledScrollArea\n ref={hostRef}\n className={classnames(\"c-scroll-area\", className)}\n style={\n autoHeight\n ? {\n ...style,\n height: \"auto\",\n minHeight: autoHeightMin,\n maxHeight: autoHeightMax,\n }\n : { width: \"100%\", height: \"100%\", ...style }\n }\n data-overlayscrollbars-initialize=\"\"\n >\n <div\n ref={viewRef}\n className=\"c-scroll-area__view\"\n style={autoHeight ? { maxHeight: autoHeightMax } : undefined}\n >\n {children}\n </div>\n </StyledScrollArea>\n );\n }\n);\n\nScrollArea.displayName = \"ScrollArea\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAGVC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,iB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ACjB;IACF,CAAC,EACD;MACEC,WAAW,EAAER,MAAM;MACnBS,OAAO,EAAET,MAAM;MACfU,MAAM,EAAEA,CAACC,SAAS,EAAEC,KAAK,KAAK;QAC5B1B,WAAW,CAACC,OAAO,CAACL,QAAQ,YAA5BI,WAAW,CAACC,OAAO,CAACL,QAAQ,CAAG8B,KAAK,CAAC;QACrCZ,MAAM,CAAC,CAAC;MACV;IACF,CACF,CAAC;IAED,OAAO,MAAMC,QAAQ,CAACY,OAAO,CAAC,CAAC;EACjC,CAAC,EAAE,EAAE,CAAC;EAEN,oBACEtE,KAAA,CAAAuE,aAAA,CAAC/D,gBAAgB;IACfuB,GAAG,EAAEU,OAAQ;IACbR,SAAS,EAAE5B,UAAU,CAAC,eAAe,EAAE4B,SAAS,CAAE;IAClDC,KAAK,EACHE,UAAU,GAAAoC,QAAA,KAEDtC,KAAK;MACRuC,MAAM,EAAE,MAAM;MACdC,SAAS,EAAErC,aAAa;MACxBsC,SAAS,EAAErC;IAAa,KAAAkC,QAAA;MAExBI,KAAK,EAAE,MAAM;MAAEH,MAAM,EAAE;IAAM,GAAKvC,KAAK,CAC9C;IACD,qCAAkC;EAAE,gBAEpClC,KAAA,CAAAuE,aAAA;IACExC,GAAG,EAAEW,OAAQ;IACbT,SAAS,EAAC,qBAAqB;IAC/BC,KAAK,EAAEE,UAAU,GAAG;MAAEuC,SAAS,EAAErC;IAAc,CAAC,GAAGkB;EAAU,GAE5DxB,QACE,CACW,CAAC;AAEvB,CACF,CAAC;AAEDH,UAAU,CAACgD,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/ScrollArea/Styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,gBAAgB,CAAC;AAG/C,eAAO,MAAM,gBAAgB,oEAkC5B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
export const SCROLL_AREA_THEME = "os-theme-ac";
|
|
3
|
+
|
|
4
|
+
/* A thin bar on the edge that grows under the pointer, in the text color of the theme. */
|
|
5
|
+
export const StyledScrollArea = styled.div.withConfig({
|
|
6
|
+
displayName: "Styles__StyledScrollArea",
|
|
7
|
+
componentId: "sc-uwrfsw-0"
|
|
8
|
+
})(["position:relative;.os-scrollbar.", "{--os-size:12px;--os-padding-perpendicular:2px;--os-padding-axis:3px;--os-track-border-radius:999px;--os-handle-border-radius:999px;--os-handle-min-size:32px;--os-handle-perpendicular-size:75%;--os-handle-perpendicular-size-hover:100%;--os-handle-perpendicular-size-active:100%;--os-handle-interactive-area-offset:4px;--os-handle-bg:color-mix(in srgb,var(--color-theme-900) 28%,transparent);--os-handle-bg-hover:color-mix( in srgb,var(--color-theme-900) 40%,transparent );--os-handle-bg-active:color-mix( in srgb,var(--color-theme-900) 50%,transparent );z-index:1;&:hover,&:active{opacity:1;visibility:visible;}}"], SCROLL_AREA_THEME);
|
|
9
|
+
StyledScrollArea.displayName = "StyledScrollArea";
|
|
10
|
+
//# sourceMappingURL=Styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","SCROLL_AREA_THEME","StyledScrollArea","div","withConfig","displayName","componentId"],"sources":["../../../../src/components/ScrollArea/Styles.ts"],"sourcesContent":["import styled from \"styled-components\";\n\nexport const SCROLL_AREA_THEME = \"os-theme-ac\";\n\n/* A thin bar on the edge that grows under the pointer, in the text color of the theme. */\nexport const StyledScrollArea = styled.div`\n position: relative;\n\n .os-scrollbar.${SCROLL_AREA_THEME} {\n --os-size: 12px;\n --os-padding-perpendicular: 2px;\n --os-padding-axis: 3px;\n --os-track-border-radius: 999px;\n --os-handle-border-radius: 999px;\n --os-handle-min-size: 32px;\n --os-handle-perpendicular-size: 75%;\n --os-handle-perpendicular-size-hover: 100%;\n --os-handle-perpendicular-size-active: 100%;\n --os-handle-interactive-area-offset: 4px;\n --os-handle-bg: color-mix(in srgb, var(--color-theme-900) 28%, transparent);\n --os-handle-bg-hover: color-mix(\n in srgb,\n var(--color-theme-900) 40%,\n transparent\n );\n --os-handle-bg-active: color-mix(\n in srgb,\n var(--color-theme-900) 50%,\n transparent\n );\n z-index: 1;\n\n /* Like macOS: a bar under the pointer or in a drag does not hide. */\n &:hover,\n &:active {\n opacity: 1;\n visibility: visible;\n }\n }\n`;\n\nStyledScrollArea.displayName = \"StyledScrollArea\";\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,iBAAiB,GAAG,aAAa;;AAE9C;AACA,OAAO,MAAMC,gBAAgB,GAAGF,MAAM,CAACG,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,ipBAGxBL,iBAAiB,CA+BlC;AAEDC,gBAAgB,CAACG,WAAW,GAAG,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ScrollArea/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/ScrollArea/index.ts"],"sourcesContent":["export * from \"./ScrollArea\";\n"],"mappings":"AAAA,cAAc,cAAc","ignoreList":[]}
|
|
@@ -7,6 +7,8 @@ export declare const StyledViewSwitcherTrack: import("styled-components").Styled
|
|
|
7
7
|
export declare const StyledViewSwitcherOptions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
8
|
export declare const StyledViewSwitcherOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
9
9
|
export declare const StyledViewSwitcherMenuOption: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
10
|
+
export declare const StyledViewSwitcherMenuRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const StyledViewSwitcherMenuClip: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
12
|
export declare const StyledViewSwitcherMenuIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
11
13
|
export declare const StyledViewSwitcherMenuList: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("..").ListProps & {
|
|
12
14
|
children?: import("react").ReactNode | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/ViewSwitcher/Styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,kBAAkB,oEAI9B,CAAC;AAIF,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/ViewSwitcher/Styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,kBAAkB,oEAI9B,CAAC;AAIF,eAAO,MAAM,uBAAuB,oEASnC,CAAC;AAIF,eAAO,MAAM,yBAAyB,oEAGrC,CAAC;AAIF,eAAO,MAAM,wBAAwB,uEA4CpC,CAAC;AAIF,eAAO,MAAM,4BAA4B,uEAwDxC,CAAC;AA6BF,eAAO,MAAM,0BAA0B,oEA8BtC,CAAC;AAIF,eAAO,MAAM,0BAA0B,oEAOtC,CAAC;AAIF,eAAO,MAAM,0BAA0B,qEAKtC,CAAC;AAIF,eAAO,MAAM,0BAA0B;;;;;;;;;;kBAEtC,CAAC;AAIF,eAAO,MAAM,2BAA2B,qEAOvC,CAAC;AAiCF,eAAO,MAAM,6BAA6B,qEAOzC,CAAC;AAQF,eAAO,MAAM,wBAAwB,oEAuDpC,CAAC;AAIF,eAAO,MAAM,4BAA4B,oEAIxC,CAAC;AAIF,eAAO,MAAM,4BAA4B,oEAexC,CAAC;AAIF,eAAO,MAAM,wBAAwB,uEA8BpC,CAAC;AAIF,eAAO,MAAM,sBAAsB,kEAMlC,CAAC;AAIF,eAAO,MAAM,yBAAyB,uEAmCrC,CAAC;AAIF,eAAO,MAAM,yBAAyB,qEAuBrC,CAAC"}
|
|
@@ -13,7 +13,7 @@ StyledViewSwitcher.displayName = "StyledViewSwitcher";
|
|
|
13
13
|
export const StyledViewSwitcherTrack = styled.div.withConfig({
|
|
14
14
|
displayName: "Styles__StyledViewSwitcherTrack",
|
|
15
15
|
componentId: "sc-1cg2mte-1"
|
|
16
|
-
})(["", " display:inline-flex;align-items:center;height:32px;padding:3px;border-radius:var(--ac-br-rounded);background-color:var(--color-theme-300);"], BoxSizingStyle);
|
|
16
|
+
})(["", " position:relative;display:inline-flex;align-items:center;height:32px;padding:3px;border-radius:var(--ac-br-rounded);background-color:var(--color-theme-300);"], BoxSizingStyle);
|
|
17
17
|
StyledViewSwitcherTrack.displayName = "StyledViewSwitcherTrack";
|
|
18
18
|
export const StyledViewSwitcherOptions = styled.div.withConfig({
|
|
19
19
|
displayName: "Styles__StyledViewSwitcherOptions",
|
|
@@ -30,65 +30,84 @@ export const StyledViewSwitcherMenuOption = styled.button.withConfig({
|
|
|
30
30
|
componentId: "sc-1cg2mte-4"
|
|
31
31
|
})(["", " display:inline-flex;align-items:center;gap:4px;height:26px;margin:0;padding:0 8px 0 12px;border:0;border-radius:var(--ac-br-rounded);background-color:var(--page-paper-main);box-shadow:var(--shadow-float);color:var(--color-theme-900);font-size:calc(13px * var(--text-scale,1));white-space:nowrap;cursor:pointer;outline:none;svg{flex-shrink:0;fill:var(--color-theme-900);}&:has(.c-view-switcher-menu__icon){padding-left:8px;}.c-view-switcher-menu__values{display:inline-grid;}.c-view-switcher-menu__value{display:inline-flex;grid-area:1 / 1;align-items:center;gap:4px;visibility:hidden;}.c-view-switcher-menu__value[data-selected=\"true\"]{visibility:visible;}.c-view-switcher-menu__icon{display:inline-flex;flex-shrink:0;}.c-view-switcher-menu__icon svg{width:20px;height:20px;}&:focus-visible{box-shadow:0 0 0 2px var(--color-primary);}"], BoxSizingStyle);
|
|
32
32
|
StyledViewSwitcherMenuOption.displayName = "StyledViewSwitcherMenuOption";
|
|
33
|
+
const VIEW_SWITCHER_MENU_REVEAL_MS = 200;
|
|
34
|
+
const VIEW_SWITCHER_MENU_GAP = 8;
|
|
35
|
+
const menuReveal = keyframes(["from{grid-template-columns:0fr;margin-right:-", "px;}"], VIEW_SWITCHER_MENU_GAP);
|
|
36
|
+
const menuConceal = keyframes(["to{grid-template-columns:0fr;margin-right:-", "px;}"], VIEW_SWITCHER_MENU_GAP);
|
|
37
|
+
const menuClip = keyframes(["from,to{overflow:hidden;}"]);
|
|
38
|
+
|
|
39
|
+
// The width opens from nothing, so the controls beside the menu move aside with it.
|
|
40
|
+
export const StyledViewSwitcherMenuRoot = styled(StyledViewSwitcher).withConfig({
|
|
41
|
+
displayName: "Styles__StyledViewSwitcherMenuRoot",
|
|
42
|
+
componentId: "sc-1cg2mte-5"
|
|
43
|
+
})(["display:inline-grid;grid-template-columns:1fr;&[data-animate-in]{animation:", " ", "ms cubic-bezier(0.4,0,0.2,1);}&[data-animate-in] > .c-view-switcher-menu__clip{animation:", " ", "ms;}&[data-leaving]{pointer-events:none;animation:", " ", "ms cubic-bezier(0.4,0,0.2,1) forwards;}&[data-leaving] > .c-view-switcher-menu__clip{overflow:hidden;}@media (prefers-reduced-motion:reduce){&[data-animate-in],&[data-animate-in] > .c-view-switcher-menu__clip,&[data-leaving]{animation:none;}}"], menuReveal, VIEW_SWITCHER_MENU_REVEAL_MS, menuClip, VIEW_SWITCHER_MENU_REVEAL_MS, menuConceal, VIEW_SWITCHER_MENU_REVEAL_MS);
|
|
44
|
+
StyledViewSwitcherMenuRoot.displayName = "StyledViewSwitcherMenuRoot";
|
|
45
|
+
export const StyledViewSwitcherMenuClip = styled.div.withConfig({
|
|
46
|
+
displayName: "Styles__StyledViewSwitcherMenuClip",
|
|
47
|
+
componentId: "sc-1cg2mte-6"
|
|
48
|
+
})(["display:flex;min-width:0;> *{flex-shrink:0;}"]);
|
|
49
|
+
StyledViewSwitcherMenuClip.displayName = "StyledViewSwitcherMenuClip";
|
|
33
50
|
export const StyledViewSwitcherMenuIcon = styled.span.withConfig({
|
|
34
51
|
displayName: "Styles__StyledViewSwitcherMenuIcon",
|
|
35
|
-
componentId: "sc-1cg2mte-
|
|
52
|
+
componentId: "sc-1cg2mte-7"
|
|
36
53
|
})(["display:inline-flex;flex-shrink:0;margin-right:8px;fill:var(--color-theme-900);"]);
|
|
37
54
|
StyledViewSwitcherMenuIcon.displayName = "StyledViewSwitcherMenuIcon";
|
|
38
55
|
export const StyledViewSwitcherMenuList = styled(List).withConfig({
|
|
39
56
|
displayName: "Styles__StyledViewSwitcherMenuList",
|
|
40
|
-
componentId: "sc-1cg2mte-
|
|
57
|
+
componentId: "sc-1cg2mte-8"
|
|
41
58
|
})(["padding:8px 0;"]);
|
|
42
59
|
StyledViewSwitcherMenuList.displayName = "StyledViewSwitcherMenuList";
|
|
43
60
|
export const StyledViewSwitcherMenuLabel = styled.span.withConfig({
|
|
44
61
|
displayName: "Styles__StyledViewSwitcherMenuLabel",
|
|
45
|
-
componentId: "sc-1cg2mte-
|
|
62
|
+
componentId: "sc-1cg2mte-9"
|
|
46
63
|
})(["flex:1;&[data-selected=\"true\"]{font-weight:bold;color:var(--color-primary);}"]);
|
|
47
64
|
StyledViewSwitcherMenuLabel.displayName = "StyledViewSwitcherMenuLabel";
|
|
48
|
-
const promptIn = keyframes(["from{
|
|
49
|
-
const promptOut = keyframes(["to{
|
|
65
|
+
const promptIn = keyframes(["from{opacity:0;}"]);
|
|
66
|
+
const promptOut = keyframes(["to{clip-path:inset(0 0 0 100%);}"]);
|
|
50
67
|
const appliedIn = keyframes(["from{opacity:0;transform:translateY(6px);}"]);
|
|
51
68
|
const appliedIcon = keyframes(["from{opacity:0;transform:scale(0.4);}60%{transform:scale(1.2);}"]);
|
|
52
69
|
export const StyledViewSwitcherPromptTitle = styled.span.withConfig({
|
|
53
70
|
displayName: "Styles__StyledViewSwitcherPromptTitle",
|
|
54
|
-
componentId: "sc-1cg2mte-
|
|
71
|
+
componentId: "sc-1cg2mte-10"
|
|
55
72
|
})(["position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;"]);
|
|
56
73
|
StyledViewSwitcherPromptTitle.displayName = "StyledViewSwitcherPromptTitle";
|
|
57
74
|
const PROMPT_EASE = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
58
75
|
const APPLIED_SWAP_MS = 160;
|
|
76
|
+
|
|
77
|
+
// The offer covers the buttons and keeps the width of the switcher, so nothing beside it moves.
|
|
59
78
|
export const StyledViewSwitcherPrompt = styled.div.withConfig({
|
|
60
79
|
displayName: "Styles__StyledViewSwitcherPrompt",
|
|
61
|
-
componentId: "sc-1cg2mte-
|
|
62
|
-
})(["", "
|
|
80
|
+
componentId: "sc-1cg2mte-11"
|
|
81
|
+
})(["", " position:absolute;top:3px;right:3px;bottom:3px;z-index:1;display:flex;min-width:calc(100% - 6px);animation:", " ", "ms ", ";&[data-phase=\"applying\"],&[data-phase=\"applied\"]{pointer-events:none;}&[data-phase=\"applying\"] .c-view-switcher__prompt-pill{opacity:0.7;}.c-view-switcher__action,.c-view-switcher__line,.c-view-switcher__dismiss{transition:opacity ", "ms ", ",transform ", "ms ", ",visibility 0s linear ", "ms,background-color 150ms ease;}&[data-confirmed] .c-view-switcher__action,&[data-confirmed] .c-view-switcher__line,&[data-confirmed] .c-view-switcher__dismiss{visibility:hidden;opacity:0;transform:translateY(-6px);}&[data-phase=\"leaving\"]{pointer-events:none;animation:", " ", "ms ", " forwards;}@media (prefers-reduced-motion:reduce){animation:none;&[data-phase=\"leaving\"]{animation:none;}.c-view-switcher__action,.c-view-switcher__line,.c-view-switcher__dismiss,.c-view-switcher__prompt-pill{transition:none;}}"], BoxSizingStyle, promptIn, VIEW_SWITCHER_LEAVE_MS, PROMPT_EASE, APPLIED_SWAP_MS, PROMPT_EASE, APPLIED_SWAP_MS, PROMPT_EASE, APPLIED_SWAP_MS, promptOut, VIEW_SWITCHER_LEAVE_MS, PROMPT_EASE);
|
|
63
82
|
StyledViewSwitcherPrompt.displayName = "StyledViewSwitcherPrompt";
|
|
64
83
|
export const StyledViewSwitcherPromptClip = styled.div.withConfig({
|
|
65
84
|
displayName: "Styles__StyledViewSwitcherPromptClip",
|
|
66
|
-
componentId: "sc-1cg2mte-
|
|
67
|
-
})(["display:flex;min-width:0;
|
|
85
|
+
componentId: "sc-1cg2mte-12"
|
|
86
|
+
})(["display:flex;flex:1;min-width:0;"]);
|
|
68
87
|
StyledViewSwitcherPromptClip.displayName = "StyledViewSwitcherPromptClip";
|
|
69
88
|
export const StyledViewSwitcherPromptPill = styled.div.withConfig({
|
|
70
89
|
displayName: "Styles__StyledViewSwitcherPromptPill",
|
|
71
|
-
componentId: "sc-1cg2mte-
|
|
72
|
-
})(["", " position:relative;display:inline-flex;flex
|
|
90
|
+
componentId: "sc-1cg2mte-13"
|
|
91
|
+
})(["", " position:relative;display:inline-flex;flex:1;align-items:center;justify-content:center;height:26px;border-radius:var(--ac-br-rounded);background-color:var(--color-primary-opaque-300);color:var(--color-primary);font-size:calc(0.75rem * var(--text-scale,1));font-weight:500;white-space:nowrap;transition:opacity 150ms ease;"], BoxSizingStyle);
|
|
73
92
|
StyledViewSwitcherPromptPill.displayName = "StyledViewSwitcherPromptPill";
|
|
74
93
|
export const StyledViewSwitcherAction = styled.button.withConfig({
|
|
75
94
|
displayName: "Styles__StyledViewSwitcherAction",
|
|
76
|
-
componentId: "sc-1cg2mte-
|
|
95
|
+
componentId: "sc-1cg2mte-14"
|
|
77
96
|
})(["", " display:inline-flex;align-items:center;gap:4px;height:26px;margin:0;padding:0 2px 0 6px;border:0;border-radius:var(--ac-br-rounded);background-color:transparent;color:inherit;font:inherit;cursor:pointer;outline:none;svg{flex-shrink:0;width:16px;height:16px;fill:currentColor;}&:hover{color:var(--color-theme-900);}&:focus-visible{box-shadow:inset 0 0 0 2px var(--color-primary);}"], BoxSizingStyle);
|
|
78
97
|
StyledViewSwitcherAction.displayName = "StyledViewSwitcherAction";
|
|
79
98
|
export const StyledViewSwitcherLine = styled.i.withConfig({
|
|
80
99
|
displayName: "Styles__StyledViewSwitcherLine",
|
|
81
|
-
componentId: "sc-1cg2mte-
|
|
100
|
+
componentId: "sc-1cg2mte-15"
|
|
82
101
|
})(["flex-shrink:0;width:1px;height:14px;margin:0 1px 0 6px;background-color:color-mix(in srgb,var(--color-primary) 35%,transparent);"]);
|
|
83
102
|
StyledViewSwitcherLine.displayName = "StyledViewSwitcherLine";
|
|
84
103
|
export const StyledViewSwitcherDismiss = styled.button.withConfig({
|
|
85
104
|
displayName: "Styles__StyledViewSwitcherDismiss",
|
|
86
|
-
componentId: "sc-1cg2mte-
|
|
105
|
+
componentId: "sc-1cg2mte-16"
|
|
87
106
|
})(["", " display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;width:22px;height:22px;margin:0 2px 0 0;padding:0;border:0;border-radius:50%;background-color:transparent;cursor:pointer;outline:none;transition:background-color 150ms ease;svg{width:16px;height:16px;margin-left:-1px;fill:var(--color-theme-700);}&:hover{background-color:color-mix( in srgb,var(--color-theme-900) 16%,transparent );}&:focus-visible{box-shadow:inset 0 0 0 2px var(--color-primary);}"], BoxSizingStyle);
|
|
88
107
|
StyledViewSwitcherDismiss.displayName = "StyledViewSwitcherDismiss";
|
|
89
108
|
export const StyledViewSwitcherApplied = styled.span.withConfig({
|
|
90
109
|
displayName: "Styles__StyledViewSwitcherApplied",
|
|
91
|
-
componentId: "sc-1cg2mte-
|
|
110
|
+
componentId: "sc-1cg2mte-17"
|
|
92
111
|
})(["position:absolute;inset:0;display:inline-flex;align-items:center;justify-content:center;gap:4px;animation:", " ", "ms ", " 60ms backwards;svg{width:16px;height:16px;fill:currentColor;animation:", " 250ms ease-out 60ms backwards;}@media (prefers-reduced-motion:reduce){animation:none;svg{animation:none;}}"], appliedIn, APPLIED_SWAP_MS, PROMPT_EASE, appliedIcon);
|
|
93
112
|
StyledViewSwitcherApplied.displayName = "StyledViewSwitcherApplied";
|
|
94
113
|
//# sourceMappingURL=Styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Styles.js","names":["styled","keyframes","BoxSizingStyle","List","VIEW_SWITCHER_PROMPT_DELAY_MS","VIEW_SWITCHER_PROMPT_MS","VIEW_SWITCHER_APPLIED_MS","VIEW_SWITCHER_LEAVE_MS","StyledViewSwitcher","div","withConfig","displayName","componentId","StyledViewSwitcherTrack","StyledViewSwitcherOptions","StyledViewSwitcherOption","button","StyledViewSwitcherMenuOption","StyledViewSwitcherMenuIcon","span","StyledViewSwitcherMenuList","StyledViewSwitcherMenuLabel","promptIn","promptOut","appliedIn","appliedIcon","StyledViewSwitcherPromptTitle","PROMPT_EASE","APPLIED_SWAP_MS","StyledViewSwitcherPrompt","StyledViewSwitcherPromptClip","StyledViewSwitcherPromptPill","StyledViewSwitcherAction","StyledViewSwitcherLine","i","StyledViewSwitcherDismiss","StyledViewSwitcherApplied"],"sources":["../../../../src/components/ViewSwitcher/Styles.ts"],"sourcesContent":["import styled, { keyframes } from \"styled-components\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { List } from \"../List\";\n\nexport const VIEW_SWITCHER_PROMPT_DELAY_MS = 100;\nexport const VIEW_SWITCHER_PROMPT_MS = 5000;\nexport const VIEW_SWITCHER_APPLIED_MS = 900;\nexport const VIEW_SWITCHER_LEAVE_MS = 200;\n\nexport const StyledViewSwitcher = styled.div`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n`;\n\nStyledViewSwitcher.displayName = \"StyledViewSwitcher\";\n\nexport const StyledViewSwitcherTrack = styled.div`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n height: 32px;\n padding: 3px;\n border-radius: var(--ac-br-rounded);\n background-color: var(--color-theme-300);\n`;\n\nStyledViewSwitcherTrack.displayName = \"StyledViewSwitcherTrack\";\n\nexport const StyledViewSwitcherOptions = styled.div`\n display: inline-flex;\n align-items: center;\n`;\n\nStyledViewSwitcherOptions.displayName = \"StyledViewSwitcherOptions\";\n\nexport const StyledViewSwitcherOption = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 34px;\n height: 26px;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: transparent;\n cursor: pointer;\n outline: none;\n transition: background-color 150ms ease, box-shadow 150ms ease;\n\n svg {\n width: 20px;\n height: 20px;\n fill: var(--color-theme-700);\n }\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-theme-900) 16%,\n transparent\n );\n }\n\n &[aria-checked=\"true\"] {\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-float);\n cursor: default;\n\n svg {\n fill: var(--color-theme-900);\n }\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherOption.displayName = \"StyledViewSwitcherOption\";\n\nexport const StyledViewSwitcherMenuOption = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 26px;\n margin: 0;\n padding: 0 8px 0 12px;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-float);\n color: var(--color-theme-900);\n font-size: calc(13px * var(--text-scale, 1));\n white-space: nowrap;\n cursor: pointer;\n outline: none;\n\n svg {\n flex-shrink: 0;\n fill: var(--color-theme-900);\n }\n\n &:has(.c-view-switcher-menu__icon) {\n padding-left: 8px;\n }\n\n .c-view-switcher-menu__values {\n display: inline-grid;\n }\n\n .c-view-switcher-menu__value {\n display: inline-flex;\n grid-area: 1 / 1;\n align-items: center;\n gap: 4px;\n visibility: hidden;\n }\n\n .c-view-switcher-menu__value[data-selected=\"true\"] {\n visibility: visible;\n }\n\n .c-view-switcher-menu__icon {\n display: inline-flex;\n flex-shrink: 0;\n }\n\n .c-view-switcher-menu__icon svg {\n width: 20px;\n height: 20px;\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherMenuOption.displayName = \"StyledViewSwitcherMenuOption\";\n\nexport const StyledViewSwitcherMenuIcon = styled.span`\n display: inline-flex;\n flex-shrink: 0;\n margin-right: 8px;\n fill: var(--color-theme-900);\n`;\n\nStyledViewSwitcherMenuIcon.displayName = \"StyledViewSwitcherMenuIcon\";\n\nexport const StyledViewSwitcherMenuList = styled(List)`\n padding: 8px 0;\n`;\n\nStyledViewSwitcherMenuList.displayName = \"StyledViewSwitcherMenuList\";\n\nexport const StyledViewSwitcherMenuLabel = styled.span`\n flex: 1;\n\n &[data-selected=\"true\"] {\n font-weight: bold;\n color: var(--color-primary);\n }\n`;\n\nStyledViewSwitcherMenuLabel.displayName = \"StyledViewSwitcherMenuLabel\";\n\nconst promptIn = keyframes`\n from {\n grid-template-columns: 0fr;\n opacity: 0;\n }\n`;\n\nconst promptOut = keyframes`\n to {\n grid-template-columns: 0fr;\n opacity: 0;\n }\n`;\n\nconst appliedIn = keyframes`\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n`;\n\nconst appliedIcon = keyframes`\n from {\n opacity: 0;\n transform: scale(0.4);\n }\n 60% {\n transform: scale(1.2);\n }\n`;\n\nexport const StyledViewSwitcherPromptTitle = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n`;\n\nStyledViewSwitcherPromptTitle.displayName = \"StyledViewSwitcherPromptTitle\";\n\nconst PROMPT_EASE = \"cubic-bezier(0.4, 0, 0.2, 1)\";\nconst APPLIED_SWAP_MS = 160;\n\nexport const StyledViewSwitcherPrompt = styled.div`\n ${BoxSizingStyle}\n display: grid;\n flex-shrink: 0;\n grid-template-columns: 1fr;\n animation: ${promptIn} ${VIEW_SWITCHER_LEAVE_MS}ms ${PROMPT_EASE};\n\n &[data-phase=\"applying\"],\n &[data-phase=\"applied\"] {\n pointer-events: none;\n }\n\n &[data-phase=\"applying\"] .c-view-switcher__prompt-pill {\n opacity: 0.7;\n }\n\n .c-view-switcher__action,\n .c-view-switcher__line,\n .c-view-switcher__dismiss {\n transition: opacity ${APPLIED_SWAP_MS}ms ${PROMPT_EASE},\n transform ${APPLIED_SWAP_MS}ms ${PROMPT_EASE},\n visibility 0s linear ${APPLIED_SWAP_MS}ms, background-color 150ms ease;\n }\n\n &[data-confirmed] .c-view-switcher__action,\n &[data-confirmed] .c-view-switcher__line,\n &[data-confirmed] .c-view-switcher__dismiss {\n visibility: hidden;\n opacity: 0;\n transform: translateY(-6px);\n }\n\n &[data-phase=\"leaving\"] {\n pointer-events: none;\n animation: ${promptOut} ${VIEW_SWITCHER_LEAVE_MS}ms ${PROMPT_EASE} forwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n animation: none;\n\n &[data-phase=\"leaving\"] {\n animation: none;\n }\n\n .c-view-switcher__action,\n .c-view-switcher__line,\n .c-view-switcher__dismiss,\n .c-view-switcher__prompt-pill {\n transition: none;\n }\n }\n`;\n\nStyledViewSwitcherPrompt.displayName = \"StyledViewSwitcherPrompt\";\n\nexport const StyledViewSwitcherPromptClip = styled.div`\n display: flex;\n min-width: 0;\n overflow: hidden;\n`;\n\nStyledViewSwitcherPromptClip.displayName = \"StyledViewSwitcherPromptClip\";\n\nexport const StyledViewSwitcherPromptPill = styled.div`\n ${BoxSizingStyle}\n position: relative;\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n height: 26px;\n margin-right: 2px;\n border-radius: var(--ac-br-rounded);\n background-color: var(--color-primary-opaque-300);\n color: var(--color-primary);\n font-size: calc(0.75rem * var(--text-scale, 1));\n font-weight: 500;\n white-space: nowrap;\n transition: opacity 150ms ease;\n`;\n\nStyledViewSwitcherPromptPill.displayName = \"StyledViewSwitcherPromptPill\";\n\nexport const StyledViewSwitcherAction = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 26px;\n margin: 0;\n padding: 0 2px 0 6px;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n outline: none;\n\n svg {\n flex-shrink: 0;\n width: 16px;\n height: 16px;\n fill: currentColor;\n }\n\n &:hover {\n color: var(--color-theme-900);\n }\n\n &:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherAction.displayName = \"StyledViewSwitcherAction\";\n\nexport const StyledViewSwitcherLine = styled.i`\n flex-shrink: 0;\n width: 1px;\n height: 14px;\n margin: 0 1px 0 6px;\n background-color: color-mix(in srgb, var(--color-primary) 35%, transparent);\n`;\n\nStyledViewSwitcherLine.displayName = \"StyledViewSwitcherLine\";\n\nexport const StyledViewSwitcherDismiss = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n margin: 0 2px 0 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background-color: transparent;\n cursor: pointer;\n outline: none;\n transition: background-color 150ms ease;\n\n svg {\n width: 16px;\n height: 16px;\n margin-left: -1px;\n fill: var(--color-theme-700);\n }\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-theme-900) 16%,\n transparent\n );\n }\n\n &:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherDismiss.displayName = \"StyledViewSwitcherDismiss\";\n\nexport const StyledViewSwitcherApplied = styled.span`\n position: absolute;\n inset: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n animation: ${appliedIn} ${APPLIED_SWAP_MS}ms ${PROMPT_EASE} 60ms backwards;\n\n svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n animation: ${appliedIcon} 250ms ease-out 60ms backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n animation: none;\n\n svg {\n animation: none;\n }\n }\n`;\n\nStyledViewSwitcherApplied.displayName = \"StyledViewSwitcherApplied\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,SAAS,QAAQ,mBAAmB;AAErD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,IAAI,QAAQ,SAAS;AAE9B,OAAO,MAAMC,6BAA6B,GAAG,GAAG;AAChD,OAAO,MAAMC,uBAAuB,GAAG,IAAI;AAC3C,OAAO,MAAMC,wBAAwB,GAAG,GAAG;AAC3C,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AAEzC,OAAO,MAAMC,kBAAkB,GAAGR,MAAM,CAACS,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,gDACxCV,cAAc,CAGjB;AAEDM,kBAAkB,CAACG,WAAW,GAAG,oBAAoB;AAErD,OAAO,MAAME,uBAAuB,GAAGb,MAAM,CAACS,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,wJAC7CV,cAAc,CAOjB;AAEDW,uBAAuB,CAACF,WAAW,GAAG,yBAAyB;AAE/D,OAAO,MAAMG,yBAAyB,GAAGd,MAAM,CAACS,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,+CAGlD;AAEDE,yBAAyB,CAACH,WAAW,GAAG,2BAA2B;AAEnE,OAAO,MAAMI,wBAAwB,GAAGf,MAAM,CAACgB,MAAM,CAAAN,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,goBACjDV,cAAc,CA2CjB;AAEDa,wBAAwB,CAACJ,WAAW,GAAG,0BAA0B;AAEjE,OAAO,MAAMM,4B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WITCHER_PROMPT_MS","VIEW_SWITCHER_APPLIED_MS","VIEW_SWITCHER_LEAVE_MS","StyledViewSwitcher","div","withConfig","displayName","componentId","StyledViewSwitcherTrack","StyledViewSwitcherOptions","StyledViewSwitcherOption","button","StyledViewSwitcherMenuOption","VIEW_SWITCHER_MENU_REVEAL_MS","VIEW_SWITCHER_MENU_GAP","menuReveal","menuConceal","menuClip","StyledViewSwitcherMenuRoot","StyledViewSwitcherMenuClip","StyledViewSwitcherMenuIcon","span","StyledViewSwitcherMenuList","StyledViewSwitcherMenuLabel","promptIn","promptOut","appliedIn","appliedIcon","StyledViewSwitcherPromptTitle","PROMPT_EASE","APPLIED_SWAP_MS","StyledViewSwitcherPrompt","StyledViewSwitcherPromptClip","StyledViewSwitcherPromptPill","StyledViewSwitcherAction","StyledViewSwitcherLine","i","StyledViewSwitcherDismiss","StyledViewSwitcherApplied"],"sources":["../../../../src/components/ViewSwitcher/Styles.ts"],"sourcesContent":["import styled, { keyframes } from \"styled-components\";\n\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { List } from \"../List\";\n\nexport const VIEW_SWITCHER_PROMPT_DELAY_MS = 100;\nexport const VIEW_SWITCHER_PROMPT_MS = 5000;\nexport const VIEW_SWITCHER_APPLIED_MS = 900;\nexport const VIEW_SWITCHER_LEAVE_MS = 200;\n\nexport const StyledViewSwitcher = styled.div`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n`;\n\nStyledViewSwitcher.displayName = \"StyledViewSwitcher\";\n\nexport const StyledViewSwitcherTrack = styled.div`\n ${BoxSizingStyle}\n position: relative;\n display: inline-flex;\n align-items: center;\n height: 32px;\n padding: 3px;\n border-radius: var(--ac-br-rounded);\n background-color: var(--color-theme-300);\n`;\n\nStyledViewSwitcherTrack.displayName = \"StyledViewSwitcherTrack\";\n\nexport const StyledViewSwitcherOptions = styled.div`\n display: inline-flex;\n align-items: center;\n`;\n\nStyledViewSwitcherOptions.displayName = \"StyledViewSwitcherOptions\";\n\nexport const StyledViewSwitcherOption = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 34px;\n height: 26px;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: transparent;\n cursor: pointer;\n outline: none;\n transition: background-color 150ms ease, box-shadow 150ms ease;\n\n svg {\n width: 20px;\n height: 20px;\n fill: var(--color-theme-700);\n }\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-theme-900) 16%,\n transparent\n );\n }\n\n &[aria-checked=\"true\"] {\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-float);\n cursor: default;\n\n svg {\n fill: var(--color-theme-900);\n }\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherOption.displayName = \"StyledViewSwitcherOption\";\n\nexport const StyledViewSwitcherMenuOption = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 26px;\n margin: 0;\n padding: 0 8px 0 12px;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: var(--page-paper-main);\n box-shadow: var(--shadow-float);\n color: var(--color-theme-900);\n font-size: calc(13px * var(--text-scale, 1));\n white-space: nowrap;\n cursor: pointer;\n outline: none;\n\n svg {\n flex-shrink: 0;\n fill: var(--color-theme-900);\n }\n\n &:has(.c-view-switcher-menu__icon) {\n padding-left: 8px;\n }\n\n .c-view-switcher-menu__values {\n display: inline-grid;\n }\n\n .c-view-switcher-menu__value {\n display: inline-flex;\n grid-area: 1 / 1;\n align-items: center;\n gap: 4px;\n visibility: hidden;\n }\n\n .c-view-switcher-menu__value[data-selected=\"true\"] {\n visibility: visible;\n }\n\n .c-view-switcher-menu__icon {\n display: inline-flex;\n flex-shrink: 0;\n }\n\n .c-view-switcher-menu__icon svg {\n width: 20px;\n height: 20px;\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherMenuOption.displayName = \"StyledViewSwitcherMenuOption\";\n\nconst VIEW_SWITCHER_MENU_REVEAL_MS = 200;\nconst VIEW_SWITCHER_MENU_GAP = 8;\n\nconst menuReveal = keyframes`\n from {\n grid-template-columns: 0fr;\n margin-right: -${VIEW_SWITCHER_MENU_GAP}px;\n }\n`;\n\nconst menuConceal = keyframes`\n to {\n grid-template-columns: 0fr;\n margin-right: -${VIEW_SWITCHER_MENU_GAP}px;\n }\n`;\n\nconst menuClip = keyframes`\n from,\n to {\n overflow: hidden;\n }\n`;\n\n// The width opens from nothing, so the controls beside the menu move aside with it.\nexport const StyledViewSwitcherMenuRoot = styled(StyledViewSwitcher)`\n display: inline-grid;\n grid-template-columns: 1fr;\n\n &[data-animate-in] {\n animation: ${menuReveal} ${VIEW_SWITCHER_MENU_REVEAL_MS}ms\n cubic-bezier(0.4, 0, 0.2, 1);\n }\n\n &[data-animate-in] > .c-view-switcher-menu__clip {\n animation: ${menuClip} ${VIEW_SWITCHER_MENU_REVEAL_MS}ms;\n }\n\n &[data-leaving] {\n pointer-events: none;\n animation: ${menuConceal} ${VIEW_SWITCHER_MENU_REVEAL_MS}ms\n cubic-bezier(0.4, 0, 0.2, 1) forwards;\n }\n\n &[data-leaving] > .c-view-switcher-menu__clip {\n overflow: hidden;\n }\n\n @media (prefers-reduced-motion: reduce) {\n &[data-animate-in],\n &[data-animate-in] > .c-view-switcher-menu__clip,\n &[data-leaving] {\n animation: none;\n }\n }\n`;\n\nStyledViewSwitcherMenuRoot.displayName = \"StyledViewSwitcherMenuRoot\";\n\nexport const StyledViewSwitcherMenuClip = styled.div`\n display: flex;\n min-width: 0;\n\n > * {\n flex-shrink: 0;\n }\n`;\n\nStyledViewSwitcherMenuClip.displayName = \"StyledViewSwitcherMenuClip\";\n\nexport const StyledViewSwitcherMenuIcon = styled.span`\n display: inline-flex;\n flex-shrink: 0;\n margin-right: 8px;\n fill: var(--color-theme-900);\n`;\n\nStyledViewSwitcherMenuIcon.displayName = \"StyledViewSwitcherMenuIcon\";\n\nexport const StyledViewSwitcherMenuList = styled(List)`\n padding: 8px 0;\n`;\n\nStyledViewSwitcherMenuList.displayName = \"StyledViewSwitcherMenuList\";\n\nexport const StyledViewSwitcherMenuLabel = styled.span`\n flex: 1;\n\n &[data-selected=\"true\"] {\n font-weight: bold;\n color: var(--color-primary);\n }\n`;\n\nStyledViewSwitcherMenuLabel.displayName = \"StyledViewSwitcherMenuLabel\";\n\nconst promptIn = keyframes`\n from {\n opacity: 0;\n }\n`;\n\nconst promptOut = keyframes`\n to {\n clip-path: inset(0 0 0 100%);\n }\n`;\n\nconst appliedIn = keyframes`\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n`;\n\nconst appliedIcon = keyframes`\n from {\n opacity: 0;\n transform: scale(0.4);\n }\n 60% {\n transform: scale(1.2);\n }\n`;\n\nexport const StyledViewSwitcherPromptTitle = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n`;\n\nStyledViewSwitcherPromptTitle.displayName = \"StyledViewSwitcherPromptTitle\";\n\nconst PROMPT_EASE = \"cubic-bezier(0.4, 0, 0.2, 1)\";\nconst APPLIED_SWAP_MS = 160;\n\n// The offer covers the buttons and keeps the width of the switcher, so nothing beside it moves.\nexport const StyledViewSwitcherPrompt = styled.div`\n ${BoxSizingStyle}\n position: absolute;\n top: 3px;\n right: 3px;\n bottom: 3px;\n z-index: 1;\n display: flex;\n min-width: calc(100% - 6px);\n animation: ${promptIn} ${VIEW_SWITCHER_LEAVE_MS}ms ${PROMPT_EASE};\n\n &[data-phase=\"applying\"],\n &[data-phase=\"applied\"] {\n pointer-events: none;\n }\n\n &[data-phase=\"applying\"] .c-view-switcher__prompt-pill {\n opacity: 0.7;\n }\n\n .c-view-switcher__action,\n .c-view-switcher__line,\n .c-view-switcher__dismiss {\n transition: opacity ${APPLIED_SWAP_MS}ms ${PROMPT_EASE},\n transform ${APPLIED_SWAP_MS}ms ${PROMPT_EASE},\n visibility 0s linear ${APPLIED_SWAP_MS}ms, background-color 150ms ease;\n }\n\n &[data-confirmed] .c-view-switcher__action,\n &[data-confirmed] .c-view-switcher__line,\n &[data-confirmed] .c-view-switcher__dismiss {\n visibility: hidden;\n opacity: 0;\n transform: translateY(-6px);\n }\n\n &[data-phase=\"leaving\"] {\n pointer-events: none;\n animation: ${promptOut} ${VIEW_SWITCHER_LEAVE_MS}ms ${PROMPT_EASE} forwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n animation: none;\n\n &[data-phase=\"leaving\"] {\n animation: none;\n }\n\n .c-view-switcher__action,\n .c-view-switcher__line,\n .c-view-switcher__dismiss,\n .c-view-switcher__prompt-pill {\n transition: none;\n }\n }\n`;\n\nStyledViewSwitcherPrompt.displayName = \"StyledViewSwitcherPrompt\";\n\nexport const StyledViewSwitcherPromptClip = styled.div`\n display: flex;\n flex: 1;\n min-width: 0;\n`;\n\nStyledViewSwitcherPromptClip.displayName = \"StyledViewSwitcherPromptClip\";\n\nexport const StyledViewSwitcherPromptPill = styled.div`\n ${BoxSizingStyle}\n position: relative;\n display: inline-flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n height: 26px;\n border-radius: var(--ac-br-rounded);\n background-color: var(--color-primary-opaque-300);\n color: var(--color-primary);\n font-size: calc(0.75rem * var(--text-scale, 1));\n font-weight: 500;\n white-space: nowrap;\n transition: opacity 150ms ease;\n`;\n\nStyledViewSwitcherPromptPill.displayName = \"StyledViewSwitcherPromptPill\";\n\nexport const StyledViewSwitcherAction = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n gap: 4px;\n height: 26px;\n margin: 0;\n padding: 0 2px 0 6px;\n border: 0;\n border-radius: var(--ac-br-rounded);\n background-color: transparent;\n color: inherit;\n font: inherit;\n cursor: pointer;\n outline: none;\n\n svg {\n flex-shrink: 0;\n width: 16px;\n height: 16px;\n fill: currentColor;\n }\n\n &:hover {\n color: var(--color-theme-900);\n }\n\n &:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherAction.displayName = \"StyledViewSwitcherAction\";\n\nexport const StyledViewSwitcherLine = styled.i`\n flex-shrink: 0;\n width: 1px;\n height: 14px;\n margin: 0 1px 0 6px;\n background-color: color-mix(in srgb, var(--color-primary) 35%, transparent);\n`;\n\nStyledViewSwitcherLine.displayName = \"StyledViewSwitcherLine\";\n\nexport const StyledViewSwitcherDismiss = styled.button`\n ${BoxSizingStyle}\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n margin: 0 2px 0 0;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background-color: transparent;\n cursor: pointer;\n outline: none;\n transition: background-color 150ms ease;\n\n svg {\n width: 16px;\n height: 16px;\n margin-left: -1px;\n fill: var(--color-theme-700);\n }\n\n &:hover {\n background-color: color-mix(\n in srgb,\n var(--color-theme-900) 16%,\n transparent\n );\n }\n\n &:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-primary);\n }\n`;\n\nStyledViewSwitcherDismiss.displayName = \"StyledViewSwitcherDismiss\";\n\nexport const StyledViewSwitcherApplied = styled.span`\n position: absolute;\n inset: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n animation: ${appliedIn} ${APPLIED_SWAP_MS}ms ${PROMPT_EASE} 60ms backwards;\n\n svg {\n width: 16px;\n height: 16px;\n fill: currentColor;\n animation: ${appliedIcon} 250ms ease-out 60ms backwards;\n }\n\n @media (prefers-reduced-motion: reduce) {\n animation: none;\n\n svg {\n animation: none;\n }\n }\n`;\n\nStyledViewSwitcherApplied.displayName = \"StyledViewSwitcherApplied\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,SAAS,QAAQ,mBAAmB;AAErD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,IAAI,QAAQ,SAAS;AAE9B,OAAO,MAAMC,6BAA6B,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AA;EAAAC,WAAA;AAAA,yTAOrCmB,SAAS,EAAII,eAAe,EAAMD,WAAW,EAM3CF,WAAW,CAU3B;AAEDW,yBAAyB,CAAChC,WAAW,GAAG,2BAA2B","ignoreList":[]}
|
|
@@ -25,6 +25,8 @@ export interface ViewSwitcherProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
25
25
|
dismissLabel?: string;
|
|
26
26
|
/** Text that confirms the extra action. */
|
|
27
27
|
appliedLabel?: string;
|
|
28
|
+
/** A new value opens the extra action for the checked view, for a change made outside the buttons. */
|
|
29
|
+
offerKey?: string | number;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* @component ViewSwitcher
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSwitcher.d.ts","sourceRoot":"","sources":["../../../../src/components/ViewSwitcher/ViewSwitcher.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,cAAc,EAEd,SAAS,EAMV,MAAM,OAAO,CAAC;AA0Bf,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxD,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,eAAe,CAA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,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,0FA8UxB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["views", "value", "onChange", "aria-label", "onApplyToAll", "applyToAllLabel", "applyToAllTitle", "offerTitle", "dismissLabel", "appliedLabel", "className", "onKeyDown", "onBlur"];
|
|
3
|
+
const _excluded = ["views", "value", "onChange", "aria-label", "onApplyToAll", "applyToAllLabel", "applyToAllTitle", "offerTitle", "dismissLabel", "appliedLabel", "offerKey", "className", "onKeyDown", "onBlur"];
|
|
4
4
|
import React, { forwardRef, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
5
5
|
import classnames from "classnames";
|
|
6
6
|
import { StyledViewSwitcher, StyledViewSwitcherAction, StyledViewSwitcherApplied, StyledViewSwitcherDismiss, StyledViewSwitcherLine, StyledViewSwitcherOption, StyledViewSwitcherOptions, StyledViewSwitcherPrompt, StyledViewSwitcherPromptClip, StyledViewSwitcherPromptPill, StyledViewSwitcherPromptTitle, StyledViewSwitcherTrack, VIEW_SWITCHER_APPLIED_MS, VIEW_SWITCHER_LEAVE_MS, VIEW_SWITCHER_PROMPT_DELAY_MS, VIEW_SWITCHER_PROMPT_MS } from "./Styles";
|
|
@@ -43,6 +43,7 @@ export const ViewSwitcher = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
43
43
|
dismissLabel = _ref$dismissLabel === void 0 ? "Dismiss" : _ref$dismissLabel,
|
|
44
44
|
_ref$appliedLabel = _ref.appliedLabel,
|
|
45
45
|
appliedLabel = _ref$appliedLabel === void 0 ? "Applied" : _ref$appliedLabel,
|
|
46
|
+
offerKey = _ref.offerKey,
|
|
46
47
|
className = _ref.className,
|
|
47
48
|
onKeyDown = _ref.onKeyDown,
|
|
48
49
|
onBlur = _ref.onBlur,
|
|
@@ -94,6 +95,16 @@ export const ViewSwitcher = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
94
95
|
setOfferId(id);
|
|
95
96
|
}
|
|
96
97
|
}, [onApplyToAll, onChange, value]);
|
|
98
|
+
const seenOfferKeyRef = useRef(offerKey);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (seenOfferKeyRef.current === offerKey) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
seenOfferKeyRef.current = offerKey;
|
|
104
|
+
if (value) {
|
|
105
|
+
select(value);
|
|
106
|
+
}
|
|
107
|
+
}, [offerKey, select, value]);
|
|
97
108
|
const isInside = node => {
|
|
98
109
|
var _rootRef$current;
|
|
99
110
|
return Boolean(node && ((_rootRef$current = rootRef.current) == null ? void 0 : _rootRef$current.contains(node)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSwitcher.js","names":["React","forwardRef","useCallback","useEffect","useId","useRef","useState","classnames","StyledViewSwitcher","StyledViewSwitcherAction","StyledViewSwitcherApplied","StyledViewSwitcherDismiss","StyledViewSwitcherLine","StyledViewSwitcherOption","StyledViewSwitcherOptions","StyledViewSwitcherPrompt","StyledViewSwitcherPromptClip","StyledViewSwitcherPromptPill","StyledViewSwitcherPromptTitle","StyledViewSwitcherTrack","VIEW_SWITCHER_APPLIED_MS","VIEW_SWITCHER_LEAVE_MS","VIEW_SWITCHER_PROMPT_DELAY_MS","VIEW_SWITCHER_PROMPT_MS","useForkRef","CheckIcon","CloseSmallIcon","Tooltip","ViewSwitcher","_ref","ref","_views","views","value","onChange","_ref$ariaLabel","ariaLabel","onApplyToAll","_ref$applyToAllLabel","applyToAllLabel","_ref$applyToAllTitle","applyToAllTitle","offerTitle","_ref$dismissLabel","dismissLabel","_ref$appliedLabel","appliedLabel","className","onKeyDown","onBlur","rest","_objectWithoutPropertiesLoose","_excluded","rootRef","handleRootRef","optionRefs","promptRef","_useState","offerId","setOfferId","_useState2","offerPhase","setOfferPhase","_useState3","isConfirmed","setIsConfirmed","offerTitleId","offerIdRef","offerPhaseRef","restoreFocusRef","current","checkedIndex","findIndex","_ref2","id","tabStopId","offerView","find","_ref3","select","isOfferUp","includes","phase","isInside","node","_rootRef$current","Boolean","contains","focusChecked","_optionRefs$current$t","focus","leave","_promptRef$current","document","activeElement","undefined","timer","setTimeout","clearTimeout","leaveOutside","event","target","addEventListener","removeEventListener","handleOptionKeyDown","index","_optionRefs$current$i","last","length","targets","ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End","key","preventDefault","handleRootKeyDown","stopPropagation","handleRootBlur","next","relatedTarget","applyToAll","_promptRef$current2","isApplied","createElement","_extends","role","label","title","placement","type","onClick","map","view","checked","tabIndex","icon","displayName"],"sources":["../../../../src/components/ViewSwitcher/ViewSwitcher.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n forwardRef,\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledViewSwitcher,\n StyledViewSwitcherAction,\n StyledViewSwitcherApplied,\n StyledViewSwitcherDismiss,\n StyledViewSwitcherLine,\n StyledViewSwitcherOption,\n StyledViewSwitcherOptions,\n StyledViewSwitcherPrompt,\n StyledViewSwitcherPromptClip,\n StyledViewSwitcherPromptPill,\n StyledViewSwitcherPromptTitle,\n StyledViewSwitcherTrack,\n VIEW_SWITCHER_APPLIED_MS,\n VIEW_SWITCHER_LEAVE_MS,\n VIEW_SWITCHER_PROMPT_DELAY_MS,\n VIEW_SWITCHER_PROMPT_MS,\n} from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { CheckIcon, CloseSmallIcon } from \"../Icons\";\nimport { Tooltip } from \"../Tooltip\";\n\nexport interface ViewSwitcherView {\n id: string;\n /** View name: the radio's accessible name and its tooltip. */\n label: string;\n /** DS icon element. */\n icon: ReactNode;\n}\n\nexport interface ViewSwitcherProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n views: ViewSwitcherView[];\n /** Id of the checked view. */\n value?: string;\n onChange: (id: string) => void;\n /** Accessible name of the radiogroup. */\n \"aria-label\"?: string;\n /** Turns on the extra action offered after a switch. A result of false shows no confirmation. */\n onApplyToAll?: (id: string) => unknown;\n /** Short visible text of the extra action. */\n applyToAllLabel?: string;\n /** Tooltip and accessible name of the extra action. */\n applyToAllTitle?: string;\n /** Accessible name of the extra action group. Defaults to \"Now in {label}\". */\n offerTitle?: (view: ViewSwitcherView) => ReactNode;\n /** Accessible name of the button that dismisses the extra action. */\n dismissLabel?: string;\n /** Text that confirms the extra action. */\n appliedLabel?: string;\n}\n\n/**\n * @component ViewSwitcher\n * @description\n * Icon-only radiogroup that switches the view of a page. A tooltip shows the view name on hover.\n * With onApplyToAll, a switch or a click on the checked view opens a compact extra action beside the buttons\n * after a short delay, for five seconds.\n *\n * @example\n * <ViewSwitcher\n * aria-label=\"View\"\n * views={[\n * { id: \"list\", label: \"List View\", icon: <ViewListIcon /> },\n * { id: \"grid\", label: \"Grid View\", icon: <ViewGridIcon /> },\n * ]}\n * value={view}\n * onChange={setView}\n * onApplyToAll={applyToAllProjects}\n * />\n */\nexport const ViewSwitcher = forwardRef<HTMLDivElement, ViewSwitcherProps>(\n (\n {\n views,\n value,\n onChange,\n \"aria-label\": ariaLabel = \"View\",\n onApplyToAll,\n applyToAllLabel = \"All Projects\",\n applyToAllTitle = \"Apply to All Projects\",\n offerTitle,\n dismissLabel = \"Dismiss\",\n appliedLabel = \"Applied\",\n className,\n onKeyDown,\n onBlur,\n ...rest\n },\n ref\n ) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const handleRootRef = useForkRef(rootRef, ref);\n const optionRefs = useRef<Record<string, HTMLButtonElement | null>>({});\n const promptRef = useRef<HTMLDivElement | null>(null);\n const [offerId, setOfferId] = useState<string | null>(null);\n const [offerPhase, setOfferPhase] = useState<\n \"waiting\" | \"open\" | \"applying\" | \"applied\" | \"leaving\"\n >(\"waiting\");\n const [isConfirmed, setIsConfirmed] = useState(false);\n const offerTitleId = useId();\n const offerIdRef = useRef(offerId);\n const offerPhaseRef = useRef(offerPhase);\n const restoreFocusRef = useRef(false);\n\n offerIdRef.current = offerId;\n offerPhaseRef.current = offerPhase;\n\n const checkedIndex = views.findIndex(({ id }) => id === value);\n const tabStopId = views[checkedIndex >= 0 ? checkedIndex : 0]?.id;\n const offerView = views.find(({ id }) => id === offerId);\n\n const select = useCallback(\n (id: string) => {\n // A click on the checked view also offers the extra action.\n if (id === value) {\n const isOfferUp =\n offerIdRef.current &&\n [\"open\", \"applying\", \"applied\"].includes(offerPhaseRef.current);\n\n if (onApplyToAll && !isOfferUp) {\n setOfferPhase(\"waiting\");\n setIsConfirmed(false);\n setOfferId(id);\n }\n\n return;\n }\n\n onChange(id);\n\n if (onApplyToAll) {\n // An open prompt stays for the next switch, and only a new one waits.\n setOfferPhase((phase) =>\n offerIdRef.current && phase === \"open\" ? \"open\" : \"waiting\"\n );\n setIsConfirmed(false);\n setOfferId(id);\n }\n },\n [onApplyToAll, onChange, value]\n );\n\n const isInside = (node: Node | null): boolean =>\n Boolean(node && rootRef.current?.contains(node));\n\n const focusChecked = useCallback(() => {\n if (tabStopId) {\n optionRefs.current[tabStopId]?.focus();\n }\n }, [tabStopId]);\n\n const leave = useCallback((): void => {\n restoreFocusRef.current = Boolean(\n promptRef.current?.contains(document.activeElement)\n );\n\n if (offerPhaseRef.current === \"waiting\") {\n setOfferId(null);\n\n return;\n }\n\n setOfferPhase(\"leaving\");\n }, []);\n\n useEffect(() => {\n if (!offerId && restoreFocusRef.current) {\n restoreFocusRef.current = false;\n focusChecked();\n }\n }, [focusChecked, offerId]);\n\n useEffect(() => {\n if (!offerId || offerPhase === \"applying\") {\n return undefined;\n }\n\n if (offerPhase === \"waiting\") {\n const timer = setTimeout(\n () => setOfferPhase(\"open\"),\n VIEW_SWITCHER_PROMPT_DELAY_MS\n );\n\n return () => clearTimeout(timer);\n }\n\n if (offerPhase === \"leaving\") {\n const timer = setTimeout(\n () => setOfferId(null),\n VIEW_SWITCHER_LEAVE_MS\n );\n\n return () => clearTimeout(timer);\n }\n\n const timer = setTimeout(\n leave,\n offerPhase === \"applied\"\n ? VIEW_SWITCHER_APPLIED_MS\n : VIEW_SWITCHER_PROMPT_MS\n );\n\n return () => clearTimeout(timer);\n }, [leave, offerId, offerPhase]);\n\n useEffect(() => {\n if (!offerId) {\n return undefined;\n }\n\n const leaveOutside = (event: MouseEvent): void => {\n if (!isInside(event.target as Node)) {\n leave();\n }\n };\n\n document.addEventListener(\"mousedown\", leaveOutside);\n\n return () => document.removeEventListener(\"mousedown\", leaveOutside);\n }, [leave, offerId]);\n\n const handleOptionKeyDown = (\n event: KeyboardEvent<HTMLButtonElement>,\n index: number\n ): void => {\n const last = views.length - 1;\n const targets: Record<string, number> = {\n ArrowRight: index === last ? 0 : index + 1,\n ArrowDown: index === last ? 0 : index + 1,\n ArrowLeft: index === 0 ? last : index - 1,\n ArrowUp: index === 0 ? last : index - 1,\n Home: 0,\n End: last,\n };\n const target = targets[event.key];\n\n if (target === undefined) {\n return;\n }\n\n event.preventDefault();\n\n const { id } = views[target];\n\n optionRefs.current[id]?.focus();\n select(id);\n };\n\n const handleRootKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n onKeyDown?.(event);\n\n if (event.key !== \"Escape\" || !offerId) {\n return;\n }\n\n if (offerPhase === \"waiting\") {\n leave();\n\n return;\n }\n\n // A native dialog around the switcher would take an Escape that is not prevented as its own close request.\n event.preventDefault();\n event.stopPropagation();\n leave();\n };\n\n const handleRootBlur = (event: FocusEvent<HTMLDivElement>): void => {\n onBlur?.(event);\n\n const next = event.relatedTarget as Node | null;\n\n if (offerId && next && !isInside(next)) {\n leave();\n }\n };\n\n const applyToAll = async (): Promise<void> => {\n if (!offerId || !onApplyToAll || offerPhase !== \"open\") {\n return;\n }\n\n let isApplied = false;\n\n // The action hides while it confirms, so the focus goes back to the views now.\n if (promptRef.current?.contains(document.activeElement)) {\n focusChecked();\n }\n\n setOfferPhase(\"applying\");\n\n try {\n isApplied = (await onApplyToAll(offerId)) !== false;\n } finally {\n if (offerIdRef.current === offerId) {\n setIsConfirmed(isApplied);\n setOfferPhase(isApplied ? \"applied\" : \"leaving\");\n }\n }\n };\n\n return (\n <StyledViewSwitcher\n ref={handleRootRef}\n className={classnames(\"c-view-switcher\", className)}\n onKeyDown={handleRootKeyDown}\n onBlur={handleRootBlur}\n {...rest}\n >\n <StyledViewSwitcherTrack className=\"c-view-switcher__track\">\n {offerView && offerPhase !== \"waiting\" ? (\n <StyledViewSwitcherPrompt\n ref={promptRef}\n role=\"group\"\n aria-labelledby={offerTitleId}\n className=\"c-view-switcher__prompt\"\n data-phase={offerPhase}\n data-confirmed={isConfirmed || undefined}\n >\n <StyledViewSwitcherPromptTitle id={offerTitleId}>\n {offerTitle\n ? offerTitle(offerView)\n : `Now in ${offerView.label}`}\n </StyledViewSwitcherPromptTitle>\n <StyledViewSwitcherPromptClip>\n <StyledViewSwitcherPromptPill className=\"c-view-switcher__prompt-pill\">\n <Tooltip title={applyToAllTitle} placement=\"bottom\">\n <StyledViewSwitcherAction\n type=\"button\"\n aria-label={applyToAllTitle}\n className=\"c-view-switcher__action\"\n onClick={applyToAll}\n >\n <CheckIcon />\n {applyToAllLabel}\n </StyledViewSwitcherAction>\n </Tooltip>\n <StyledViewSwitcherLine className=\"c-view-switcher__line\" />\n <Tooltip title={dismissLabel} placement=\"bottom\">\n <StyledViewSwitcherDismiss\n type=\"button\"\n aria-label={dismissLabel}\n className=\"c-view-switcher__dismiss\"\n onClick={leave}\n >\n <CloseSmallIcon />\n </StyledViewSwitcherDismiss>\n </Tooltip>\n {isConfirmed ? (\n <StyledViewSwitcherApplied role=\"status\">\n <CheckIcon />\n {appliedLabel}\n </StyledViewSwitcherApplied>\n ) : null}\n </StyledViewSwitcherPromptPill>\n </StyledViewSwitcherPromptClip>\n </StyledViewSwitcherPrompt>\n ) : null}\n <StyledViewSwitcherOptions role=\"radiogroup\" aria-label={ariaLabel}>\n {views.map((view, index) => {\n const checked = view.id === value;\n\n return (\n <Tooltip key={view.id} title={view.label} placement=\"bottom\">\n <StyledViewSwitcherOption\n ref={(node: HTMLButtonElement | null) => {\n optionRefs.current[view.id] = node;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-label={view.label}\n tabIndex={view.id === tabStopId ? 0 : -1}\n className=\"c-view-switcher__option\"\n onClick={() => select(view.id)}\n onKeyDown={(event: KeyboardEvent<HTMLButtonElement>) =>\n handleOptionKeyDown(event, index)\n }\n >\n {view.icon}\n </StyledViewSwitcherOption>\n </Tooltip>\n );\n })}\n </StyledViewSwitcherOptions>\n </StyledViewSwitcherTrack>\n </StyledViewSwitcher>\n );\n }\n);\n\nViewSwitcher.displayName = \"ViewSwitcher\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAEVC,UAAU,EAIVC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB,EACzBC,sBAAsB,EACtBC,wBAAwB,EACxBC,yBAAyB,EACzBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,wBAAwB,EACxBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,uBAAuB,QAClB,UAAU;AACjB,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,SAAS,EAAEC,cAAc,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,YAAY;AAgCpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OA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,CAAE;MAC/B1B,SAAS,EAAGoD,KAAuC,IACjDI,mBAAmB,CAACJ,KAAK,EAAEK,KAAK;IACjC,GAEA8B,IAAI,CAACG,IACkB,CACnB,CAAC;EAEd,CAAC,CACwB,CACJ,CACP,CAAC;AAEzB,CACF,CAAC;AAED9G,YAAY,CAAC+G,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ViewSwitcher.js","names":["React","forwardRef","useCallback","useEffect","useId","useRef","useState","classnames","StyledViewSwitcher","StyledViewSwitcherAction","StyledViewSwitcherApplied","StyledViewSwitcherDismiss","StyledViewSwitcherLine","StyledViewSwitcherOption","StyledViewSwitcherOptions","StyledViewSwitcherPrompt","StyledViewSwitcherPromptClip","StyledViewSwitcherPromptPill","StyledViewSwitcherPromptTitle","StyledViewSwitcherTrack","VIEW_SWITCHER_APPLIED_MS","VIEW_SWITCHER_LEAVE_MS","VIEW_SWITCHER_PROMPT_DELAY_MS","VIEW_SWITCHER_PROMPT_MS","useForkRef","CheckIcon","CloseSmallIcon","Tooltip","ViewSwitcher","_ref","ref","_views","views","value","onChange","_ref$ariaLabel","ariaLabel","onApplyToAll","_ref$applyToAllLabel","applyToAllLabel","_ref$applyToAllTitle","applyToAllTitle","offerTitle","_ref$dismissLabel","dismissLabel","_ref$appliedLabel","appliedLabel","offerKey","className","onKeyDown","onBlur","rest","_objectWithoutPropertiesLoose","_excluded","rootRef","handleRootRef","optionRefs","promptRef","_useState","offerId","setOfferId","_useState2","offerPhase","setOfferPhase","_useState3","isConfirmed","setIsConfirmed","offerTitleId","offerIdRef","offerPhaseRef","restoreFocusRef","current","checkedIndex","findIndex","_ref2","id","tabStopId","offerView","find","_ref3","select","isOfferUp","includes","phase","seenOfferKeyRef","isInside","node","_rootRef$current","Boolean","contains","focusChecked","_optionRefs$current$t","focus","leave","_promptRef$current","document","activeElement","undefined","timer","setTimeout","clearTimeout","leaveOutside","event","target","addEventListener","removeEventListener","handleOptionKeyDown","index","_optionRefs$current$i","last","length","targets","ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End","key","preventDefault","handleRootKeyDown","stopPropagation","handleRootBlur","next","relatedTarget","applyToAll","_promptRef$current2","isApplied","createElement","_extends","role","label","title","placement","type","onClick","map","view","checked","tabIndex","icon","displayName"],"sources":["../../../../src/components/ViewSwitcher/ViewSwitcher.tsx"],"sourcesContent":["import React, {\n FocusEvent,\n forwardRef,\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledViewSwitcher,\n StyledViewSwitcherAction,\n StyledViewSwitcherApplied,\n StyledViewSwitcherDismiss,\n StyledViewSwitcherLine,\n StyledViewSwitcherOption,\n StyledViewSwitcherOptions,\n StyledViewSwitcherPrompt,\n StyledViewSwitcherPromptClip,\n StyledViewSwitcherPromptPill,\n StyledViewSwitcherPromptTitle,\n StyledViewSwitcherTrack,\n VIEW_SWITCHER_APPLIED_MS,\n VIEW_SWITCHER_LEAVE_MS,\n VIEW_SWITCHER_PROMPT_DELAY_MS,\n VIEW_SWITCHER_PROMPT_MS,\n} from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { CheckIcon, CloseSmallIcon } from \"../Icons\";\nimport { Tooltip } from \"../Tooltip\";\n\nexport interface ViewSwitcherView {\n id: string;\n /** View name: the radio's accessible name and its tooltip. */\n label: string;\n /** DS icon element. */\n icon: ReactNode;\n}\n\nexport interface ViewSwitcherProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n views: ViewSwitcherView[];\n /** Id of the checked view. */\n value?: string;\n onChange: (id: string) => void;\n /** Accessible name of the radiogroup. */\n \"aria-label\"?: string;\n /** Turns on the extra action offered after a switch. A result of false shows no confirmation. */\n onApplyToAll?: (id: string) => unknown;\n /** Short visible text of the extra action. */\n applyToAllLabel?: string;\n /** Tooltip and accessible name of the extra action. */\n applyToAllTitle?: string;\n /** Accessible name of the extra action group. Defaults to \"Now in {label}\". */\n offerTitle?: (view: ViewSwitcherView) => ReactNode;\n /** Accessible name of the button that dismisses the extra action. */\n dismissLabel?: string;\n /** Text that confirms the extra action. */\n appliedLabel?: string;\n /** A new value opens the extra action for the checked view, for a change made outside the buttons. */\n offerKey?: string | number;\n}\n\n/**\n * @component ViewSwitcher\n * @description\n * Icon-only radiogroup that switches the view of a page. A tooltip shows the view name on hover.\n * With onApplyToAll, a switch or a click on the checked view opens a compact extra action beside the buttons\n * after a short delay, for five seconds.\n *\n * @example\n * <ViewSwitcher\n * aria-label=\"View\"\n * views={[\n * { id: \"list\", label: \"List View\", icon: <ViewListIcon /> },\n * { id: \"grid\", label: \"Grid View\", icon: <ViewGridIcon /> },\n * ]}\n * value={view}\n * onChange={setView}\n * onApplyToAll={applyToAllProjects}\n * />\n */\nexport const ViewSwitcher = forwardRef<HTMLDivElement, ViewSwitcherProps>(\n (\n {\n views,\n value,\n onChange,\n \"aria-label\": ariaLabel = \"View\",\n onApplyToAll,\n applyToAllLabel = \"All Projects\",\n applyToAllTitle = \"Apply to All Projects\",\n offerTitle,\n dismissLabel = \"Dismiss\",\n appliedLabel = \"Applied\",\n offerKey,\n className,\n onKeyDown,\n onBlur,\n ...rest\n },\n ref\n ) => {\n const rootRef = useRef<HTMLDivElement | null>(null);\n const handleRootRef = useForkRef(rootRef, ref);\n const optionRefs = useRef<Record<string, HTMLButtonElement | null>>({});\n const promptRef = useRef<HTMLDivElement | null>(null);\n const [offerId, setOfferId] = useState<string | null>(null);\n const [offerPhase, setOfferPhase] = useState<\n \"waiting\" | \"open\" | \"applying\" | \"applied\" | \"leaving\"\n >(\"waiting\");\n const [isConfirmed, setIsConfirmed] = useState(false);\n const offerTitleId = useId();\n const offerIdRef = useRef(offerId);\n const offerPhaseRef = useRef(offerPhase);\n const restoreFocusRef = useRef(false);\n\n offerIdRef.current = offerId;\n offerPhaseRef.current = offerPhase;\n\n const checkedIndex = views.findIndex(({ id }) => id === value);\n const tabStopId = views[checkedIndex >= 0 ? checkedIndex : 0]?.id;\n const offerView = views.find(({ id }) => id === offerId);\n\n const select = useCallback(\n (id: string) => {\n // A click on the checked view also offers the extra action.\n if (id === value) {\n const isOfferUp =\n offerIdRef.current &&\n [\"open\", \"applying\", \"applied\"].includes(offerPhaseRef.current);\n\n if (onApplyToAll && !isOfferUp) {\n setOfferPhase(\"waiting\");\n setIsConfirmed(false);\n setOfferId(id);\n }\n\n return;\n }\n\n onChange(id);\n\n if (onApplyToAll) {\n // An open prompt stays for the next switch, and only a new one waits.\n setOfferPhase((phase) =>\n offerIdRef.current && phase === \"open\" ? \"open\" : \"waiting\"\n );\n setIsConfirmed(false);\n setOfferId(id);\n }\n },\n [onApplyToAll, onChange, value]\n );\n\n const seenOfferKeyRef = useRef(offerKey);\n\n useEffect(() => {\n if (seenOfferKeyRef.current === offerKey) {\n return;\n }\n\n seenOfferKeyRef.current = offerKey;\n\n if (value) {\n select(value);\n }\n }, [offerKey, select, value]);\n\n const isInside = (node: Node | null): boolean =>\n Boolean(node && rootRef.current?.contains(node));\n\n const focusChecked = useCallback(() => {\n if (tabStopId) {\n optionRefs.current[tabStopId]?.focus();\n }\n }, [tabStopId]);\n\n const leave = useCallback((): void => {\n restoreFocusRef.current = Boolean(\n promptRef.current?.contains(document.activeElement)\n );\n\n if (offerPhaseRef.current === \"waiting\") {\n setOfferId(null);\n\n return;\n }\n\n setOfferPhase(\"leaving\");\n }, []);\n\n useEffect(() => {\n if (!offerId && restoreFocusRef.current) {\n restoreFocusRef.current = false;\n focusChecked();\n }\n }, [focusChecked, offerId]);\n\n useEffect(() => {\n if (!offerId || offerPhase === \"applying\") {\n return undefined;\n }\n\n if (offerPhase === \"waiting\") {\n const timer = setTimeout(\n () => setOfferPhase(\"open\"),\n VIEW_SWITCHER_PROMPT_DELAY_MS\n );\n\n return () => clearTimeout(timer);\n }\n\n if (offerPhase === \"leaving\") {\n const timer = setTimeout(\n () => setOfferId(null),\n VIEW_SWITCHER_LEAVE_MS\n );\n\n return () => clearTimeout(timer);\n }\n\n const timer = setTimeout(\n leave,\n offerPhase === \"applied\"\n ? VIEW_SWITCHER_APPLIED_MS\n : VIEW_SWITCHER_PROMPT_MS\n );\n\n return () => clearTimeout(timer);\n }, [leave, offerId, offerPhase]);\n\n useEffect(() => {\n if (!offerId) {\n return undefined;\n }\n\n const leaveOutside = (event: MouseEvent): void => {\n if (!isInside(event.target as Node)) {\n leave();\n }\n };\n\n document.addEventListener(\"mousedown\", leaveOutside);\n\n return () => document.removeEventListener(\"mousedown\", leaveOutside);\n }, [leave, offerId]);\n\n const handleOptionKeyDown = (\n event: KeyboardEvent<HTMLButtonElement>,\n index: number\n ): void => {\n const last = views.length - 1;\n const targets: Record<string, number> = {\n ArrowRight: index === last ? 0 : index + 1,\n ArrowDown: index === last ? 0 : index + 1,\n ArrowLeft: index === 0 ? last : index - 1,\n ArrowUp: index === 0 ? last : index - 1,\n Home: 0,\n End: last,\n };\n const target = targets[event.key];\n\n if (target === undefined) {\n return;\n }\n\n event.preventDefault();\n\n const { id } = views[target];\n\n optionRefs.current[id]?.focus();\n select(id);\n };\n\n const handleRootKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n onKeyDown?.(event);\n\n if (event.key !== \"Escape\" || !offerId) {\n return;\n }\n\n if (offerPhase === \"waiting\") {\n leave();\n\n return;\n }\n\n // A native dialog around the switcher would take an Escape that is not prevented as its own close request.\n event.preventDefault();\n event.stopPropagation();\n leave();\n };\n\n const handleRootBlur = (event: FocusEvent<HTMLDivElement>): void => {\n onBlur?.(event);\n\n const next = event.relatedTarget as Node | null;\n\n if (offerId && next && !isInside(next)) {\n leave();\n }\n };\n\n const applyToAll = async (): Promise<void> => {\n if (!offerId || !onApplyToAll || offerPhase !== \"open\") {\n return;\n }\n\n let isApplied = false;\n\n // The action hides while it confirms, so the focus goes back to the views now.\n if (promptRef.current?.contains(document.activeElement)) {\n focusChecked();\n }\n\n setOfferPhase(\"applying\");\n\n try {\n isApplied = (await onApplyToAll(offerId)) !== false;\n } finally {\n if (offerIdRef.current === offerId) {\n setIsConfirmed(isApplied);\n setOfferPhase(isApplied ? \"applied\" : \"leaving\");\n }\n }\n };\n\n return (\n <StyledViewSwitcher\n ref={handleRootRef}\n className={classnames(\"c-view-switcher\", className)}\n onKeyDown={handleRootKeyDown}\n onBlur={handleRootBlur}\n {...rest}\n >\n <StyledViewSwitcherTrack className=\"c-view-switcher__track\">\n {offerView && offerPhase !== \"waiting\" ? (\n <StyledViewSwitcherPrompt\n ref={promptRef}\n role=\"group\"\n aria-labelledby={offerTitleId}\n className=\"c-view-switcher__prompt\"\n data-phase={offerPhase}\n data-confirmed={isConfirmed || undefined}\n >\n <StyledViewSwitcherPromptTitle id={offerTitleId}>\n {offerTitle\n ? offerTitle(offerView)\n : `Now in ${offerView.label}`}\n </StyledViewSwitcherPromptTitle>\n <StyledViewSwitcherPromptClip>\n <StyledViewSwitcherPromptPill className=\"c-view-switcher__prompt-pill\">\n <Tooltip title={applyToAllTitle} placement=\"bottom\">\n <StyledViewSwitcherAction\n type=\"button\"\n aria-label={applyToAllTitle}\n className=\"c-view-switcher__action\"\n onClick={applyToAll}\n >\n <CheckIcon />\n {applyToAllLabel}\n </StyledViewSwitcherAction>\n </Tooltip>\n <StyledViewSwitcherLine className=\"c-view-switcher__line\" />\n <Tooltip title={dismissLabel} placement=\"bottom\">\n <StyledViewSwitcherDismiss\n type=\"button\"\n aria-label={dismissLabel}\n className=\"c-view-switcher__dismiss\"\n onClick={leave}\n >\n <CloseSmallIcon />\n </StyledViewSwitcherDismiss>\n </Tooltip>\n {isConfirmed ? (\n <StyledViewSwitcherApplied role=\"status\">\n <CheckIcon />\n {appliedLabel}\n </StyledViewSwitcherApplied>\n ) : null}\n </StyledViewSwitcherPromptPill>\n </StyledViewSwitcherPromptClip>\n </StyledViewSwitcherPrompt>\n ) : null}\n <StyledViewSwitcherOptions role=\"radiogroup\" aria-label={ariaLabel}>\n {views.map((view, index) => {\n const checked = view.id === value;\n\n return (\n <Tooltip key={view.id} title={view.label} placement=\"bottom\">\n <StyledViewSwitcherOption\n ref={(node: HTMLButtonElement | null) => {\n optionRefs.current[view.id] = node;\n }}\n type=\"button\"\n role=\"radio\"\n aria-checked={checked}\n aria-label={view.label}\n tabIndex={view.id === tabStopId ? 0 : -1}\n className=\"c-view-switcher__option\"\n onClick={() => select(view.id)}\n onKeyDown={(event: KeyboardEvent<HTMLButtonElement>) =>\n handleOptionKeyDown(event, index)\n }\n >\n {view.icon}\n </StyledViewSwitcherOption>\n </Tooltip>\n );\n })}\n </StyledViewSwitcherOptions>\n </StyledViewSwitcherTrack>\n </StyledViewSwitcher>\n );\n }\n);\n\nViewSwitcher.displayName = \"ViewSwitcher\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAEVC,UAAU,EAIVC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,kBAAkB,EAClBC,wBAAwB,EACxBC,yBAAyB,EACzBC,yBAAyB,EACzBC,sBAAsB,EACtBC,wBAAwB,EACxBC,yBAAyB,EACzBC,wBAAwB,EACxBC,4BAA4B,EAC5BC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,uBAAuB,EACvBC,wBAAwB,EACxBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,uBAAuB,QAClB,UAAU;AACjB,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,SAAS,EAAEC,cAAc,QAAQ,UAAU;AACpD,SAASC,OAAO,QAAQ,YAAY;AAkCpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,gBAAG3B,UAAU,CACpC,CAAA4B,IAAA,EAkBEC,GAAG,KACA;EAAA,IAAAC,MAAA;EAAA,IAjBDC,KAAK,GAAAH,IAAA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,gBAAcQ,OAAQ;MACtB,cAAYD,IAAI,CAACN,KAAM;MACvBQ,QAAQ,EAAEF,IAAI,CAAC9D,EAAE,KAAKC,SAAS,GAAG,CAAC,GAAG,CAAC,CAAE;MACzC5B,SAAS,EAAC,yBAAyB;MACnCuF,OAAO,EAAEA,CAAA,KAAMvD,MAAM,CAACyD,IAAI,CAAC9D,EAAE,CAAE;MAC/B1B,SAAS,EAAGqD,KAAuC,IACjDI,mBAAmB,CAACJ,KAAK,EAAEK,KAAK;IACjC,GAEA8B,IAAI,CAACG,IACkB,CACnB,CAAC;EAEd,CAAC,CACwB,CACJ,CACP,CAAC;AAEzB,CACF,CAAC;AAEDhH,YAAY,CAACiH,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
@@ -12,6 +12,10 @@ export interface ViewSwitcherMenuProps extends Omit<HTMLAttributes<HTMLDivElemen
|
|
|
12
12
|
onChange: (id: string) => void;
|
|
13
13
|
/** Accessible name of the trigger. The selected option follows it. */
|
|
14
14
|
"aria-label"?: string;
|
|
15
|
+
/** Opens with a clip from zero width when it mounts, and pushes the controls beside it aside. */
|
|
16
|
+
animateIn?: boolean;
|
|
17
|
+
/** Closes with the same clip. The parent removes the menu after it, 200 ms later. */
|
|
18
|
+
leaving?: boolean;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* @component ViewSwitcherMenu
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSwitcherMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ViewSwitcher/ViewSwitcherMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ViewSwitcherMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/ViewSwitcher/ViewSwitcherMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAiB/E,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxD,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAClC,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,8FAoG5B,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["options", "value", "onChange", "aria-label", "className"];
|
|
3
|
+
const _excluded = ["options", "value", "onChange", "aria-label", "animateIn", "leaving", "className"];
|
|
4
4
|
import React, { forwardRef, useState } from "react";
|
|
5
5
|
import classnames from "classnames";
|
|
6
|
-
import {
|
|
6
|
+
import { StyledViewSwitcherMenuClip, StyledViewSwitcherMenuIcon, StyledViewSwitcherMenuLabel, StyledViewSwitcherMenuList, StyledViewSwitcherMenuOption, StyledViewSwitcherMenuRoot, StyledViewSwitcherTrack } from "./Styles";
|
|
7
7
|
import { ArrowDownSmallIcon } from "../Icons";
|
|
8
8
|
import { ListItem } from "../List";
|
|
9
9
|
import { Menu } from "../Menu";
|
|
@@ -31,6 +31,10 @@ export const ViewSwitcherMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
31
31
|
value = _ref.value,
|
|
32
32
|
onChange = _ref.onChange,
|
|
33
33
|
ariaLabel = _ref["aria-label"],
|
|
34
|
+
_ref$animateIn = _ref.animateIn,
|
|
35
|
+
animateIn = _ref$animateIn === void 0 ? false : _ref$animateIn,
|
|
36
|
+
_ref$leaving = _ref.leaving,
|
|
37
|
+
leaving = _ref$leaving === void 0 ? false : _ref$leaving,
|
|
34
38
|
className = _ref.className,
|
|
35
39
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
36
40
|
const _useState = useState(false),
|
|
@@ -40,10 +44,14 @@ export const ViewSwitcherMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
40
44
|
let id = _ref2.id;
|
|
41
45
|
return id === value;
|
|
42
46
|
})) != null ? _options$find : options[0];
|
|
43
|
-
return /*#__PURE__*/React.createElement(
|
|
47
|
+
return /*#__PURE__*/React.createElement(StyledViewSwitcherMenuRoot, _extends({
|
|
44
48
|
ref: ref,
|
|
49
|
+
"data-animate-in": animateIn || undefined,
|
|
50
|
+
"data-leaving": leaving || undefined,
|
|
45
51
|
className: classnames("c-view-switcher-menu", className)
|
|
46
|
-
}, rest), /*#__PURE__*/React.createElement(
|
|
52
|
+
}, rest), /*#__PURE__*/React.createElement(StyledViewSwitcherMenuClip, {
|
|
53
|
+
className: "c-view-switcher-menu__clip"
|
|
54
|
+
}, /*#__PURE__*/React.createElement(Menu, {
|
|
47
55
|
open: open,
|
|
48
56
|
onOpen: () => setOpen(true),
|
|
49
57
|
onClose: () => setOpen(false),
|
|
@@ -87,7 +95,7 @@ export const ViewSwitcherMenu = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
87
95
|
}, icon ? /*#__PURE__*/React.createElement(StyledViewSwitcherMenuIcon, null, icon) : null, /*#__PURE__*/React.createElement(StyledViewSwitcherMenuLabel, {
|
|
88
96
|
"data-selected": id === (selected == null ? void 0 : selected.id)
|
|
89
97
|
}, label));
|
|
90
|
-
}))));
|
|
98
|
+
})))));
|
|
91
99
|
});
|
|
92
100
|
ViewSwitcherMenu.displayName = "ViewSwitcherMenu";
|
|
93
101
|
//# sourceMappingURL=ViewSwitcherMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewSwitcherMenu.js","names":["React","forwardRef","useState","classnames","
|
|
1
|
+
{"version":3,"file":"ViewSwitcherMenu.js","names":["React","forwardRef","useState","classnames","StyledViewSwitcherMenuClip","StyledViewSwitcherMenuIcon","StyledViewSwitcherMenuLabel","StyledViewSwitcherMenuList","StyledViewSwitcherMenuOption","StyledViewSwitcherMenuRoot","StyledViewSwitcherTrack","ArrowDownSmallIcon","ListItem","Menu","ViewSwitcherMenu","_ref","ref","_options$find","options","value","onChange","ariaLabel","_ref$animateIn","animateIn","_ref$leaving","leaving","className","rest","_objectWithoutPropertiesLoose","_excluded","_useState","open","setOpen","selected","find","_ref2","id","createElement","_extends","undefined","onOpen","onClose","position","target","type","label","map","_ref3","icon","key","_ref4","onClick","displayName"],"sources":["../../../../src/components/ViewSwitcher/ViewSwitcherMenu.tsx"],"sourcesContent":["import React, { forwardRef, HTMLAttributes, ReactNode, useState } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledViewSwitcherMenuClip,\n StyledViewSwitcherMenuIcon,\n StyledViewSwitcherMenuLabel,\n StyledViewSwitcherMenuList,\n StyledViewSwitcherMenuOption,\n StyledViewSwitcherMenuRoot,\n StyledViewSwitcherTrack,\n} from \"./Styles\";\nimport { ArrowDownSmallIcon } from \"../Icons\";\nimport { ListItem } from \"../List\";\nimport { Menu } from \"../Menu\";\n\nexport interface ViewSwitcherMenuOption {\n id: string;\n label: string;\n /** DS icon element. */\n icon?: ReactNode;\n}\n\nexport interface ViewSwitcherMenuProps\n extends Omit<HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n options: ViewSwitcherMenuOption[];\n /** Id of the selected option. */\n value?: string;\n onChange: (id: string) => void;\n /** Accessible name of the trigger. The selected option follows it. */\n \"aria-label\"?: string;\n /** Opens with a clip from zero width when it mounts, and pushes the controls beside it aside. */\n animateIn?: boolean;\n /** Closes with the same clip. The parent removes the menu after it, 200 ms later. */\n leaving?: boolean;\n}\n\n/**\n * @component ViewSwitcherMenu\n * @description\n * Second level of a ViewSwitcher: a dropdown with the look of the checked ViewSwitcher option. It\n * shows the icon and the name of the selected option and lists all options with their icons. Its width\n * fits the widest option, so a new selection does not move the controls around it.\n *\n * @example\n * <ViewSwitcherMenu\n * aria-label=\"Group by\"\n * options={[\n * { id: \"start_date\", label: \"Start Date\", icon: <ClockIcon /> },\n * { id: \"date\", label: \"Due Date\", icon: <CalendarIcon /> },\n * ]}\n * value={view}\n * onChange={setView}\n * />\n */\nexport const ViewSwitcherMenu = forwardRef<\n HTMLDivElement,\n ViewSwitcherMenuProps\n>(\n (\n {\n options,\n value,\n onChange,\n \"aria-label\": ariaLabel,\n animateIn = false,\n leaving = false,\n className,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(false);\n const selected = options.find(({ id }) => id === value) ?? options[0];\n\n return (\n <StyledViewSwitcherMenuRoot\n ref={ref}\n data-animate-in={animateIn || undefined}\n data-leaving={leaving || undefined}\n className={classnames(\"c-view-switcher-menu\", className)}\n {...rest}\n >\n <StyledViewSwitcherMenuClip className=\"c-view-switcher-menu__clip\">\n <Menu\n open={open}\n onOpen={() => setOpen(true)}\n onClose={() => setOpen(false)}\n position=\"bottom-end\"\n target={\n <StyledViewSwitcherTrack className=\"c-view-switcher__track\">\n <StyledViewSwitcherMenuOption\n type=\"button\"\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={\n ariaLabel\n ? `${ariaLabel}: ${selected?.label}`\n : selected?.label\n }\n className=\"c-view-switcher-menu__trigger\"\n >\n <span className=\"c-view-switcher-menu__values\">\n {options.map(({ id, label, icon }) => (\n <span\n key={id}\n aria-hidden={id !== selected?.id}\n data-selected={id === selected?.id}\n className=\"c-view-switcher-menu__value\"\n >\n {icon ? (\n <span className=\"c-view-switcher-menu__icon\">\n {icon}\n </span>\n ) : null}\n {label}\n </span>\n ))}\n </span>\n <ArrowDownSmallIcon />\n </StyledViewSwitcherMenuOption>\n </StyledViewSwitcherTrack>\n }\n >\n <StyledViewSwitcherMenuList>\n {options.map(({ id, label, icon }) => (\n <ListItem\n key={id}\n aria-selected={id === selected?.id}\n onClick={() => {\n setOpen(false);\n\n if (id !== value) {\n onChange(id);\n }\n }}\n >\n {icon ? (\n <StyledViewSwitcherMenuIcon>\n {icon}\n </StyledViewSwitcherMenuIcon>\n ) : null}\n <StyledViewSwitcherMenuLabel\n data-selected={id === selected?.id}\n >\n {label}\n </StyledViewSwitcherMenuLabel>\n </ListItem>\n ))}\n </StyledViewSwitcherMenuList>\n </Menu>\n </StyledViewSwitcherMenuClip>\n </StyledViewSwitcherMenuRoot>\n );\n }\n);\n\nViewSwitcherMenu.displayName = \"ViewSwitcherMenu\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAA6BC,QAAQ,QAAQ,OAAO;AAE9E,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,0BAA0B,EAC1BC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,uBAAuB,QAClB,UAAU;AACjB,SAASC,kBAAkB,QAAQ,UAAU;AAC7C,SAASC,QAAQ,QAAQ,SAAS;AAClC,SAASC,IAAI,QAAQ,SAAS;AAuB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,gBAAGb,UAAU,CAIxC,CAAAc,IAAA,EAWEC,GAAG,KACA;EAAA,IAAAC,aAAA;EAAA,IAVDC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,KAAK,GAAAJ,IAAA,CAALI,KAAK;IACLC,QAAQ,GAA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