@economic/taco 1.25.2 → 1.25.3
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/esm/packages/taco/src/components/Header/components/AgreementSelector.js +19 -12
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/MenuButton.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js +26 -22
- package/dist/esm/packages/taco/src/components/Layout/components/Sidebar.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js +1 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
- package/dist/taco.cjs.development.js +46 -35
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -119,18 +119,25 @@ const filterBySearchValue = search => agreement => {
|
|
|
119
119
|
const isCurrentAgreement = (agreement, currentAgreement) => {
|
|
120
120
|
return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;
|
|
121
121
|
};
|
|
122
|
-
const createAgreementButton = (agreement, fallbackImageSrc, onChangeAgreement, isCurrentAgreement = false) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
const createAgreementButton = (agreement, fallbackImageSrc, onChangeAgreement, isCurrentAgreement = false) => {
|
|
123
|
+
const handleKeyDown = event => {
|
|
124
|
+
if (event.key === 'Enter') {
|
|
125
|
+
onChangeAgreement(agreement);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
129
|
+
"aria-current": isCurrentAgreement ? 'true' : undefined,
|
|
130
|
+
className: "focus:yt-focus-dark w-full rounded outline-none",
|
|
131
|
+
"data-taco": "header-agreements-agreement",
|
|
132
|
+
key: `${agreement.number}_${agreement.userId}`,
|
|
133
|
+
onClick: () => onChangeAgreement(agreement),
|
|
134
|
+
onKeyDown: handleKeyDown,
|
|
135
|
+
tabIndex: 0
|
|
136
|
+
}, /*#__PURE__*/React__default.createElement(AgreementDetails, Object.assign({}, agreement, {
|
|
137
|
+
className: "h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]",
|
|
138
|
+
fallbackImageSrc: fallbackImageSrc
|
|
139
|
+
})));
|
|
140
|
+
};
|
|
134
141
|
|
|
135
142
|
export { AgreementDisplay, AgreementSelector };
|
|
136
143
|
//# sourceMappingURL=AgreementSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgreementSelector.js","sources":["../../../../../../../../src/components/Header/components/AgreementSelector.tsx"],"sourcesContent":["import React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as CollectionPrimitive from '../../../primitives/Collection/Collection';\nimport { Agreement, AgreementDetails } from './Agreements/AgreementDetails';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Icon } from '../../Icon/Icon';\nimport { SearchInput } from '../../SearchInput/SearchInput';\nimport { Button } from '../../Button/Button';\nimport { useLocalization } from '../../Provider/Localization';\n\nconst Container = props => {\n return (\n <div\n className=\"-ml-3 flex flex-shrink-0 flex-grow-0 items-center gap-2 xl:ml-auto xl:w-64 xl:pr-2\"\n data-taco=\"header-agreements\">\n <span className=\"hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex\" />\n {props.children}\n </div>\n );\n};\n\nexport type AgreementDisplayProps = React.HTMLAttributes<HTMLDivElement> & {\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n};\n\nexport function AgreementDisplay(props: AgreementDisplayProps) {\n const { currentAgreement, fallbackImageSrc } = props;\n\n return (\n <Container>\n <AgreementDetails\n {...currentAgreement}\n className=\"h-12 [&>span>span]:hidden xl:[&>span>span]:flex \"\n fallbackImageSrc={fallbackImageSrc}\n />\n </Container>\n );\n}\n\nexport type AgreementSelectorProps = AgreementDisplayProps & {\n agreements: Agreement[];\n filterAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n filterClientAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n onAddAgreement?: () => void;\n onChangeAgreement: (agreement: Agreement) => void;\n onLogout: () => void;\n open?: boolean;\n setOpen?: (open: boolean) => void;\n};\n\nexport function AgreementSelector(props: AgreementSelectorProps) {\n const {\n agreements,\n currentAgreement,\n fallbackImageSrc,\n filterAgreement = () => true,\n filterClientAgreement = () => true,\n onAddAgreement: handleAddAgreement,\n onChangeAgreement,\n onLogout: handleLogout,\n open: prop,\n setOpen: onChange,\n } = props;\n const { texts } = useLocalization();\n const collectionRef = React.useRef<CollectionPrimitive.CollectionRef | null>(null);\n const [open, setOpen] = useControllableState<boolean>({\n onChange,\n prop,\n });\n const [search, setSearch] = React.useState('');\n\n React.useEffect(() => {\n setSearch('');\n }, [open]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {\n event.preventDefault();\n collectionRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n };\n\n const handleChangeAgreement = (agreement: Agreement) => {\n onChangeAgreement(agreement);\n setOpen(false);\n };\n\n return (\n <Container>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger className=\"xl:focus-visible:yt-focus-dark [&:focus-visible_img]:yt-focus-dark w-full rounded outline-none xl:[&:focus-visible_img]:shadow-none\">\n <AgreementDetails\n {...currentAgreement}\n className=\"h-12 flex-grow xl:hover:bg-white/[0.16] [&>span>span]:hidden xl:[&>span>span]:flex [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}>\n {agreements ? (\n <Icon\n className=\"ml-auto hidden flex-shrink-0 flex-grow-0 text-white xl:flex\"\n name={open ? 'chevron-up' : 'chevron-down'}\n />\n ) : null}\n </AgreementDetails>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content className=\"z-[996] mt-2 flex h-[calc(100vh_-_theme(spacing.16))] w-64 flex-col gap-1 bg-blue-900\">\n <SearchInput\n autoFocus\n className=\"focus-visible:!yt-focus-dark mx-2 !border-transparent !bg-white/[0.08] !text-white hover:!bg-white/[0.16] hover:!shadow-none focus:!bg-white/[0.16] active:!bg-white/[0.16] [&+div>button]:!text-white\"\n onChange={event => setSearch(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={texts.header.search}\n />\n <CollectionPrimitive.Root\n querySelector=\"button\"\n className=\"-my-1 flex w-full flex-grow flex-col gap-1 overflow-auto px-2 py-1 outline-none\"\n ref={collectionRef}\n tabIndex={-1}>\n {agreements\n ?.filter(agreement => filterAgreement(agreement, filterBySearchValue(search)))\n .map(agreement => {\n const button = createAgreementButton(\n agreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(agreement, currentAgreement)\n );\n\n if (agreement.clients) {\n return (\n <span\n className=\"flex flex-col gap-px [&>*:first-child>span]:!rounded-t [&>*:last-child>span]:!rounded-b [&>*>span]:!rounded-none\"\n key={`${agreement.number}_${agreement.userId}_clients`}>\n {filterBySearchValue(search)(agreement) ? button : null}\n {agreement.clients\n .filter(agreement =>\n filterClientAgreement(agreement, filterBySearchValue(search))\n )\n .map(clientAgreement =>\n createAgreementButton(\n clientAgreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(clientAgreement, currentAgreement)\n )\n )}\n </span>\n );\n }\n\n return button;\n })}\n </CollectionPrimitive.Root>\n {handleAddAgreement ? (\n <Button\n className=\"focus-visible:!yt-focus-dark my-1 mx-2 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]\"\n onClick={handleAddAgreement}>\n {texts.header.addAgreement}\n </Button>\n ) : null}\n <hr className=\"my-0 h-px w-full bg-white/[0.08]\" />\n <a\n className=\"focus-visible:yt-focus-dark mx-2 mb-2 flex h-8 shrink-0 items-center justify-center rounded text-white hover:cursor-pointer hover:text-white hover:underline focus-visible:outline-none\"\n onClick={handleLogout}\n tabIndex={0}>\n {texts.header.logout}\n </a>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </Container>\n );\n}\n\nconst filterBySearchValue = (search: string) => (agreement: Agreement) => {\n if (!search || !search.length) {\n return true;\n }\n\n const matchesAgreementNumber = String(agreement.number).indexOf(search) > -1;\n const matchesCompanyName = agreement.name.toLowerCase().indexOf(search.toLowerCase()) > -1;\n\n return matchesAgreementNumber || matchesCompanyName;\n};\n\nconst isCurrentAgreement = (agreement: Agreement, currentAgreement: Agreement) => {\n return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;\n};\n\nconst createAgreementButton = (\n agreement: Agreement,\n fallbackImageSrc: string,\n onChangeAgreement: (agreement: Agreement) => void,\n isCurrentAgreement = false\n) => (\n <button\n aria-current={isCurrentAgreement ? 'true' : undefined}\n className=\"focus:yt-focus-dark w-full rounded outline-none\"\n data-taco=\"header-agreements-agreement\"\n key={`${agreement.number}_${agreement.userId}`}\n onClick={() => onChangeAgreement(agreement)}\n onKeyDown={() => onChangeAgreement(agreement)}\n tabIndex={0}>\n <AgreementDetails\n {...agreement}\n className=\"h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}\n />\n </button>\n);\n"],"names":["Container","props","React","className","children","AgreementDisplay","currentAgreement","fallbackImageSrc","AgreementDetails","AgreementSelector","agreements","filterAgreement","filterClientAgreement","onAddAgreement","handleAddAgreement","onChangeAgreement","onLogout","handleLogout","open","prop","setOpen","onChange","texts","useLocalization","collectionRef","useRef","useControllableState","search","setSearch","useState","useEffect","handleKeyDown","event","key","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","handleChangeAgreement","agreement","PopoverPrimitive","onOpenChange","Icon","name","SearchInput","autoFocus","target","value","onKeyDown","placeholder","header","CollectionPrimitive","querySelector","ref","tabIndex","filter","filterBySearchValue","map","button","createAgreementButton","isCurrentAgreement","clients","number","userId","clientAgreement","Button","onClick","addAgreement","logout","length","matchesAgreementNumber","String","indexOf","matchesCompanyName","toLowerCase","undefined"],"mappings":";;;;;;;;;;;;AAWA,MAAMA,SAAS,GAAGC,KAAK;EACnB,oBACIC;IACIC,SAAS,EAAC,oFAAoF;iBACpF;kBACVD;IAAMC,SAAS,EAAC;IAAqE,EACpFF,KAAK,CAACG,QAAQ,CACb;AAEd,CAAC;SAOeC,gBAAgB,CAACJ,KAA4B;EACzD,MAAM;IAAEK,gBAAgB;IAAEC;GAAkB,GAAGN,KAAK;EAEpD,oBACIC,6BAACF,SAAS,qBACNE,6BAACM,gBAAgB,oBACTF,gBAAgB;IACpBH,SAAS,EAAC,kDAAkD;IAC5DI,gBAAgB,EAAEA;KACpB,CACM;AAEpB;SAagBE,iBAAiB,CAACR,KAA6B;EAC3D,MAAM;IACFS,UAAU;IACVJ,gBAAgB;IAChBC,gBAAgB;IAChBI,eAAe,GAAG,MAAM,IAAI;IAC5BC,qBAAqB,GAAG,MAAM,IAAI;IAClCC,cAAc,EAAEC,kBAAkB;IAClCC,iBAAiB;IACjBC,QAAQ,EAAEC,YAAY;IACtBC,IAAI,EAAEC,IAAI;IACVC,OAAO,EAAEC;GACZ,GAAGpB,KAAK;EACT,MAAM;IAAEqB;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,aAAa,GAAGtB,cAAK,CAACuB,MAAM,CAA2C,IAAI,CAAC;EAClF,MAAM,CAACP,IAAI,EAAEE,OAAO,CAAC,GAAGM,oBAAoB,CAAU;IAClDL,QAAQ;IACRF;GACH,CAAC;EACF,MAAM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AgB,EAAEA;GACpB,CAET;;;;"}
|
|
1
|
+
{"version":3,"file":"AgreementSelector.js","sources":["../../../../../../../../src/components/Header/components/AgreementSelector.tsx"],"sourcesContent":["import React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport * as CollectionPrimitive from '../../../primitives/Collection/Collection';\nimport { Agreement, AgreementDetails } from './Agreements/AgreementDetails';\nimport { createCustomKeyboardEvent } from '../../../utils/input';\nimport { Icon } from '../../Icon/Icon';\nimport { SearchInput } from '../../SearchInput/SearchInput';\nimport { Button } from '../../Button/Button';\nimport { useLocalization } from '../../Provider/Localization';\n\nconst Container = props => {\n return (\n <div\n className=\"-ml-3 flex flex-shrink-0 flex-grow-0 items-center gap-2 xl:ml-auto xl:w-64 xl:pr-2\"\n data-taco=\"header-agreements\">\n <span className=\"hidden h-8 w-px flex-shrink-0 flex-grow-0 bg-white/[0.3] xl:flex\" />\n {props.children}\n </div>\n );\n};\n\nexport type AgreementDisplayProps = React.HTMLAttributes<HTMLDivElement> & {\n currentAgreement: Agreement;\n fallbackImageSrc: string;\n};\n\nexport function AgreementDisplay(props: AgreementDisplayProps) {\n const { currentAgreement, fallbackImageSrc } = props;\n\n return (\n <Container>\n <AgreementDetails\n {...currentAgreement}\n className=\"h-12 [&>span>span]:hidden xl:[&>span>span]:flex \"\n fallbackImageSrc={fallbackImageSrc}\n />\n </Container>\n );\n}\n\nexport type AgreementSelectorProps = AgreementDisplayProps & {\n agreements: Agreement[];\n filterAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n filterClientAgreement: (agreement: Agreement, filter: (agreement: Agreement) => boolean) => void;\n onAddAgreement?: () => void;\n onChangeAgreement: (agreement: Agreement) => void;\n onLogout: () => void;\n open?: boolean;\n setOpen?: (open: boolean) => void;\n};\n\nexport function AgreementSelector(props: AgreementSelectorProps) {\n const {\n agreements,\n currentAgreement,\n fallbackImageSrc,\n filterAgreement = () => true,\n filterClientAgreement = () => true,\n onAddAgreement: handleAddAgreement,\n onChangeAgreement,\n onLogout: handleLogout,\n open: prop,\n setOpen: onChange,\n } = props;\n const { texts } = useLocalization();\n const collectionRef = React.useRef<CollectionPrimitive.CollectionRef | null>(null);\n const [open, setOpen] = useControllableState<boolean>({\n onChange,\n prop,\n });\n const [search, setSearch] = React.useState('');\n\n React.useEffect(() => {\n setSearch('');\n }, [open]);\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'Enter') {\n event.preventDefault();\n collectionRef.current?.dispatchEvent(createCustomKeyboardEvent(event as React.KeyboardEvent<HTMLInputElement>));\n }\n };\n\n const handleChangeAgreement = (agreement: Agreement) => {\n onChangeAgreement(agreement);\n setOpen(false);\n };\n\n return (\n <Container>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PopoverPrimitive.Trigger className=\"xl:focus-visible:yt-focus-dark [&:focus-visible_img]:yt-focus-dark w-full rounded outline-none xl:[&:focus-visible_img]:shadow-none\">\n <AgreementDetails\n {...currentAgreement}\n className=\"h-12 flex-grow xl:hover:bg-white/[0.16] [&>span>span]:hidden xl:[&>span>span]:flex [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}>\n {agreements ? (\n <Icon\n className=\"ml-auto hidden flex-shrink-0 flex-grow-0 text-white xl:flex\"\n name={open ? 'chevron-up' : 'chevron-down'}\n />\n ) : null}\n </AgreementDetails>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content className=\"z-[996] mt-2 flex h-[calc(100vh_-_theme(spacing.16))] w-64 flex-col gap-1 bg-blue-900\">\n <SearchInput\n autoFocus\n className=\"focus-visible:!yt-focus-dark mx-2 !border-transparent !bg-white/[0.08] !text-white hover:!bg-white/[0.16] hover:!shadow-none focus:!bg-white/[0.16] active:!bg-white/[0.16] [&+div>button]:!text-white\"\n onChange={event => setSearch(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={texts.header.search}\n />\n <CollectionPrimitive.Root\n querySelector=\"button\"\n className=\"-my-1 flex w-full flex-grow flex-col gap-1 overflow-auto px-2 py-1 outline-none\"\n ref={collectionRef}\n tabIndex={-1}>\n {agreements\n ?.filter(agreement => filterAgreement(agreement, filterBySearchValue(search)))\n .map(agreement => {\n const button = createAgreementButton(\n agreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(agreement, currentAgreement)\n );\n\n if (agreement.clients) {\n return (\n <span\n className=\"flex flex-col gap-px [&>*:first-child>span]:!rounded-t [&>*:last-child>span]:!rounded-b [&>*>span]:!rounded-none\"\n key={`${agreement.number}_${agreement.userId}_clients`}>\n {filterBySearchValue(search)(agreement) ? button : null}\n {agreement.clients\n .filter(agreement =>\n filterClientAgreement(agreement, filterBySearchValue(search))\n )\n .map(clientAgreement =>\n createAgreementButton(\n clientAgreement,\n fallbackImageSrc,\n handleChangeAgreement,\n isCurrentAgreement(clientAgreement, currentAgreement)\n )\n )}\n </span>\n );\n }\n\n return button;\n })}\n </CollectionPrimitive.Root>\n {handleAddAgreement ? (\n <Button\n className=\"focus-visible:!yt-focus-dark my-1 mx-2 !h-9 shrink-0 !bg-white/[0.08] !text-white hover:!bg-white/[0.16]\"\n onClick={handleAddAgreement}>\n {texts.header.addAgreement}\n </Button>\n ) : null}\n <hr className=\"my-0 h-px w-full bg-white/[0.08]\" />\n <a\n className=\"focus-visible:yt-focus-dark mx-2 mb-2 flex h-8 shrink-0 items-center justify-center rounded text-white hover:cursor-pointer hover:text-white hover:underline focus-visible:outline-none\"\n onClick={handleLogout}\n tabIndex={0}>\n {texts.header.logout}\n </a>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Root>\n </Container>\n );\n}\n\nconst filterBySearchValue = (search: string) => (agreement: Agreement) => {\n if (!search || !search.length) {\n return true;\n }\n\n const matchesAgreementNumber = String(agreement.number).indexOf(search) > -1;\n const matchesCompanyName = agreement.name.toLowerCase().indexOf(search.toLowerCase()) > -1;\n\n return matchesAgreementNumber || matchesCompanyName;\n};\n\nconst isCurrentAgreement = (agreement: Agreement, currentAgreement: Agreement) => {\n return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;\n};\n\nconst createAgreementButton = (\n agreement: Agreement,\n fallbackImageSrc: string,\n onChangeAgreement: (agreement: Agreement) => void,\n isCurrentAgreement = false\n) => {\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === 'Enter') {\n onChangeAgreement(agreement);\n }\n };\n\n return (\n <button\n aria-current={isCurrentAgreement ? 'true' : undefined}\n className=\"focus:yt-focus-dark w-full rounded outline-none\"\n data-taco=\"header-agreements-agreement\"\n key={`${agreement.number}_${agreement.userId}`}\n onClick={() => onChangeAgreement(agreement)}\n onKeyDown={handleKeyDown}\n tabIndex={0}>\n <AgreementDetails\n {...agreement}\n className=\"h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]\"\n fallbackImageSrc={fallbackImageSrc}\n />\n </button>\n );\n};\n"],"names":["Container","props","React","className","children","AgreementDisplay","currentAgreement","fallbackImageSrc","AgreementDetails","AgreementSelector","agreements","filterAgreement","filterClientAgreement","onAddAgreement","handleAddAgreement","onChangeAgreement","onLogout","handleLogout","open","prop","setOpen","onChange","texts","useLocalization","collectionRef","useRef","useControllableState","search","setSearch","useState","useEffect","handleKeyDown","event","key","preventDefault","current","dispatchEvent","createCustomKeyboardEvent","handleChangeAgreement","agreement","PopoverPrimitive","onOpenChange","Icon","name","SearchInput","autoFocus","target","value","onKeyDown","placeholder","header","CollectionPrimitive","querySelector","ref","tabIndex","filter","filterBySearchValue","map","button","createAgreementButton","isCurrentAgreement","clients","number","userId","clientAgreement","Button","onClick","addAgreement","logout","length","matchesAgreementNumber","String","indexOf","matchesCompanyName","toLowerCase","undefined"],"mappings":";;;;;;;;;;;;AAWA,MAAMA,SAAS,GAAGC,KAAK;EACnB,oBACIC;IACIC,SAAS,E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ACI,IAAI,CAAC+B,WAAW,EAAE,CAACF,OAAO,CAAC7C,MAAM,CAAC+C,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;EAE1F,OAAOJ,sBAAsB,IAAIG,kBAAkB;AACvD,CAAC;AAED,MAAMb,kBAAkB,GAAG,CAACrB,SAAoB,EAAEjC,gBAA2B;EACzE,OAAOiC,SAAS,CAACuB,MAAM,KAAKxD,gBAAgB,CAACwD,MAAM,IAAIvB,SAAS,CAACwB,MAAM,KAAKzD,gBAAgB,CAACyD,MAAM;AACvG,CAAC;AAED,MAAMJ,qBAAqB,GAAG,CAC1BpB,SAAoB,EACpBhC,gBAAwB,EACxBQ,iBAAiD,EACjD6C,kBAAkB,GAAG,KAAK;EAE1B,MAAM7B,aAAa,GAAIC,KAA6C;IAChE,IAAIA,KAAK,CAACC,GAAG,KAAK,OAAO,EAAE;MACvBlB,iBAAiB,CAACwB,SAAS,CAAC;;GAEnC;EAED,oBACIrC;oBACkB0D,kBAAkB,GAAG,MAAM,GAAGe,SAAS;IACrDxE,SAAS,EAAC,iDAAiD;iBACjD,6BAA6B;IACvC8B,GAAG,KAAKM,SAAS,CAACuB,UAAUvB,SAAS,CAACwB,QAAQ;IAC9CG,OAAO,EAAE,MAAMnD,iBAAiB,CAACwB,SAAS,CAAC;IAC3CS,SAAS,EAAEjB,aAAa;IACxBuB,QAAQ,EAAE;kBACVpD,6BAACM,gBAAgB,oBACT+B,SAAS;IACbpC,SAAS,EAAC,yFAAyF;IACnGI,gBAAgB,EAAEA;KACpB,CACG;AAEjB,CAAC;;;;"}
|
|
@@ -4,7 +4,7 @@ import { IconButton } from '../../IconButton/IconButton.js';
|
|
|
4
4
|
import { getButtonClasses } from './Button.js';
|
|
5
5
|
|
|
6
6
|
const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(props, ref) {
|
|
7
|
-
const className = cn(getButtonClasses(), 'ml-1 -mr-1 !bg-transparent hover:!bg-white/[.08] focus:!bg-white/[.08]] lg:hidden');
|
|
7
|
+
const className = cn(getButtonClasses(), 'ml-1 -mr-1 !bg-transparent hover:!bg-white/[.08] focus:!bg-white/[.08]] lg:hidden z-[2]');
|
|
8
8
|
return /*#__PURE__*/React__default.createElement(IconButton, Object.assign({}, props, {
|
|
9
9
|
className: className,
|
|
10
10
|
"data-taco": "header-toggle-sidebar",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuButton.js","sources":["../../../../../../../../src/components/Header/components/MenuButton.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { getButtonClasses } from './Button';\n\nexport type MenuButtonProps = {\n onClick: () => void;\n};\n\nexport const MenuButton = React.forwardRef<HTMLButtonElement, MenuButtonProps>(function MenuButton(props, ref) {\n const className = cn(getButtonClasses()
|
|
1
|
+
{"version":3,"file":"MenuButton.js","sources":["../../../../../../../../src/components/Header/components/MenuButton.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { getButtonClasses } from './Button';\n\nexport type MenuButtonProps = {\n onClick: () => void;\n};\n\nexport const MenuButton = React.forwardRef<HTMLButtonElement, MenuButtonProps>(function MenuButton(props, ref) {\n const className = cn(\n getButtonClasses(),\n 'ml-1 -mr-1 !bg-transparent hover:!bg-white/[.08] focus:!bg-white/[.08]] lg:hidden z-[2]'\n );\n\n return <IconButton {...props} className={className} data-taco=\"header-toggle-sidebar\" icon=\"menu\" ref={ref} />;\n});\n"],"names":["MenuButton","React","forwardRef","props","ref","className","cn","getButtonClasses","IconButton","icon"],"mappings":";;;;;MASaA,UAAU,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASF,UAAU,CAACG,KAAK,EAAEC,GAAG;EACzG,MAAMC,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EAAE,EAClB,yFAAyF,CAC5F;EAED,oBAAON,6BAACO,UAAU,oBAAKL,KAAK;IAAEE,SAAS,EAAEA,SAAS;iBAAY,uBAAuB;IAACI,IAAI,EAAC,MAAM;IAACL,GAAG,EAAEA;KAAO;AAClH,CAAC;;;;"}
|
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Backdrop } from '../../Backdrop/Backdrop.js';
|
|
4
|
-
import {
|
|
4
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
5
5
|
import { LayoutContext } from './Context.js';
|
|
6
6
|
import { useIsLargeScreen } from '../../../hooks/useIsLargeScreen.js';
|
|
7
7
|
|
|
8
|
-
const SidebarBackdrop = /*#__PURE__*/
|
|
9
|
-
const internalRef = useMergedRef(ref);
|
|
10
|
-
React__default.useEffect(() => {
|
|
11
|
-
if (internalRef.current) {
|
|
12
|
-
internalRef.current.style.opacity = '1'; // Trigger the animation
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return () => {
|
|
16
|
-
if (internalRef.current) {
|
|
17
|
-
internalRef.current.style.opacity = '0'; // Reset to the initial value
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
return /*#__PURE__*/React__default.createElement(Backdrop, Object.assign({}, props, {
|
|
22
|
-
className: "absolute z-[1] opacity-0 transition-opacity duration-300",
|
|
23
|
-
ref: internalRef
|
|
24
|
-
}));
|
|
25
|
-
});
|
|
8
|
+
const SidebarBackdrop = /*#__PURE__*/motion(Backdrop);
|
|
26
9
|
const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(props, ref) {
|
|
27
10
|
const {
|
|
28
11
|
children,
|
|
@@ -56,10 +39,21 @@ const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(pr
|
|
|
56
39
|
};
|
|
57
40
|
}, [isSmallScreen, sidebarOpen]);
|
|
58
41
|
const showBackdrop = isSmallScreen && sidebarOpen === true;
|
|
42
|
+
const [ready, setReady] = React__default.useState(isSmallScreen);
|
|
59
43
|
const className = cn('bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0', {
|
|
60
|
-
'
|
|
44
|
+
'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,
|
|
45
|
+
// prevent animation when crossing the boundary from large to small screen,
|
|
46
|
+
// this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)
|
|
47
|
+
invisible: isSmallScreen && !ready,
|
|
48
|
+
'transition-[transform] duration-300 visible': isSmallScreen && ready,
|
|
61
49
|
'border-r-2 border-black/[.08] ': !showBackdrop
|
|
62
50
|
}, props.className);
|
|
51
|
+
React__default.useEffect(() => {
|
|
52
|
+
// ensure state is updated in the next cpu tick so that the animation definitely doesn't run
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setReady(isSmallScreen);
|
|
55
|
+
}, 1);
|
|
56
|
+
}, [isSmallScreen]);
|
|
63
57
|
const toggleSidebar = () => setSidebarOpen(open => !open);
|
|
64
58
|
const content = typeof children === 'function' ? children({
|
|
65
59
|
isLargeScreen,
|
|
@@ -74,9 +68,19 @@ const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(pr
|
|
|
74
68
|
"aria-hidden": !isVisible,
|
|
75
69
|
className: className,
|
|
76
70
|
ref: ref
|
|
77
|
-
}), content), showBackdrop
|
|
71
|
+
}), content), /*#__PURE__*/React__default.createElement(AnimatePresence, null, showBackdrop && /*#__PURE__*/React__default.createElement(SidebarBackdrop, {
|
|
72
|
+
initial: {
|
|
73
|
+
opacity: 0
|
|
74
|
+
},
|
|
75
|
+
animate: {
|
|
76
|
+
opacity: 1
|
|
77
|
+
},
|
|
78
|
+
exit: {
|
|
79
|
+
opacity: 0
|
|
80
|
+
},
|
|
81
|
+
className: "z-[1]",
|
|
78
82
|
onClick: () => setSidebarOpen(false)
|
|
79
|
-
})
|
|
83
|
+
})));
|
|
80
84
|
});
|
|
81
85
|
|
|
82
86
|
export { Sidebar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../../../../../../../src/components/Layout/components/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { LayoutContext } from './Context';\nimport { useIsLargeScreen } from '../../../hooks/useIsLargeScreen';\nimport { Backdrop, BackdropProps } from '../../Backdrop/Backdrop';\n\nconst SidebarBackdrop = motion<BackdropProps>(Backdrop);\n\nexport type LayoutSidebarProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, LayoutSidebarProps>(function LayoutSidebar(props, ref) {\n const { children, ...attributes } = props;\n const { sidebarOpen, setSidebarOpen } = React.useContext(LayoutContext);\n const isLargeScreen = useIsLargeScreen();\n const isSmallScreen = !isLargeScreen;\n\n // if it's a large screen we override the open state and make it always visible\n const isVisible = isLargeScreen || sidebarOpen;\n\n // ensures the menu is always closed by default when resizing to a smaller window size\n React.useEffect(() => {\n setSidebarOpen(isLargeScreen);\n }, [isLargeScreen]);\n\n React.useEffect(() => {\n const handleEscapeKey = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n setSidebarOpen(false);\n }\n };\n\n if (isSmallScreen && sidebarOpen) {\n window.addEventListener('keydown', handleEscapeKey);\n }\n\n return () => {\n window.removeEventListener('keydown', handleEscapeKey);\n };\n }, [isSmallScreen, sidebarOpen]);\n\n const showBackdrop = isSmallScreen && sidebarOpen === true;\n\n const [ready, setReady] = React.useState(isSmallScreen);\n\n const className = cn(\n 'bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0',\n {\n 'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,\n // prevent animation when crossing the boundary from large to small screen,\n // this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)\n invisible: isSmallScreen && !ready,\n 'transition-[transform] duration-300 visible': isSmallScreen && ready,\n 'border-r-2 border-black/[.08] ': !showBackdrop,\n },\n props.className\n );\n\n React.useEffect(() => {\n // ensure state is updated in the next cpu tick so that the animation definitely doesn't run\n setTimeout(() => {\n setReady(isSmallScreen);\n }, 1);\n }, [isSmallScreen]);\n\n const toggleSidebar = () => setSidebarOpen(open => !open);\n const content = typeof children === 'function' ? children({ isLargeScreen, open: sidebarOpen, toggleSidebar }) : children;\n\n if (!content) {\n return null;\n }\n\n return (\n <>\n <nav {...attributes} data-responsive={isSmallScreen} aria-hidden={!isVisible} className={className} ref={ref}>\n {content}\n </nav>\n <AnimatePresence>\n {showBackdrop && (\n <SidebarBackdrop\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n className=\"z-[1]\"\n onClick={() => setSidebarOpen(false)}\n />\n )}\n </AnimatePresence>\n </>\n );\n});\n"],"names":["SidebarBackdrop","motion","Backdrop","Sidebar","React","forwardRef","LayoutSidebar","props","ref","children","attributes","sidebarOpen","setSidebarOpen","useContext","LayoutContext","isLargeScreen","useIsLargeScreen","isSmallScreen","isVisible","useEffect","handleEscapeKey","event","key","preventDefault","stopPropagation","window","addEventListener","removeEventListener","showBackdrop","ready","setReady","useState","className","cn","invisible","setTimeout","toggleSidebar","open","content","AnimatePresence","initial","opacity","animate","exit","onClick"],"mappings":";;;;;;;AAOA,MAAMA,eAAe,gBAAGC,MAAM,CAAgBC,QAAQ,CAAC;MAI1CC,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAa,CAACC,KAAK,EAAEC,GAAG;EACzG,MAAM;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGH,KAAK;EACzC,MAAM;IAAEI,WAAW;IAAEC;GAAgB,GAAGR,cAAK,CAACS,UAAU,CAACC,aAAa,CAAC;EACvE,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;EACxC,MAAMC,aAAa,GAAG,CAACF,aAAa;;EAGpC,MAAMG,SA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AQ,KAAK,UAAU,GAAGA,QAAQ,CAAC;IAAEM,aAAa;IAAEsB,IAAI,EAAE1B,WAAW;IAAEyB;GAAe,CAAC,GAAG3B,QAAQ;EAEzH,IAAI,CAAC6B,OAAO,EAAE;IACV,OAAO,IAAI;;EAGf,oBACIlC,yEACIA,sDAASM,UAAU;uBAAmBO,aAAa;mBAAe,CAACC,SAAS;IAAEc,SAAS,EAAEA,SAAS;IAAExB,GAAG,EAAEA;MACpG8B,OAAO,CACN,eACNlC,6BAACmC,eAAe,QACXX,YAAY,iBACTxB,6BAACJ,eAAe;IACZwC,OAAO,EAAE;MAAEC,OAAO,EAAE;KAAG;IACvBC,OAAO,EAAE;MAAED,OAAO,EAAE;KAAG;IACvBE,IAAI,EAAE;MAAEF,OAAO,EAAE;KAAG;IACpBT,SAAS,EAAC,OAAO;IACjBY,OAAO,EAAE,MAAMhC,cAAc,CAAC,KAAK;IAE1C,CACa,CACnB;AAEX,CAAC;;;;"}
|
|
@@ -26,7 +26,7 @@ const useItemStyling = ({
|
|
|
26
26
|
return cn('flex items-center justify-start h-8 pr-1.5 relative rounded w-full focus:outline-none group', {
|
|
27
27
|
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
|
28
28
|
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented),
|
|
29
|
-
'cursor-pointer hover:wcag-grey-200
|
|
29
|
+
'cursor-pointer text-black hover:wcag-grey-200 data-[highlighted]:wcag-grey-200': !disabled,
|
|
30
30
|
'cursor-not-allowed hover:bg-white text-grey-300': disabled
|
|
31
31
|
}, className);
|
|
32
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.js","sources":["../../../../../../../../src/components/Menu/components/Item.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport cn from 'classnames';\nimport { IconName } from '../../Icon/Icon';\nimport { Icon as IconPrimitive } from '../../Icon/Icon';\nimport { useCurrentMenu } from '../Context';\nimport { DialogProps } from '../../Dialog/Dialog';\n\nexport const Icon = ({ name }) => (\n <span className=\"absolute left-0 ml-1\">\n <IconPrimitive className=\"-ml-px -mt-px !h-5 !w-5\" name={name} />\n </span>\n);\n\nexport const useItemStyling = ({ disabled, indented, className }) => {\n const menu = useCurrentMenu();\n\n React.useEffect(() => {\n if (indented && !menu?.indented) {\n menu?.registerIndentation();\n }\n }, [indented]);\n\n return cn(\n 'flex items-center justify-start h-8 pr-1.5 relative rounded w-full focus:outline-none group',\n {\n 'pl-7': menu?.indented,\n 'pl-1.5': !menu?.indented,\n 'cursor-pointer hover:wcag-grey-200
|
|
1
|
+
{"version":3,"file":"Item.js","sources":["../../../../../../../../src/components/Menu/components/Item.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport cn from 'classnames';\nimport { IconName } from '../../Icon/Icon';\nimport { Icon as IconPrimitive } from '../../Icon/Icon';\nimport { useCurrentMenu } from '../Context';\nimport { DialogProps } from '../../Dialog/Dialog';\n\nexport const Icon = ({ name }) => (\n <span className=\"absolute left-0 ml-1\">\n <IconPrimitive className=\"-ml-px -mt-px !h-5 !w-5\" name={name} />\n </span>\n);\n\nexport const useItemStyling = ({ disabled, indented, className }) => {\n const menu = useCurrentMenu();\n\n React.useEffect(() => {\n if (indented && !menu?.indented) {\n menu?.registerIndentation();\n }\n }, [indented]);\n\n return cn(\n 'flex items-center justify-start h-8 pr-1.5 relative rounded w-full focus:outline-none group',\n {\n 'pl-7': menu?.indented,\n 'pl-1.5': !menu?.indented,\n 'cursor-pointer text-black hover:wcag-grey-200 data-[highlighted]:wcag-grey-200': !disabled,\n 'cursor-not-allowed hover:bg-white text-grey-300': disabled,\n },\n className\n );\n};\n\nexport const Shortcut = props => {\n return <span {...props} className=\"text-grey-700 ml-auto pl-3\" />;\n};\n\nexport type MenuItemProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> & {\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n disabled?: boolean;\n icon?: IconName;\n onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;\n shortcut?: string;\n};\n\nexport const Item = React.forwardRef(function MenuItem(props: MenuItemProps, ref: React.Ref<HTMLDivElement>) {\n const { dialog, icon, onClick, shortcut, ...otherProps } = props;\n const menu = useCurrentMenu();\n const className = useItemStyling({\n disabled: props.disabled,\n indented: !!icon,\n className: props.className,\n });\n\n const disabled = props.disabled ?? props['aria-disabled'];\n\n let handleClick;\n\n // radix has a bug that does not disable clicks when disabled is set on items\n if (disabled) {\n handleClick = event => {\n event.preventDefault();\n event.stopPropagation();\n };\n }\n\n const handleSelect = event => {\n if (onClick) {\n onClick(event);\n }\n\n if (props['aria-haspopup'] || typeof dialog === 'function') {\n event.preventDefault();\n }\n };\n\n let button = (\n <DropdownMenuPrimitive.Item {...otherProps} className={className} onClick={handleClick} onSelect={handleSelect} ref={ref}>\n {icon && <Icon name={icon} />}\n {props.children}\n {shortcut && <Shortcut>{shortcut}</Shortcut>}\n </DropdownMenuPrimitive.Item>\n );\n\n if (typeof dialog === 'function') {\n button = dialog({ trigger: button, onClose: menu?.close });\n }\n\n return button;\n});\n"],"names":["Icon","name","React","className","IconPrimitive","useItemStyling","disabled","indented","menu","useCurrentMenu","registerIndentation","cn","Shortcut","props","Item","MenuItem","ref","dialog","icon","onClick","shortcut","otherProps","handleClick","event","preventDefault","stopPropagation","handleSelect","button","DropdownMenuPrimitive","onSelect","children","trigger","onClose","close"],"mappings":";;;;;;MAQaA,IAAI,GAAG,CAAC;EAAEC;CAAM,kBACzBC;EAAMC,SAAS,EAAC;gBACZD,cAACE,MAAa;EAACD,SAAS,EAAC,yBAAyB;EAACF,IAAI,EAAEA;EAAQ;MAI5DI,cAAc,GAAG,CAAC;EAAEC,QAAQ;EAAEC,QAAQ;EAAEJ;CAAW;EAC5D,MAAMK,IAAI,GAAGC,cAAc,EAAE;EAE7BP,SAAe,CAAC;IACZ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B,IAAIV,KAAK,CAAC,eAAe,CAAC,IAAI,OAAOI,MAAM,KAAK,UAAU,EAAE;MACxDM,KAAK,CAACC,cAAc,EAAE;;GAE7B;EAED,IAAIG,MAAM,gBACNzB,cAAC0B,MAA0B,oBAAKP,UAAU;IAAElB,SAAS,EAAEA,SAAS;IAAEgB,OAAO,EAAEG,WAAW;IAAEO,QAAQ,EAAEH,YAAY;IAAEV,GAAG,EAAEA;MAChHE,IAAI,iBAAIhB,cAACF,IAAI;IAACC,IAAI,EAAEiB;IAAQ,EAC5BL,KAAK,CAACiB,QAAQ,EACdV,QAAQ,iBAAIlB,cAACU,QAAQ,QAAEQ,QAAQ,CAAY,CAEnD;EAED,IAAI,OAAOH,MAAM,KAAK,UAAU,EAAE;IAC9BU,MAAM,GAAGV,MAAM,CAAC;MAAEc,OAAO,EAAEJ,MAAM;MAAEK,OAAO,EAAExB,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEyB;KAAO,CAAC;;EAG9D,OAAON,MAAM;AACjB,CAAC;;;;"}
|
|
@@ -6935,7 +6935,7 @@ const useItemStyling = ({
|
|
|
6935
6935
|
return cn('flex items-center justify-start h-8 pr-1.5 relative rounded w-full focus:outline-none group', {
|
|
6936
6936
|
'pl-7': menu === null || menu === void 0 ? void 0 : menu.indented,
|
|
6937
6937
|
'pl-1.5': !(menu !== null && menu !== void 0 && menu.indented),
|
|
6938
|
-
'cursor-pointer hover:wcag-grey-200
|
|
6938
|
+
'cursor-pointer text-black hover:wcag-grey-200 data-[highlighted]:wcag-grey-200': !disabled,
|
|
6939
6939
|
'cursor-not-allowed hover:bg-white text-grey-300': disabled
|
|
6940
6940
|
}, className);
|
|
6941
6941
|
};
|
|
@@ -14952,7 +14952,7 @@ const SecondaryNavigation = /*#__PURE__*/React__default.forwardRef(function Seco
|
|
|
14952
14952
|
});
|
|
14953
14953
|
|
|
14954
14954
|
const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(props, ref) {
|
|
14955
|
-
const className = cn(getButtonClasses$1(), 'ml-1 -mr-1 !bg-transparent hover:!bg-white/[.08] focus:!bg-white/[.08]] lg:hidden');
|
|
14955
|
+
const className = cn(getButtonClasses$1(), 'ml-1 -mr-1 !bg-transparent hover:!bg-white/[.08] focus:!bg-white/[.08]] lg:hidden z-[2]');
|
|
14956
14956
|
return /*#__PURE__*/React__default.createElement(IconButton, Object.assign({}, props, {
|
|
14957
14957
|
className: className,
|
|
14958
14958
|
"data-taco": "header-toggle-sidebar",
|
|
@@ -15136,18 +15136,25 @@ const filterBySearchValue = search => agreement => {
|
|
|
15136
15136
|
const isCurrentAgreement = (agreement, currentAgreement) => {
|
|
15137
15137
|
return agreement.number === currentAgreement.number && agreement.userId === currentAgreement.userId;
|
|
15138
15138
|
};
|
|
15139
|
-
const createAgreementButton = (agreement, fallbackImageSrc, onChangeAgreement, isCurrentAgreement = false) =>
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15139
|
+
const createAgreementButton = (agreement, fallbackImageSrc, onChangeAgreement, isCurrentAgreement = false) => {
|
|
15140
|
+
const handleKeyDown = event => {
|
|
15141
|
+
if (event.key === 'Enter') {
|
|
15142
|
+
onChangeAgreement(agreement);
|
|
15143
|
+
}
|
|
15144
|
+
};
|
|
15145
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
15146
|
+
"aria-current": isCurrentAgreement ? 'true' : undefined,
|
|
15147
|
+
className: "focus:yt-focus-dark w-full rounded outline-none",
|
|
15148
|
+
"data-taco": "header-agreements-agreement",
|
|
15149
|
+
key: `${agreement.number}_${agreement.userId}`,
|
|
15150
|
+
onClick: () => onChangeAgreement(agreement),
|
|
15151
|
+
onKeyDown: handleKeyDown,
|
|
15152
|
+
tabIndex: 0
|
|
15153
|
+
}, /*#__PURE__*/React__default.createElement(AgreementDetails, Object.assign({}, agreement, {
|
|
15154
|
+
className: "h-14 bg-white/[0.08] xl:hover:bg-white/[0.16] [[aria-current='true']>&]:bg-white/[0.16]",
|
|
15155
|
+
fallbackImageSrc: fallbackImageSrc
|
|
15156
|
+
})));
|
|
15157
|
+
};
|
|
15151
15158
|
|
|
15152
15159
|
const Header$2 = /*#__PURE__*/React__default.forwardRef(function Header(props, ref) {
|
|
15153
15160
|
const className = cn('bg-blue-900 flex h-16 w-full shrink-0 items-center gap-4 pl-2', '[&>a:focus-visible]:yt-focus-dark [&>a]:px-2 [&>a]:rounded [&>a]:h-[calc(100%-14px)]',
|
|
@@ -15196,24 +15203,7 @@ const useMatchMedia = (query, defaultMatches = false) => {
|
|
|
15196
15203
|
|
|
15197
15204
|
const useIsLargeScreen = () => useMatchMedia('(min-width: 1024px)', window.innerWidth > 1024);
|
|
15198
15205
|
|
|
15199
|
-
const SidebarBackdrop = /*#__PURE__*/
|
|
15200
|
-
const internalRef = useMergedRef(ref);
|
|
15201
|
-
React__default.useEffect(() => {
|
|
15202
|
-
if (internalRef.current) {
|
|
15203
|
-
internalRef.current.style.opacity = '1'; // Trigger the animation
|
|
15204
|
-
}
|
|
15205
|
-
|
|
15206
|
-
return () => {
|
|
15207
|
-
if (internalRef.current) {
|
|
15208
|
-
internalRef.current.style.opacity = '0'; // Reset to the initial value
|
|
15209
|
-
}
|
|
15210
|
-
};
|
|
15211
|
-
}, []);
|
|
15212
|
-
return /*#__PURE__*/React__default.createElement(Backdrop, Object.assign({}, props, {
|
|
15213
|
-
className: "absolute z-[1] opacity-0 transition-opacity duration-300",
|
|
15214
|
-
ref: internalRef
|
|
15215
|
-
}));
|
|
15216
|
-
});
|
|
15206
|
+
const SidebarBackdrop = /*#__PURE__*/framerMotion.motion(Backdrop);
|
|
15217
15207
|
const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(props, ref) {
|
|
15218
15208
|
const {
|
|
15219
15209
|
children,
|
|
@@ -15247,10 +15237,21 @@ const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(pr
|
|
|
15247
15237
|
};
|
|
15248
15238
|
}, [isSmallScreen, sidebarOpen]);
|
|
15249
15239
|
const showBackdrop = isSmallScreen && sidebarOpen === true;
|
|
15240
|
+
const [ready, setReady] = React__default.useState(isSmallScreen);
|
|
15250
15241
|
const className = cn('bg-grey-50 h-full w-64 flex-shrink-0 flex-grow-0', {
|
|
15251
|
-
'
|
|
15242
|
+
'absolute z-10 aria-hidden:-translate-x-64 ': isSmallScreen,
|
|
15243
|
+
// prevent animation when crossing the boundary from large to small screen,
|
|
15244
|
+
// this prevents awkward animation in the edge case (resizing the browser, instead of starting at a given size)
|
|
15245
|
+
invisible: isSmallScreen && !ready,
|
|
15246
|
+
'transition-[transform] duration-300 visible': isSmallScreen && ready,
|
|
15252
15247
|
'border-r-2 border-black/[.08] ': !showBackdrop
|
|
15253
15248
|
}, props.className);
|
|
15249
|
+
React__default.useEffect(() => {
|
|
15250
|
+
// ensure state is updated in the next cpu tick so that the animation definitely doesn't run
|
|
15251
|
+
setTimeout(() => {
|
|
15252
|
+
setReady(isSmallScreen);
|
|
15253
|
+
}, 1);
|
|
15254
|
+
}, [isSmallScreen]);
|
|
15254
15255
|
const toggleSidebar = () => setSidebarOpen(open => !open);
|
|
15255
15256
|
const content = typeof children === 'function' ? children({
|
|
15256
15257
|
isLargeScreen,
|
|
@@ -15265,9 +15266,19 @@ const Sidebar = /*#__PURE__*/React__default.forwardRef(function LayoutSidebar(pr
|
|
|
15265
15266
|
"aria-hidden": !isVisible,
|
|
15266
15267
|
className: className,
|
|
15267
15268
|
ref: ref
|
|
15268
|
-
}), content), showBackdrop
|
|
15269
|
+
}), content), /*#__PURE__*/React__default.createElement(framerMotion.AnimatePresence, null, showBackdrop && /*#__PURE__*/React__default.createElement(SidebarBackdrop, {
|
|
15270
|
+
initial: {
|
|
15271
|
+
opacity: 0
|
|
15272
|
+
},
|
|
15273
|
+
animate: {
|
|
15274
|
+
opacity: 1
|
|
15275
|
+
},
|
|
15276
|
+
exit: {
|
|
15277
|
+
opacity: 0
|
|
15278
|
+
},
|
|
15279
|
+
className: "z-[1]",
|
|
15269
15280
|
onClick: () => setSidebarOpen(false)
|
|
15270
|
-
})
|
|
15281
|
+
})));
|
|
15271
15282
|
});
|
|
15272
15283
|
|
|
15273
15284
|
const Top = props => {
|