@stokelp/ui 4.0.2 → 4.0.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/components/alert/Alert.cjs.map +1 -1
- package/dist/components/alert/Alert.d.ts +1 -1
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/app/navigation/AppNavigation.cjs.map +1 -1
- package/dist/components/app/navigation/AppNavigation.d.ts +2 -1
- package/dist/components/app/navigation/AppNavigation.js.map +1 -1
- package/dist/components/chat/ChatDocumentMessage.cjs.map +1 -1
- package/dist/components/chat/ChatDocumentMessage.js.map +1 -1
- package/dist/components/chat/ChatProfileAvatar.cjs.map +1 -1
- package/dist/components/chat/ChatProfileAvatar.js.map +1 -1
- package/dist/components/chat/ChatScoreBreakdown.cjs.map +1 -1
- package/dist/components/chat/ChatScoreBreakdown.js.map +1 -1
- package/dist/components/chat/ChatTextInput.cjs.map +1 -1
- package/dist/components/chat/ChatTextInput.d.ts +1 -1
- package/dist/components/chat/ChatTextInput.js.map +1 -1
- package/dist/components/date-picker/DatePicker.cjs.map +1 -1
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/dialog/styled.cjs.map +1 -1
- package/dist/components/dialog/styled.js.map +1 -1
- package/dist/components/input/HighlightedInput.cjs.map +1 -1
- package/dist/components/input/HighlightedInput.js.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.js.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +14 -14
- package/package.json +20 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.cjs","names":["createStyleContext","alert","styled","ark","forwardRef","Icon","IconButton","require_slots","require_IconButton","require_Icon","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledAlert","withProvider","StyledAlertIcon","withContext","StyledAlertTitle","StyledAlertDescription","getIcon","severity","Alert","props","showIcon","iconProps","icon","title","showDismissTrigger","onDismiss","description"],"sources":["../../../src/components/alert/Alert.tsx"],"sourcesContent":["import { ark } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { alert } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { type ComponentProps, forwardRef, ReactNode } from 'react'\nimport { IconButton, type IconButtonProps } from '~/components/icon-button/IconButton'\nimport { Icon, IconProps } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(alert)\n\nconst StyledAlert = withProvider(styled(ark.div), 'root')\nconst StyledAlertIcon = withContext(styled(ark.svg), 'icon')\nconst StyledAlertTitle = withContext(styled(ark.h3), 'title')\nconst StyledAlertDescription = withContext(styled(ark.div), 'description')\n\nexport interface AlertProps extends Omit<ComponentProps<typeof StyledAlert>, 'children' | 'title'> {\n title: ReactNode\n description?: ReactNode\n onDismiss?: IconButtonProps['onClick']\n showDismissTrigger?: boolean\n showIcon?: boolean\n icon?: ReactNode\n iconProps?: IconProps\n}\n\nconst getIcon = (severity: AlertProps['severity']) => {\n switch (severity) {\n default:\n case 'neutral':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM10.2208 6.06246C9.55415 5.47918 8.44619 5.47918 7.77959 6.06246C7.54579 6.26703 7.19043 6.24334 6.98586 6.00954C6.78128 5.77575 6.80498 5.42038 7.03877 5.21581C8.12953 4.2614 9.87081 4.2614 10.9616 5.21581C12.0964 6.20876 12.0964 7.85374 10.9616 8.84669C10.7691 9.01512 10.5571 9.15309 10.3335 9.26127C9.82633 9.50673 9.56267 9.84163 9.56267 10.125V10.6875C9.56267 10.9982 9.31083 11.25 9.00017 11.25C8.68951 11.25 8.43767 10.9982 8.43767 10.6875V10.125C8.43767 9.16573 9.23213 8.54448 9.84346 8.24862C9.98044 8.18233 10.1074 8.09925 10.2208 8.00004C10.8433 7.4553 10.8433 6.6072 10.2208 6.06246ZM8.4375 12.9375C8.4375 12.6268 8.68934 12.375 9 12.375H9.00562C9.31629 12.375 9.56812 12.6268 9.56812 12.9375V12.9431C9.56812 13.2538 9.31629 13.5056 9.00562 13.5056H9C8.68934 13.5056 8.4375 13.2538 8.4375 12.9431V12.9375Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'info':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM8.4375 6.1875C8.4375 5.87684 8.68934 5.625 9 5.625H9.00562C9.31629 5.625 9.56812 5.87684 9.56812 6.1875V6.19313C9.56812 6.50379 9.31629 6.75563 9.00562 6.75563H9C8.68934 6.75563 8.4375 6.50379 8.4375 6.19313V6.1875ZM8.21706 7.91883C9.07674 7.48899 10.0447 8.26546 9.81158 9.19791L9.27983 11.3249L9.31094 11.3094C9.5888 11.1705 9.92668 11.2831 10.0656 11.5609C10.2045 11.8388 10.0919 12.1767 9.81406 12.3156L9.78295 12.3312C8.92327 12.761 7.9553 11.9845 8.18842 11.0521L8.72017 8.92506L8.68906 8.94062C8.41119 9.07955 8.07332 8.96692 7.93438 8.68906C7.79545 8.41119 7.90808 8.07332 8.18594 7.93438L8.21706 7.91883Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'success':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM11.5769 6.85477C11.8297 7.03534 11.8883 7.38665 11.7077 7.63945L8.89523 11.5769C8.79912 11.7115 8.64868 11.7969 8.4839 11.8106C8.31911 11.8242 8.15667 11.7647 8.03975 11.6477L6.35225 9.96025C6.13258 9.74058 6.13258 9.38442 6.35225 9.16475C6.57192 8.94508 6.92808 8.94508 7.14775 9.16475L8.36572 10.3827L10.7923 6.98555C10.9728 6.73276 11.3242 6.67421 11.5769 6.85477Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.97427 2.81473C9.54134 2.06432 8.45829 2.06432 8.02535 2.81473L2.50961 12.3754C2.07692 13.1254 2.6182 14.0625 3.48407 14.0625H14.5156C15.3814 14.0625 15.9227 13.1254 15.49 12.3754L9.97427 2.81473ZM7.0509 2.25255C7.91676 0.751715 10.0829 0.751714 10.9487 2.25255L16.4645 11.8132C17.3299 13.3132 16.2473 15.1875 14.5156 15.1875H3.48407C1.75234 15.1875 0.669765 13.3132 1.53515 11.8132L7.0509 2.25255ZM8.99981 6.18755C9.31047 6.18755 9.56231 6.43939 9.56231 6.75005V9.56255C9.56231 9.87321 9.31047 10.125 8.99981 10.125C8.68915 10.125 8.43731 9.87321 8.43731 9.56255V6.75005C8.43731 6.43939 8.68915 6.18755 8.99981 6.18755ZM8.43731 11.8125C8.43731 11.5019 8.68915 11.25 8.99981 11.25H9.00544C9.3161 11.25 9.56794 11.5019 9.56794 11.8125V11.8182C9.56794 12.1288 9.3161 12.3807 9.00544 12.3807H8.99981C8.68915 12.3807 8.43731 12.1288 8.43731 11.8182V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM9 6.1875C9.31066 6.1875 9.5625 6.43934 9.5625 6.75V9.5625C9.5625 9.87316 9.31066 10.125 9 10.125C8.68934 10.125 8.4375 9.87316 8.4375 9.5625V6.75C8.4375 6.43934 8.68934 6.1875 9 6.1875ZM8.4375 11.8125C8.4375 11.5018 8.68934 11.25 9 11.25H9.00562C9.31629 11.25 9.56812 11.5018 9.56812 11.8125V11.8181C9.56812 12.1288 9.31629 12.3806 9.00562 12.3806H9C8.68934 12.3806 8.4375 12.1288 8.4375 11.8181V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(\n (\n { title, description, showDismissTrigger, onDismiss, severity, showIcon = true, icon, iconProps, ...props },\n ref,\n ) => {\n return (\n <StyledAlert ref={ref} severity={severity} {...props}>\n <StyledAlertTitle>\n {showIcon ? (\n <StyledAlertIcon asChild>\n <Icon {...iconProps}>{icon ? icon : getIcon(severity)}</Icon>\n </StyledAlertIcon>\n ) : null}\n {title}\n {showDismissTrigger ? (\n <IconButton ml=\"auto\" onClick={onDismiss} size=\"sm\" variant=\"tertiary\" aria-label=\"dismiss\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n ) : null}\n </StyledAlertTitle>\n {description ? <StyledAlertDescription>{description}</StyledAlertDescription> : null}\n </StyledAlert>\n )\n },\n)\n"],"mappings":"A,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AGnB,E"}
|
|
1
|
+
{"version":3,"file":"Alert.cjs","names":["createStyleContext","alert","styled","ark","forwardRef","Icon","IconButton","require_slots","require_IconButton","require_Icon","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledAlert","withProvider","StyledAlertIcon","withContext","StyledAlertTitle","StyledAlertDescription","getIcon","severity","Alert","props","showIcon","iconProps","icon","title","showDismissTrigger","onDismiss","description"],"sources":["../../../src/components/alert/Alert.tsx"],"sourcesContent":["import { ark } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { alert } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { type ComponentProps, forwardRef, ReactNode } from 'react'\nimport { IconButton, type IconButtonProps } from '~/components/icon-button/IconButton'\nimport { Icon, IconProps } from '~/components/icon/Icon'\n\nconst { withProvider, withContext } = createStyleContext(alert)\n\nconst StyledAlert = withProvider(styled(ark.div), 'root')\nconst StyledAlertIcon = withContext(styled(ark.svg), 'icon')\nconst StyledAlertTitle = withContext(styled(ark.h3), 'title')\nconst StyledAlertDescription = withContext(styled(ark.div), 'description')\n\nexport interface AlertProps extends Omit<ComponentProps<typeof StyledAlert>, 'children' | 'title'> {\n title: ReactNode\n description?: ReactNode\n onDismiss?: IconButtonProps['onClick']\n showDismissTrigger?: boolean\n showIcon?: boolean\n icon?: ReactNode\n iconProps?: IconProps\n}\n\nconst getIcon = (severity: AlertProps['severity']) => {\n switch (severity) {\n default:\n case 'neutral':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM10.2208 6.06246C9.55415 5.47918 8.44619 5.47918 7.77959 6.06246C7.54579 6.26703 7.19043 6.24334 6.98586 6.00954C6.78128 5.77575 6.80498 5.42038 7.03877 5.21581C8.12953 4.2614 9.87081 4.2614 10.9616 5.21581C12.0964 6.20876 12.0964 7.85374 10.9616 8.84669C10.7691 9.01512 10.5571 9.15309 10.3335 9.26127C9.82633 9.50673 9.56267 9.84163 9.56267 10.125V10.6875C9.56267 10.9982 9.31083 11.25 9.00017 11.25C8.68951 11.25 8.43767 10.9982 8.43767 10.6875V10.125C8.43767 9.16573 9.23213 8.54448 9.84346 8.24862C9.98044 8.18233 10.1074 8.09925 10.2208 8.00004C10.8433 7.4553 10.8433 6.6072 10.2208 6.06246ZM8.4375 12.9375C8.4375 12.6268 8.68934 12.375 9 12.375H9.00562C9.31629 12.375 9.56812 12.6268 9.56812 12.9375V12.9431C9.56812 13.2538 9.31629 13.5056 9.00562 13.5056H9C8.68934 13.5056 8.4375 13.2538 8.4375 12.9431V12.9375Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'info':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM8.4375 6.1875C8.4375 5.87684 8.68934 5.625 9 5.625H9.00562C9.31629 5.625 9.56812 5.87684 9.56812 6.1875V6.19313C9.56812 6.50379 9.31629 6.75563 9.00562 6.75563H9C8.68934 6.75563 8.4375 6.50379 8.4375 6.19313V6.1875ZM8.21706 7.91883C9.07674 7.48899 10.0447 8.26546 9.81158 9.19791L9.27983 11.3249L9.31094 11.3094C9.5888 11.1705 9.92668 11.2831 10.0656 11.5609C10.2045 11.8388 10.0919 12.1767 9.81406 12.3156L9.78295 12.3312C8.92327 12.761 7.9553 11.9845 8.18842 11.0521L8.72017 8.92506L8.68906 8.94062C8.41119 9.07955 8.07332 8.96692 7.93438 8.68906C7.79545 8.41119 7.90808 8.07332 8.18594 7.93438L8.21706 7.91883Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'success':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM11.5769 6.85477C11.8297 7.03534 11.8883 7.38665 11.7077 7.63945L8.89523 11.5769C8.79912 11.7115 8.64868 11.7969 8.4839 11.8106C8.31911 11.8242 8.15667 11.7647 8.03975 11.6477L6.35225 9.96025C6.13258 9.74058 6.13258 9.38442 6.35225 9.16475C6.57192 8.94508 6.92808 8.94508 7.14775 9.16475L8.36572 10.3827L10.7923 6.98555C10.9728 6.73276 11.3242 6.67421 11.5769 6.85477Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.97427 2.81473C9.54134 2.06432 8.45829 2.06432 8.02535 2.81473L2.50961 12.3754C2.07692 13.1254 2.6182 14.0625 3.48407 14.0625H14.5156C15.3814 14.0625 15.9227 13.1254 15.49 12.3754L9.97427 2.81473ZM7.0509 2.25255C7.91676 0.751715 10.0829 0.751714 10.9487 2.25255L16.4645 11.8132C17.3299 13.3132 16.2473 15.1875 14.5156 15.1875H3.48407C1.75234 15.1875 0.669765 13.3132 1.53515 11.8132L7.0509 2.25255ZM8.99981 6.18755C9.31047 6.18755 9.56231 6.43939 9.56231 6.75005V9.56255C9.56231 9.87321 9.31047 10.125 8.99981 10.125C8.68915 10.125 8.43731 9.87321 8.43731 9.56255V6.75005C8.43731 6.43939 8.68915 6.18755 8.99981 6.18755ZM8.43731 11.8125C8.43731 11.5019 8.68915 11.25 8.99981 11.25H9.00544C9.3161 11.25 9.56794 11.5019 9.56794 11.8125V11.8182C9.56794 12.1288 9.3161 12.3807 9.00544 12.3807H8.99981C8.68915 12.3807 8.43731 12.1288 8.43731 11.8182V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM9 6.1875C9.31066 6.1875 9.5625 6.43934 9.5625 6.75V9.5625C9.5625 9.87316 9.31066 10.125 9 10.125C8.68934 10.125 8.4375 9.87316 8.4375 9.5625V6.75C8.4375 6.43934 8.68934 6.1875 9 6.1875ZM8.4375 11.8125C8.4375 11.5018 8.68934 11.25 9 11.25H9.00562C9.31629 11.25 9.56812 11.5018 9.56812 11.8125V11.8181C9.56812 12.1288 9.31629 12.3806 9.00562 12.3806H9C8.68934 12.3806 8.4375 12.1288 8.4375 11.8181V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(\n (\n { title, description, showDismissTrigger, onDismiss, severity, showIcon = true, icon, iconProps, ...props },\n ref,\n ) => {\n return (\n <StyledAlert ref={ref} severity={severity} {...props}>\n <StyledAlertTitle>\n {showIcon ? (\n <StyledAlertIcon asChild>\n <Icon {...iconProps}>{icon ? icon : getIcon(severity)}</Icon>\n </StyledAlertIcon>\n ) : null}\n {title}\n {showDismissTrigger ? (\n <IconButton ml=\"auto\" onClick={onDismiss} size=\"sm\" variant=\"tertiary\" aria-label=\"dismiss\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n ) : null}\n </StyledAlertTitle>\n {description ? <StyledAlertDescription>{description}</StyledAlertDescription> : null}\n </StyledAlert>\n )\n },\n)\n"],"mappings":"A,oSAQA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,KAAK,EAExDc,EAAcC,GAAA,EAAad,EAAAA,OAAAA,CAAOC,EAAAA,IAAI,GAAG,EAAG,MAAM,EAClDc,EAAkBC,GAAA,EAAYhB,EAAAA,OAAAA,CAAOC,EAAAA,IAAI,GAAG,EAAG,MAAM,EACrDgB,EAAmBD,GAAA,EAAYhB,EAAAA,OAAAA,CAAOC,EAAAA,IAAI,EAAE,EAAG,OAAO,EACtDiB,EAAyBF,GAAA,EAAYhB,EAAAA,OAAAA,CAAOC,EAAAA,IAAI,GAAG,EAAG,aAAa,EAYnEkB,EAAW,GAAqC,CACpD,OAAQC,EAAR,CACE,QACA,IAAK,UACH,OACE,EAAAR,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,UAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,8oCACF,KAAK,cACN,CAAA,CACE,CAAA,EAET,IAAK,OACH,OACE,EAAAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,UAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,i8BACF,KAAK,cACN,CAAA,CACE,CAAA,EAET,IAAK,UACH,OACE,EAAAA,EAAA,IAAA,CAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,UAAA,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,2sBACF,KAAK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AAA,CACE,CAAA,CACK,CAAA,EACV,IACY,CAAA,CAAA,EACjBiB,GAAc,EAAAjB,EAAA,IAAA,CAACM,EAAD,CAAA,SAAyBW,CAAoC,CAAA,EAAI,IACrE,C,EAGnB,E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, ForwardRefExoticComponent, ClassAttributes, HTMLAttributes, RefAttributes } from 'react';
|
|
2
2
|
import { IconButtonProps } from '../icon-button/IconButton';
|
|
3
|
-
import { IconProps } from '
|
|
3
|
+
import { IconProps } from '../icon/Icon';
|
|
4
4
|
import { ComponentVariants } from '../../utils/slots';
|
|
5
5
|
import { StyledComponent } from '@stokelp/styled-system/jsx';
|
|
6
6
|
import { PolymorphicProps } from '@ark-ui/react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","names":["createStyleContext","alert","StyledAlert","withProvider","styled","ark","StyledAlertIcon","withContext","StyledAlertTitle","StyledAlertDescription","getIcon","severity","Alert","forwardRef","props","showIcon","Icon","iconProps","icon","title","showDismissTrigger","IconButton","onDismiss","description"],"sources":["../../../src/components/alert/Alert.tsx"],"sourcesContent":["import { ark } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { alert } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { type ComponentProps, forwardRef, ReactNode } from 'react'\nimport { IconButton, type IconButtonProps } from '~/components/icon-button/IconButton'\nimport { Icon, IconProps } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(alert)\n\nconst StyledAlert = withProvider(styled(ark.div), 'root')\nconst StyledAlertIcon = withContext(styled(ark.svg), 'icon')\nconst StyledAlertTitle = withContext(styled(ark.h3), 'title')\nconst StyledAlertDescription = withContext(styled(ark.div), 'description')\n\nexport interface AlertProps extends Omit<ComponentProps<typeof StyledAlert>, 'children' | 'title'> {\n title: ReactNode\n description?: ReactNode\n onDismiss?: IconButtonProps['onClick']\n showDismissTrigger?: boolean\n showIcon?: boolean\n icon?: ReactNode\n iconProps?: IconProps\n}\n\nconst getIcon = (severity: AlertProps['severity']) => {\n switch (severity) {\n default:\n case 'neutral':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM10.2208 6.06246C9.55415 5.47918 8.44619 5.47918 7.77959 6.06246C7.54579 6.26703 7.19043 6.24334 6.98586 6.00954C6.78128 5.77575 6.80498 5.42038 7.03877 5.21581C8.12953 4.2614 9.87081 4.2614 10.9616 5.21581C12.0964 6.20876 12.0964 7.85374 10.9616 8.84669C10.7691 9.01512 10.5571 9.15309 10.3335 9.26127C9.82633 9.50673 9.56267 9.84163 9.56267 10.125V10.6875C9.56267 10.9982 9.31083 11.25 9.00017 11.25C8.68951 11.25 8.43767 10.9982 8.43767 10.6875V10.125C8.43767 9.16573 9.23213 8.54448 9.84346 8.24862C9.98044 8.18233 10.1074 8.09925 10.2208 8.00004C10.8433 7.4553 10.8433 6.6072 10.2208 6.06246ZM8.4375 12.9375C8.4375 12.6268 8.68934 12.375 9 12.375H9.00562C9.31629 12.375 9.56812 12.6268 9.56812 12.9375V12.9431C9.56812 13.2538 9.31629 13.5056 9.00562 13.5056H9C8.68934 13.5056 8.4375 13.2538 8.4375 12.9431V12.9375Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'info':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM8.4375 6.1875C8.4375 5.87684 8.68934 5.625 9 5.625H9.00562C9.31629 5.625 9.56812 5.87684 9.56812 6.1875V6.19313C9.56812 6.50379 9.31629 6.75563 9.00562 6.75563H9C8.68934 6.75563 8.4375 6.50379 8.4375 6.19313V6.1875ZM8.21706 7.91883C9.07674 7.48899 10.0447 8.26546 9.81158 9.19791L9.27983 11.3249L9.31094 11.3094C9.5888 11.1705 9.92668 11.2831 10.0656 11.5609C10.2045 11.8388 10.0919 12.1767 9.81406 12.3156L9.78295 12.3312C8.92327 12.761 7.9553 11.9845 8.18842 11.0521L8.72017 8.92506L8.68906 8.94062C8.41119 9.07955 8.07332 8.96692 7.93438 8.68906C7.79545 8.41119 7.90808 8.07332 8.18594 7.93438L8.21706 7.91883Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'success':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM11.5769 6.85477C11.8297 7.03534 11.8883 7.38665 11.7077 7.63945L8.89523 11.5769C8.79912 11.7115 8.64868 11.7969 8.4839 11.8106C8.31911 11.8242 8.15667 11.7647 8.03975 11.6477L6.35225 9.96025C6.13258 9.74058 6.13258 9.38442 6.35225 9.16475C6.57192 8.94508 6.92808 8.94508 7.14775 9.16475L8.36572 10.3827L10.7923 6.98555C10.9728 6.73276 11.3242 6.67421 11.5769 6.85477Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.97427 2.81473C9.54134 2.06432 8.45829 2.06432 8.02535 2.81473L2.50961 12.3754C2.07692 13.1254 2.6182 14.0625 3.48407 14.0625H14.5156C15.3814 14.0625 15.9227 13.1254 15.49 12.3754L9.97427 2.81473ZM7.0509 2.25255C7.91676 0.751715 10.0829 0.751714 10.9487 2.25255L16.4645 11.8132C17.3299 13.3132 16.2473 15.1875 14.5156 15.1875H3.48407C1.75234 15.1875 0.669765 13.3132 1.53515 11.8132L7.0509 2.25255ZM8.99981 6.18755C9.31047 6.18755 9.56231 6.43939 9.56231 6.75005V9.56255C9.56231 9.87321 9.31047 10.125 8.99981 10.125C8.68915 10.125 8.43731 9.87321 8.43731 9.56255V6.75005C8.43731 6.43939 8.68915 6.18755 8.99981 6.18755ZM8.43731 11.8125C8.43731 11.5019 8.68915 11.25 8.99981 11.25H9.00544C9.3161 11.25 9.56794 11.5019 9.56794 11.8125V11.8182C9.56794 12.1288 9.3161 12.3807 9.00544 12.3807H8.99981C8.68915 12.3807 8.43731 12.1288 8.43731 11.8182V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM9 6.1875C9.31066 6.1875 9.5625 6.43934 9.5625 6.75V9.5625C9.5625 9.87316 9.31066 10.125 9 10.125C8.68934 10.125 8.4375 9.87316 8.4375 9.5625V6.75C8.4375 6.43934 8.68934 6.1875 9 6.1875ZM8.4375 11.8125C8.4375 11.5018 8.68934 11.25 9 11.25H9.00562C9.31629 11.25 9.56812 11.5018 9.56812 11.8125V11.8181C9.56812 12.1288 9.31629 12.3806 9.00562 12.3806H9C8.68934 12.3806 8.4375 12.1288 8.4375 11.8181V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(\n (\n { title, description, showDismissTrigger, onDismiss, severity, showIcon = true, icon, iconProps, ...props },\n ref,\n ) => {\n return (\n <StyledAlert ref={ref} severity={severity} {...props}>\n <StyledAlertTitle>\n {showIcon ? (\n <StyledAlertIcon asChild>\n <Icon {...iconProps}>{icon ? icon : getIcon(severity)}</Icon>\n </StyledAlertIcon>\n ) : null}\n {title}\n {showDismissTrigger ? (\n <IconButton ml=\"auto\" onClick={onDismiss} size=\"sm\" variant=\"tertiary\" aria-label=\"dismiss\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n ) : null}\n </StyledAlertTitle>\n {description ? <StyledAlertDescription>{description}</StyledAlertDescription> : null}\n </StyledAlert>\n )\n },\n)\n"],"mappings":";;;;;;;;;;AAQA,IAAM,EAAE,iBAAc,mBAAgBA,EAAmBC,CAAK,GAExDC,IAAcC,EAAaC,EAAOC,EAAI,GAAG,GAAG,MAAM,GAClDC,IAAkBC,EAAYH,EAAOC,EAAI,GAAG,GAAG,MAAM,GACrDG,IAAmBD,EAAYH,EAAOC,EAAI,EAAE,GAAG,OAAO,GACtDI,IAAyBF,EAAYH,EAAOC,EAAI,GAAG,GAAG,aAAa,GAYnEK,KAAW,MAAqC;CACpD,QAAQC,GAAR;EACE;EACA,KAAK,WACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK,QACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK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AoC,CAAA,IAAI,IACrE;A,EAGnB"}
|
|
1
|
+
{"version":3,"file":"Alert.js","names":["createStyleContext","alert","StyledAlert","withProvider","styled","ark","StyledAlertIcon","withContext","StyledAlertTitle","StyledAlertDescription","getIcon","severity","Alert","forwardRef","props","showIcon","Icon","iconProps","icon","title","showDismissTrigger","IconButton","onDismiss","description"],"sources":["../../../src/components/alert/Alert.tsx"],"sourcesContent":["import { ark } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { alert } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\nimport { type ComponentProps, forwardRef, ReactNode } from 'react'\nimport { IconButton, type IconButtonProps } from '~/components/icon-button/IconButton'\nimport { Icon, IconProps } from '~/components/icon/Icon'\n\nconst { withProvider, withContext } = createStyleContext(alert)\n\nconst StyledAlert = withProvider(styled(ark.div), 'root')\nconst StyledAlertIcon = withContext(styled(ark.svg), 'icon')\nconst StyledAlertTitle = withContext(styled(ark.h3), 'title')\nconst StyledAlertDescription = withContext(styled(ark.div), 'description')\n\nexport interface AlertProps extends Omit<ComponentProps<typeof StyledAlert>, 'children' | 'title'> {\n title: ReactNode\n description?: ReactNode\n onDismiss?: IconButtonProps['onClick']\n showDismissTrigger?: boolean\n showIcon?: boolean\n icon?: ReactNode\n iconProps?: IconProps\n}\n\nconst getIcon = (severity: AlertProps['severity']) => {\n switch (severity) {\n default:\n case 'neutral':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM10.2208 6.06246C9.55415 5.47918 8.44619 5.47918 7.77959 6.06246C7.54579 6.26703 7.19043 6.24334 6.98586 6.00954C6.78128 5.77575 6.80498 5.42038 7.03877 5.21581C8.12953 4.2614 9.87081 4.2614 10.9616 5.21581C12.0964 6.20876 12.0964 7.85374 10.9616 8.84669C10.7691 9.01512 10.5571 9.15309 10.3335 9.26127C9.82633 9.50673 9.56267 9.84163 9.56267 10.125V10.6875C9.56267 10.9982 9.31083 11.25 9.00017 11.25C8.68951 11.25 8.43767 10.9982 8.43767 10.6875V10.125C8.43767 9.16573 9.23213 8.54448 9.84346 8.24862C9.98044 8.18233 10.1074 8.09925 10.2208 8.00004C10.8433 7.4553 10.8433 6.6072 10.2208 6.06246ZM8.4375 12.9375C8.4375 12.6268 8.68934 12.375 9 12.375H9.00562C9.31629 12.375 9.56812 12.6268 9.56812 12.9375V12.9431C9.56812 13.2538 9.31629 13.5056 9.00562 13.5056H9C8.68934 13.5056 8.4375 13.2538 8.4375 12.9431V12.9375Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'info':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM8.4375 6.1875C8.4375 5.87684 8.68934 5.625 9 5.625H9.00562C9.31629 5.625 9.56812 5.87684 9.56812 6.1875V6.19313C9.56812 6.50379 9.31629 6.75563 9.00562 6.75563H9C8.68934 6.75563 8.4375 6.50379 8.4375 6.19313V6.1875ZM8.21706 7.91883C9.07674 7.48899 10.0447 8.26546 9.81158 9.19791L9.27983 11.3249L9.31094 11.3094C9.5888 11.1705 9.92668 11.2831 10.0656 11.5609C10.2045 11.8388 10.0919 12.1767 9.81406 12.3156L9.78295 12.3312C8.92327 12.761 7.9553 11.9845 8.18842 11.0521L8.72017 8.92506L8.68906 8.94062C8.41119 9.07955 8.07332 8.96692 7.93438 8.68906C7.79545 8.41119 7.90808 8.07332 8.18594 7.93438L8.21706 7.91883Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'success':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM11.5769 6.85477C11.8297 7.03534 11.8883 7.38665 11.7077 7.63945L8.89523 11.5769C8.79912 11.7115 8.64868 11.7969 8.4839 11.8106C8.31911 11.8242 8.15667 11.7647 8.03975 11.6477L6.35225 9.96025C6.13258 9.74058 6.13258 9.38442 6.35225 9.16475C6.57192 8.94508 6.92808 8.94508 7.14775 9.16475L8.36572 10.3827L10.7923 6.98555C10.9728 6.73276 11.3242 6.67421 11.5769 6.85477Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9.97427 2.81473C9.54134 2.06432 8.45829 2.06432 8.02535 2.81473L2.50961 12.3754C2.07692 13.1254 2.6182 14.0625 3.48407 14.0625H14.5156C15.3814 14.0625 15.9227 13.1254 15.49 12.3754L9.97427 2.81473ZM7.0509 2.25255C7.91676 0.751715 10.0829 0.751714 10.9487 2.25255L16.4645 11.8132C17.3299 13.3132 16.2473 15.1875 14.5156 15.1875H3.48407C1.75234 15.1875 0.669765 13.3132 1.53515 11.8132L7.0509 2.25255ZM8.99981 6.18755C9.31047 6.18755 9.56231 6.43939 9.56231 6.75005V9.56255C9.56231 9.87321 9.31047 10.125 8.99981 10.125C8.68915 10.125 8.43731 9.87321 8.43731 9.56255V6.75005C8.43731 6.43939 8.68915 6.18755 8.99981 6.18755ZM8.43731 11.8125C8.43731 11.5019 8.68915 11.25 8.99981 11.25H9.00544C9.3161 11.25 9.56794 11.5019 9.56794 11.8125V11.8182C9.56794 12.1288 9.3161 12.3807 9.00544 12.3807H8.99981C8.68915 12.3807 8.43731 12.1288 8.43731 11.8182V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 18 18\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M9 2.8125C5.58274 2.8125 2.8125 5.58274 2.8125 9C2.8125 12.4173 5.58274 15.1875 9 15.1875C12.4173 15.1875 15.1875 12.4173 15.1875 9C15.1875 5.58274 12.4173 2.8125 9 2.8125ZM1.6875 9C1.6875 4.96142 4.96142 1.6875 9 1.6875C13.0386 1.6875 16.3125 4.96142 16.3125 9C16.3125 13.0386 13.0386 16.3125 9 16.3125C4.96142 16.3125 1.6875 13.0386 1.6875 9ZM9 6.1875C9.31066 6.1875 9.5625 6.43934 9.5625 6.75V9.5625C9.5625 9.87316 9.31066 10.125 9 10.125C8.68934 10.125 8.4375 9.87316 8.4375 9.5625V6.75C8.4375 6.43934 8.68934 6.1875 9 6.1875ZM8.4375 11.8125C8.4375 11.5018 8.68934 11.25 9 11.25H9.00562C9.31629 11.25 9.56812 11.5018 9.56812 11.8125V11.8181C9.56812 12.1288 9.31629 12.3806 9.00562 12.3806H9C8.68934 12.3806 8.4375 12.1288 8.4375 11.8181V11.8125Z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n }\n}\n\nexport const Alert = forwardRef<HTMLDivElement, AlertProps>(\n (\n { title, description, showDismissTrigger, onDismiss, severity, showIcon = true, icon, iconProps, ...props },\n ref,\n ) => {\n return (\n <StyledAlert ref={ref} severity={severity} {...props}>\n <StyledAlertTitle>\n {showIcon ? (\n <StyledAlertIcon asChild>\n <Icon {...iconProps}>{icon ? icon : getIcon(severity)}</Icon>\n </StyledAlertIcon>\n ) : null}\n {title}\n {showDismissTrigger ? (\n <IconButton ml=\"auto\" onClick={onDismiss} size=\"sm\" variant=\"tertiary\" aria-label=\"dismiss\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n ) : null}\n </StyledAlertTitle>\n {description ? <StyledAlertDescription>{description}</StyledAlertDescription> : null}\n </StyledAlert>\n )\n },\n)\n"],"mappings":";;;;;;;;;;AAQA,IAAM,EAAE,iBAAc,mBAAgBA,EAAmBC,CAAK,GAExDC,IAAcC,EAAaC,EAAOC,EAAI,GAAG,GAAG,MAAM,GAClDC,IAAkBC,EAAYH,EAAOC,EAAI,GAAG,GAAG,MAAM,GACrDG,IAAmBD,EAAYH,EAAOC,EAAI,EAAE,GAAG,OAAO,GACtDI,IAAyBF,EAAYH,EAAOC,EAAI,GAAG,GAAG,aAAa,GAYnEK,KAAW,MAAqC;CACpD,QAAQC,GAAR;EACE;EACA,KAAK,WACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK,QACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK,WACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK,WACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;EAET,KAAK,SACH,OACE,kBAAC,OAAD;GAAK,OAAM;GAAK,QAAO;GAAK,SAAQ;GAAY,MAAK;GAAO,OAAM;GAChE,UAAA,kBAAC,QAAD;IACE,UAAS;IACT,UAAS;IACT,GAAE;IACF,MAAK;GACN,CAAA;EACE,CAAA;CAEX;AACF,GAEaC,IAAQC,GAEjB,EAAE,UAAO,gBAAa,uBAAoB,cAAW,aAAU,cAAW,IAAM,SAAM,cAAW,GAAGC,KACpG,MAGE,kBAACZ,GAAD;CAAkB;CAAe;CAAU,GAAIY;CAA/C,UAAA,CACE,kBAACN,GAAD,EAAA,UAAA;EACGO,IACC,kBAACT,GAAD;GAAiB,SAAA;GACf,UAAA,kBAACU,GAAD;IAAM,GAAIC;IAAY,UAAAC,KAAcR,EAAQC,CAAQ;GAAQ,CAAA;EAC7C,CAAA,IACf;EACHQ;EACAC,IACC,kBAACC,GAAD;GAAY,IAAG;GAAO,SAASC;GAAW,MAAK;GAAK,SAAQ;GAAW,cAAW;GAChF,UAAA,kBAAC,OAAD;IAAK,OAAM;IAAK,QAAO;IAAK,SAAQ;IAAY,MAAK;IAAO,OAAM;IAChE,UAAA,kBAAC,QAAD;KACE,UAAS;KACT,UAAS;KACT,GAAE;KACF,MAAK;IACN,CAAA;GACE,CAAA;EACK,CAAA,IACV;CACY,EAAA,CAAA,GACjBC,IAAc,kBAACd,GAAD,EAAA,UAAyBc,EAAoC,CAAA,IAAI,IACrE;A,EAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppNavigation.cjs","names":["createStyleContext","appNavigation","styled","Icon","Tag","ArrowLeftCircleIcon","require_runtime","require_slots","require_Tag","require_Icon","require_ArrowLeftCircleIcon","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","AppNavigation_exports","Body","Footer","Header","Item","ItemAlpha","ItemContent","ItemIcon","ItemLabel","ItemSubItems","MiniaturizeTrigger","Root","MINIATURIZE_STORAGE_KEY","readMiniaturizeState","writeMiniaturizeState","state","styledTag","tag","withProvider","withContext","newState"],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":"A,+jBASM,CAAE,eAAc,eAAgB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EACA,UACE,EAAAd,EAAA,IAAA,CAACV,EAAAA,KAAD,CAAA,UACE,EAAAU,EAAA,IAAA,CAACR,EAAAA,QAAD,CAAsB,CAAA,CAClB,CAAA,CAEV,CACF,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"AppNavigation.cjs","names":["createStyleContext","appNavigation","styled","Icon","Tag","ArrowLeftCircleIcon","require_runtime","require_slots","require_Tag","require_Icon","require_ArrowLeftCircleIcon","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","AppNavigation_exports","Body","Footer","Header","Item","ItemAlpha","ItemContent","ItemIcon","ItemLabel","ItemSubItems","MiniaturizeTrigger","Root","MINIATURIZE_STORAGE_KEY","readMiniaturizeState","writeMiniaturizeState","state","styledTag","tag","withProvider","withContext","newState"],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components/tag/Tag'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":"A,+jBASM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,cAAe,CACtE,SAAU,EACZ,CAAC,EAEKyB,EAA0B,mBAa1BC,MAA+C,CACnD,GAAI,CACF,OAAO,aAAa,QAAQD,CAAuB,IAAM,SAAW,SAAW,MACjF,MAAQ,CACN,MAAO,MACT,CACF,EAEME,EAAyB,GAAkC,CAC/D,GAAI,CACF,aAAa,QAAQF,EAAyBG,CAAK,CACrD,MAAQ,CAGR,CACF,EAGMC,EAAoD,IAAA,EACxD5B,EAAAA,OAAAA,CAAO6B,CAAG,EAECN,EAAOO,EAAaF,EAAU,KAAK,EAAG,OAAQ,CACzD,aAAc,CAAC,CACjB,CAAC,EACYb,EAASgB,EAAYH,EAAU,QAAQ,EAAG,QAAQ,EAClDf,EAAOkB,EAAYH,EAAU,MAAM,EAAG,MAAM,EAE5CZ,EAAOe,EAAYH,EAAU,KAAK,EAAG,MAAM,EAC3CP,EAAeU,EAAYH,EAAU,KAAK,EAAG,cAAc,EAC3DV,EAAca,EAAYH,EAAU,KAAK,EAAG,aAAa,EACzDR,EAAYW,EAAYH,EAAU,GAAG,EAAG,WAAW,EACnDT,EAAWY,EAAY9B,EAAAA,KAAM,WAAY,CACpD,aAAc,CACZ,KAAM,IACR,CACF,CAAC,EACYgB,EAAYc,EAAY7B,EAAAA,IAAK,YAAa,CACrD,aAAc,CACZ,SAAU,SACZ,CACF,CAAC,EAEYY,EAASiB,EAAYH,EAAU,QAAQ,EAAG,QAAQ,EAElDN,EAAqBS,EAAYH,EAAU,KAAK,EAAG,qBAAsB,CACpF,aAAc,CACZ,QAAU,GAAkC,CAC1C,EAAE,eAAe,EACjB,IAAMI,EAAWP,EAAqB,IAAM,SAAW,OAAS,SAChEC,EAAsBM,CAAQ,EAC9B,EAAE,cAAc,aAAa,aAAcA,CAAQ,EACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC,CAC3C,EACA,UAAW,qCACX,GAAG,CAOD,GAAI,cAAe,CACjB,OAAOP,EAAqB,CAC9B,CACF,EACA,UACE,EAAAd,EAAA,IAAA,CAACV,EAAAA,KAAD,CAAA,UACE,EAAAU,EAAA,IAAA,CAACR,EAAAA,QAAD,CAAsB,CAAA,CAClB,CAAA,CAEV,CACF,CAAC,E"}
|
|
@@ -2,7 +2,8 @@ import { StyledComponent } from '@stokelp/styled-system/types';
|
|
|
2
2
|
import { ComponentProps, FC, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
3
|
import { ComponentVariants } from '../../../utils/slots';
|
|
4
4
|
import { AppNavigationRecipe } from '@stokelp/styled-system/recipes';
|
|
5
|
-
import { IconProps
|
|
5
|
+
import { IconProps } from '../../icon/Icon';
|
|
6
|
+
import { TagProps } from '../../tag/Tag';
|
|
6
7
|
export declare const Root: ComponentVariants<StyledComponent<"nav", {}>, AppNavigationRecipe>;
|
|
7
8
|
export declare const Header: StyledComponent<"header", {}>;
|
|
8
9
|
export declare const Body: StyledComponent<"main", {}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppNavigation.js","names":["ArrowLeftCircleIcon","ForwardRef","AppNavigation_exports","Body","Footer","Header","Item","ItemAlpha","ItemContent","ItemIcon","ItemLabel","ItemSubItems","MiniaturizeTrigger","Root","createStyleContext","appNavigation","MINIATURIZE_STORAGE_KEY","readMiniaturizeState","writeMiniaturizeState","state","styledTag","styled","tag","withProvider","withContext","Icon","Tag","newState"],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;A,IASM,EAAE,iBAAc,mBAAgBc,EAAmBC,GAAe,EACtE,UAAU,GACZ,CAAC,GAEKC,IAA0B,oBAa1BC,UAA+C;CACnD,IAAI;EACF,OAAO,aAAa,QAAQD,CAAuB,MAAM,WAAW,WAAW;CACjF,QAAQ;EACN,OAAO;CACT;AACF,GAEME,KAAyB,MAAkC;CAC/D,IAAI;EACF,aAAa,QAAQF,GAAyBG,CAAK;CACrD,QAAQ,CAGR;AACF,GAGMC,KAAoD,MACxDC,EAAOC,CAAG,GAECT,IAAOU,EAAaH,EAAU,KAAK,GAAG,QAAQ,EACzD,cAAc,CAAC,EACjB,CAAC,GACYf,IAASmB,EAAYJ,EAAU,QAAQ,GAAG,QAAQ,GAClDjB,IAAOqB,EAAYJ,EAAU,MAAM,GAAG,MAAM,GAE5Cd,IAAOkB,EAAYJ,EAAU,KAAK,GAAG,MAAM,GAC3CT,IAAea,EAAYJ,EAAU,KAAK,GAAG,cAAc,GAC3DZ,IAAcgB,EAAYJ,EAAU,KAAK,GAAG,aAAa,GACzDV,IAAYc,EAAYJ,EAAU,GAAG,GAAG,WAAW,GACnDX,IAAWe,EAAYC,GAAM,YAAY,EACpD,cAAc,EACZ,MAAM,KACR,EACF,CAAC,GACYlB,IAAYiB,EAAYE,GAAK,aAAa,EACrD,cAAc,EACZ,UAAU,UACZ,EACF,CAAC,GAEYtB,IAASoB,EAAYJ,EAAU,QAAQ,GAAG,QAAQ,GAElDR,IAAqBY,EAAYJ,EAAU,KAAK,GAAG,sBAAsB,EACpF,cAAc;CACZ,UAAU,MAAkC;EAC1C,EAAE,eAAe;EACjB,IAAMO,IAAWV,EAAqB,MAAM,WAAW,SAAS;EAGhE,AAFAC,EAAsBS,CAAQ,GAC9B,EAAE,cAAc,aAAa,cAAcA,CAAQ,GACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC;CAC3C;CACA,WAAW;CACX,GAAG,EAOD,IAAI,eAAe;EACjB,OAAOV,EAAqB;CAC9B,EACF;CACA,UACE,kBAACQ,GAAD,EAAA,UACE,kBAACzB,GAAD,CAAsB,CAAA,EAClB,CAAA;AAEV,EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"AppNavigation.js","names":["ArrowLeftCircleIcon","ForwardRef","AppNavigation_exports","Body","Footer","Header","Item","ItemAlpha","ItemContent","ItemIcon","ItemLabel","ItemSubItems","MiniaturizeTrigger","Root","createStyleContext","appNavigation","MINIATURIZE_STORAGE_KEY","readMiniaturizeState","writeMiniaturizeState","state","styledTag","styled","tag","withProvider","withContext","Icon","Tag","newState"],"sources":["../../../../src/components/app/navigation/AppNavigation.tsx"],"sourcesContent":["import { styled } from '@stokelp/styled-system/jsx'\nimport { appNavigation } from '@stokelp/styled-system/recipes'\nimport type { StyledComponent } from '@stokelp/styled-system/types'\nimport { createStyleContext } from '~/utils/slots'\nimport { Icon } from '~/components/icon/Icon'\nimport { ComponentProps, type JSX, type MouseEvent } from 'react'\nimport { ArrowLeftCircleIcon } from '@heroicons/react/24/outline'\nimport { Tag } from '~/components/tag/Tag'\n\nconst { withProvider, withContext } = createStyleContext(appNavigation, {\n dataAttr: true,\n})\n\nconst MINIATURIZE_STORAGE_KEY = 'isMiniaturizeNav'\n\ntype MiniaturizeState = 'open' | 'closed'\n\n// Whether the nav is collapsed lives in localStorage: no backend field and no teammate\n// sync, and the recipe reads it off `data-state` on the trigger (see the `:has()` rule in\n// theme/recipes/app/navigation.ts).\n//\n// Both helpers swallow their own errors on purpose. A browser that blocks site data\n// (Android Chrome with cookies off, an embedded webview, Safari in lockdown) throws\n// SecurityError on the mere property access, and `typeof localStorage` does not guard\n// against that: it evaluates the same getter. It only guards against the server, where\n// the property is absent.\nconst readMiniaturizeState = (): MiniaturizeState => {\n try {\n return localStorage.getItem(MINIATURIZE_STORAGE_KEY) === 'closed' ? 'closed' : 'open'\n } catch {\n return 'open'\n }\n}\n\nconst writeMiniaturizeState = (state: MiniaturizeState): void => {\n try {\n localStorage.setItem(MINIATURIZE_STORAGE_KEY, state)\n } catch {\n // Storage blocked: the attribute set below still collapses the nav for this page\n // view, the choice just does not survive a reload.\n }\n}\n\n// See Table.tsx for why we wrap `styled(tag)` to pin the literal tag.\nconst styledTag = <T extends keyof JSX.IntrinsicElements>(tag: T): StyledComponent<T, {}> =>\n styled(tag) as StyledComponent<T, {}>\n\nexport const Root = withProvider(styledTag('nav'), 'root', {\n defaultProps: {},\n})\nexport const Header = withContext(styledTag('header'), 'header')\nexport const Body = withContext(styledTag('main'), 'body')\n\nexport const Item = withContext(styledTag('div'), 'item')\nexport const ItemSubItems = withContext(styledTag('div'), 'itemSubItems')\nexport const ItemContent = withContext(styledTag('div'), 'itemContent')\nexport const ItemLabel = withContext(styledTag('p'), 'itemLabel')\nexport const ItemIcon = withContext(Icon, 'itemIcon', {\n defaultProps: {\n size: 'sm',\n },\n})\nexport const ItemAlpha = withContext(Tag, 'itemAlpha', {\n defaultProps: {\n severity: 'success',\n },\n})\n\nexport const Footer = withContext(styledTag('footer'), 'footer')\n\nexport const MiniaturizeTrigger = withContext(styledTag('div'), 'miniaturizeTrigger', {\n defaultProps: {\n onClick: (e: MouseEvent<HTMLDivElement>) => {\n e.preventDefault()\n const newState = readMiniaturizeState() === 'closed' ? 'open' : 'closed'\n writeMiniaturizeState(newState)\n e.currentTarget.setAttribute('data-state', newState)\n window.dispatchEvent(new Event('storage'))\n },\n className: 'app-navigation__miniaturizeTrigger',\n ...{\n // A getter, so the value is read when this object is SPREAD (on every render of the\n // trigger, in createStyleContext) and never when the module is evaluated. As a plain\n // value it read storage at import time, which threw SecurityError on the browsers\n // above and killed the whole chunk: the kit's barrel imports this module, so every\n // page that imports anything from @stokelp/ui went down with it, public marketing\n // pages that show no navigation included.\n get 'data-state'() {\n return readMiniaturizeState()\n },\n },\n children: (\n <Icon>\n <ArrowLeftCircleIcon />\n </Icon>\n ),\n },\n})\n\nexport interface AppNavigationProps extends ComponentProps<typeof Root> {}\nexport interface AppNavigationHeaderProps extends ComponentProps<typeof Header> {}\nexport interface AppNavigationBodyProps extends ComponentProps<typeof Body> {}\nexport interface AppNavigationItemProps extends ComponentProps<typeof Item> {}\nexport interface AppNavigationItemSubItemsProps extends ComponentProps<typeof ItemSubItems> {}\nexport interface AppNavigationItemContentProps extends ComponentProps<typeof ItemContent> {}\nexport type AppNavigationItemLabelProps = ComponentProps<typeof ItemLabel>\nexport interface AppNavigationItemIconProps extends ComponentProps<typeof ItemIcon> {}\nexport interface AppNavigationFooterProps extends ComponentProps<typeof Footer> {}\nexport interface AppNavigationMiniaturizeTriggerProps extends ComponentProps<typeof MiniaturizeTrigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;A,IASM,EAAE,iBAAc,mBAAgBc,EAAmBC,GAAe,EACtE,UAAU,GACZ,CAAC,GAEKC,IAA0B,oBAa1BC,UAA+C;CACnD,IAAI;EACF,OAAO,aAAa,QAAQD,CAAuB,MAAM,WAAW,WAAW;CACjF,QAAQ;EACN,OAAO;CACT;AACF,GAEME,KAAyB,MAAkC;CAC/D,IAAI;EACF,aAAa,QAAQF,GAAyBG,CAAK;CACrD,QAAQ,CAGR;AACF,GAGMC,KAAoD,MACxDC,EAAOC,CAAG,GAECT,IAAOU,EAAaH,EAAU,KAAK,GAAG,QAAQ,EACzD,cAAc,CAAC,EACjB,CAAC,GACYf,IAASmB,EAAYJ,EAAU,QAAQ,GAAG,QAAQ,GAClDjB,IAAOqB,EAAYJ,EAAU,MAAM,GAAG,MAAM,GAE5Cd,IAAOkB,EAAYJ,EAAU,KAAK,GAAG,MAAM,GAC3CT,IAAea,EAAYJ,EAAU,KAAK,GAAG,cAAc,GAC3DZ,IAAcgB,EAAYJ,EAAU,KAAK,GAAG,aAAa,GACzDV,IAAYc,EAAYJ,EAAU,GAAG,GAAG,WAAW,GACnDX,IAAWe,EAAYC,GAAM,YAAY,EACpD,cAAc,EACZ,MAAM,KACR,EACF,CAAC,GACYlB,IAAYiB,EAAYE,GAAK,aAAa,EACrD,cAAc,EACZ,UAAU,UACZ,EACF,CAAC,GAEYtB,IAASoB,EAAYJ,EAAU,QAAQ,GAAG,QAAQ,GAElDR,IAAqBY,EAAYJ,EAAU,KAAK,GAAG,sBAAsB,EACpF,cAAc;CACZ,UAAU,MAAkC;EAC1C,EAAE,eAAe;EACjB,IAAMO,IAAWV,EAAqB,MAAM,WAAW,SAAS;EAGhE,AAFAC,EAAsBS,CAAQ,GAC9B,EAAE,cAAc,aAAa,cAAcA,CAAQ,GACnD,OAAO,cAAc,IAAI,MAAM,SAAS,CAAC;CAC3C;CACA,WAAW;CACX,GAAG,EAOD,IAAI,eAAe;EACjB,OAAOV,EAAqB;CAC9B,EACF;CACA,UACE,kBAACQ,GAAD,EAAA,UACE,kBAACzB,GAAD,CAAsB,CAAA,EAClB,CAAA;AAEV,EACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatDocumentMessage.cjs","names":["styled","HStack","chatDocumentMessage","Icon","DocumentTextIcon","Text","ArrowDownTrayIcon","require_Text","require_Icon","require_ArrowDownTrayIcon","require_DocumentTextIcon","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","StyledHStack","ChatDocumentMessage","props","onCardClick","event","documentID","documentName"],"sources":["../../../src/components/chat/ChatDocumentMessage.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { chatDocumentMessage } from '@stokelp/styled-system/recipes'\nimport { HStack, styled } from '@stokelp/styled-system/jsx'\nimport { Icon
|
|
1
|
+
{"version":3,"file":"ChatDocumentMessage.cjs","names":["styled","HStack","chatDocumentMessage","Icon","DocumentTextIcon","Text","ArrowDownTrayIcon","require_Text","require_Icon","require_ArrowDownTrayIcon","require_DocumentTextIcon","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","StyledHStack","ChatDocumentMessage","props","onCardClick","event","documentID","documentName"],"sources":["../../../src/components/chat/ChatDocumentMessage.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { chatDocumentMessage } from '@stokelp/styled-system/recipes'\nimport { HStack, styled } from '@stokelp/styled-system/jsx'\nimport { Icon } from '~/components/icon/Icon'\nimport { Text } from '~/components/text/Text'\nimport { DocumentTextIcon, ArrowDownTrayIcon } from '@heroicons/react/24/outline'\n\nexport type ChatDocumentMessageProps = {\n documentID: number | string\n documentName: string\n documentUrl?: string\n onCardClick?: (event: React.MouseEvent<HTMLDivElement>, documentID: number | string) => void\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof chatDocumentMessage>\n\nconst StyledHStack = styled(HStack, chatDocumentMessage)\n\nexport const ChatDocumentMessage: FC<ChatDocumentMessageProps> = ({\n documentID,\n documentName,\n onCardClick,\n ...props\n}) => {\n return (\n <StyledHStack\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n if (onCardClick) {\n onCardClick(event, documentID)\n }\n }}\n {...props}\n >\n <HStack gap=\"space-8\">\n <Icon size=\"xs\" color=\"primary.900\">\n <DocumentTextIcon />\n </Icon>\n <Text bold>{documentName}</Text>\n </HStack>\n <Icon size=\"xs\" color=\"primary.500\">\n <ArrowDownTrayIcon />\n </Icon>\n </StyledHStack>\n )\n}\n"],"mappings":"A,iXAgBA,IAAMc,GAAA,EAAed,EAAAA,OAAAA,CAAOC,EAAAA,OAAQC,EAAAA,mBAAmB,EAE1Ca,GAAqD,CAChE,aACA,eACA,cACA,GAAGC,MAGD,EAAAH,EAAA,KAAA,CAACC,EAAD,CACE,QAAU,GAA4C,CAChDG,GACFA,EAAYC,EAAOC,CAAU,CAEjC,EACA,GAAIH,EANN,SAAA,EAQE,EAAAH,EAAA,KAAA,CAACZ,EAAAA,OAAD,CAAQ,IAAI,UAAZ,SAAA,EACE,EAAAY,EAAA,IAAA,CAACV,EAAAA,KAAD,CAAM,KAAK,KAAK,MAAM,cACpB,UAAA,EAAAU,EAAA,IAAA,CAACT,EAAAA,QAAD,CAAmB,CAAA,CACf,CAAA,GACN,EAAAS,EAAA,IAAA,CAACR,EAAAA,KAAD,CAAM,KAAA,GAAM,SAAAe,CAAmB,CAAA,CACzB,CACR,CAAA,GAAA,EAAAP,EAAA,IAAA,CAACV,EAAAA,KAAD,CAAM,KAAK,KAAK,MAAM,cACpB,UAAA,EAAAU,EAAA,IAAA,CAACP,EAAAA,QAAD,CAAoB,CAAA,CAChB,CAAA,CACM,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatDocumentMessage.js","names":["DocumentTextIcon","ArrowDownTrayIcon","ForwardRef","ForwardRef$1","StyledHStack","styled","HStack","chatDocumentMessage","ChatDocumentMessage","props","onCardClick","event","documentID","Icon","Text","documentName"],"sources":["../../../src/components/chat/ChatDocumentMessage.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { chatDocumentMessage } from '@stokelp/styled-system/recipes'\nimport { HStack, styled } from '@stokelp/styled-system/jsx'\nimport { Icon
|
|
1
|
+
{"version":3,"file":"ChatDocumentMessage.js","names":["DocumentTextIcon","ArrowDownTrayIcon","ForwardRef","ForwardRef$1","StyledHStack","styled","HStack","chatDocumentMessage","ChatDocumentMessage","props","onCardClick","event","documentID","Icon","Text","documentName"],"sources":["../../../src/components/chat/ChatDocumentMessage.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { chatDocumentMessage } from '@stokelp/styled-system/recipes'\nimport { HStack, styled } from '@stokelp/styled-system/jsx'\nimport { Icon } from '~/components/icon/Icon'\nimport { Text } from '~/components/text/Text'\nimport { DocumentTextIcon, ArrowDownTrayIcon } from '@heroicons/react/24/outline'\n\nexport type ChatDocumentMessageProps = {\n documentID: number | string\n documentName: string\n documentUrl?: string\n onCardClick?: (event: React.MouseEvent<HTMLDivElement>, documentID: number | string) => void\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof chatDocumentMessage>\n\nconst StyledHStack = styled(HStack, chatDocumentMessage)\n\nexport const ChatDocumentMessage: FC<ChatDocumentMessageProps> = ({\n documentID,\n documentName,\n onCardClick,\n ...props\n}) => {\n return (\n <StyledHStack\n onClick={(event: React.MouseEvent<HTMLDivElement>) => {\n if (onCardClick) {\n onCardClick(event, documentID)\n }\n }}\n {...props}\n >\n <HStack gap=\"space-8\">\n <Icon size=\"xs\" color=\"primary.900\">\n <DocumentTextIcon />\n </Icon>\n <Text bold>{documentName}</Text>\n </HStack>\n <Icon size=\"xs\" color=\"primary.500\">\n <ArrowDownTrayIcon />\n </Icon>\n </StyledHStack>\n )\n}\n"],"mappings":";;;;;;;;;AAgBA,IAAMI,IAAeC,EAAOC,GAAQC,CAAmB,GAE1CC,KAAqD,EAChE,eACA,iBACA,gBACA,GAAGC,QAGD,kBAACL,GAAD;CACE,UAAU,MAA4C;EACpD,AAAIM,KACFA,EAAYC,GAAOC,CAAU;CAEjC;CACA,GAAIH;CANN,UAAA,CAQE,kBAACH,GAAD;EAAQ,KAAI;EAAZ,UAAA,CACE,kBAACO,GAAD;GAAM,MAAK;GAAK,OAAM;GACpB,UAAA,kBAACb,GAAD,CAAmB,CAAA;EACf,CAAA,GACN,kBAACc,GAAD;GAAM,MAAA;GAAM,UAAAC;EAAmB,CAAA,CACzB;CACR,CAAA,GAAA,kBAACF,GAAD;EAAM,MAAK;EAAK,OAAM;EACpB,UAAA,kBAACZ,GAAD,CAAoB,CAAA;CAChB,CAAA,CACM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatProfileAvatar.cjs","names":["styled","Box","chatProfileAvatar","Text","require_Text","require_styled","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","StyledHStack","ChatProfileAvatar","props","imageUrl","fallbackText","name"],"sources":["../../../src/components/chat/ChatProfileAvatar.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { Box, styled } from '@stokelp/styled-system/jsx'\nimport { Avatar
|
|
1
|
+
{"version":3,"file":"ChatProfileAvatar.cjs","names":["styled","Box","chatProfileAvatar","Text","require_Text","require_styled","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react_jsx_runtime","StyledHStack","ChatProfileAvatar","props","imageUrl","fallbackText","name"],"sources":["../../../src/components/chat/ChatProfileAvatar.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { Box, styled } from '@stokelp/styled-system/jsx'\nimport { Avatar } from '~/components/avatar'\nimport { Text } from '~/components/text/Text'\nimport { chatProfileAvatar } from '@stokelp/styled-system/recipes'\n\nexport type ChatProfileAvatarProps = {\n name: string\n fallbackText: string\n imageUrl?: string\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof chatProfileAvatar>\n\nconst StyledHStack = styled(Box, chatProfileAvatar)\n\nexport const ChatProfileAvatar: FC<ChatProfileAvatarProps> = ({ name, fallbackText, imageUrl, ...props }) => {\n return (\n <StyledHStack {...props}>\n <Avatar.Root border=\"solid 1px\" borderColor=\"grey.100\" hasBorder>\n <Avatar.Image src={imageUrl} />\n <Avatar.Fallback>{fallbackText}</Avatar.Fallback>\n </Avatar.Root>\n <Text bold size=\"sm\" color=\"primary.900\">\n {name}\n </Text>\n </StyledHStack>\n )\n}\n"],"mappings":"A,0MAcA,IAAMS,GAAA,EAAeT,EAAAA,OAAAA,CAAOC,EAAAA,IAAKC,EAAAA,iBAAiB,EAErCQ,GAAiD,CAAE,OAAM,eAAc,WAAU,GAAGC,MAE7F,EAAAH,EAAA,KAAA,CAACC,EAAD,CAAc,GAAIE,EAAlB,SAAA,EACE,EAAAH,EAAA,KAAA,CAAAH,EAAA,KAAA,CAAa,OAAO,YAAY,YAAY,WAAW,UAAA,GAAvD,SAAA,EACE,EAAAG,EAAA,IAAA,CAAAH,EAAA,MAAA,CAAc,IAAKO,CAAW,CAAA,GAC9B,EAAAJ,EAAA,IAAA,CAAAH,EAAA,SAAA,CAAA,SAAkBQ,CAA8B,CAAA,CACrC,CACb,CAAA,GAAA,EAAAL,EAAA,IAAA,CAACL,EAAAA,KAAD,CAAM,KAAA,GAAK,KAAK,KAAK,MAAM,cACxB,SAAAW,CACG,CAAA,CACM,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatProfileAvatar.js","names":["Avatar.Root","Avatar.Image","Avatar.Fallback","StyledHStack","styled","Box","chatProfileAvatar","ChatProfileAvatar","props","Root","Image","imageUrl","Fallback","fallbackText","Text","name"],"sources":["../../../src/components/chat/ChatProfileAvatar.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { Box, styled } from '@stokelp/styled-system/jsx'\nimport { Avatar
|
|
1
|
+
{"version":3,"file":"ChatProfileAvatar.js","names":["Avatar.Root","Avatar.Image","Avatar.Fallback","StyledHStack","styled","Box","chatProfileAvatar","ChatProfileAvatar","props","Root","Image","imageUrl","Fallback","fallbackText","Text","name"],"sources":["../../../src/components/chat/ChatProfileAvatar.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { Box, styled } from '@stokelp/styled-system/jsx'\nimport { Avatar } from '~/components/avatar'\nimport { Text } from '~/components/text/Text'\nimport { chatProfileAvatar } from '@stokelp/styled-system/recipes'\n\nexport type ChatProfileAvatarProps = {\n name: string\n fallbackText: string\n imageUrl?: string\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof chatProfileAvatar>\n\nconst StyledHStack = styled(Box, chatProfileAvatar)\n\nexport const ChatProfileAvatar: FC<ChatProfileAvatarProps> = ({ name, fallbackText, imageUrl, ...props }) => {\n return (\n <StyledHStack {...props}>\n <Avatar.Root border=\"solid 1px\" borderColor=\"grey.100\" hasBorder>\n <Avatar.Image src={imageUrl} />\n <Avatar.Fallback>{fallbackText}</Avatar.Fallback>\n </Avatar.Root>\n <Text bold size=\"sm\" color=\"primary.900\">\n {name}\n </Text>\n </StyledHStack>\n )\n}\n"],"mappings":";;;;;;;AAcA,IAAMG,IAAeC,EAAOC,GAAKC,CAAiB,GAErCC,KAAiD,EAAE,SAAM,iBAAc,aAAU,GAAGC,QAE7F,kBAACL,GAAD;CAAc,GAAIK;CAAlB,UAAA,CACE,kBAACR,GAAD;EAAa,QAAO;EAAY,aAAY;EAAW,WAAA;EAAvD,UAAA,CACE,kBAACC,GAAD,EAAc,KAAKU,EAAW,CAAA,GAC9B,kBAACT,GAAD,EAAA,UAAkBW,EAA8B,CAAA,CACrC;CACb,CAAA,GAAA,kBAACC,GAAD;EAAM,MAAA;EAAK,MAAK;EAAK,OAAM;EACxB,UAAAC;CACG,CAAA,CACM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatScoreBreakdown.cjs","names":["Box","HStack","Text","VStack","_Fragment","require_Text","_stokelp_styled_system_jsx","react_jsx_runtime","PACKAGING_TYPOLOGY_ID","ATTRIBUTE_ORDER","FOOD_ONLY_KEYS","PACKAGING_ONLY_KEYS","LEVEL_COLORS","getHeadlineColor","percent","getBarColor","ratioPercent","hasLevel","detail","isFraction","isComparable","ChatScoreBreakdown","isPackaging","typologyId","key","hiddenKeys","visibleKeys","compared","notSpecified","labels","entry","level","colors","matched","total"],"sources":["../../../src/components/chat/ChatScoreBreakdown.tsx"],"sourcesContent":["import { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\nimport { Text } from '~/components'\n\nexport type ScoreSetAttributeKey =\n 'origin' | 'rawMaterialOrigin' | 'temperature' | 'cutting' | 'cooking' | 'treatment' | 'label' | 'packaging'\n\nexport type ScoreNumericAttributeKey = 'grammageGsm' | 'recycledPct' | 'thicknessMicron'\n\nexport type ScoreAttributeKey = ScoreSetAttributeKey | ScoreNumericAttributeKey\n\n/** Proximity bucket for free numeric packaging specs: egal (equal) → non_correspondant (no match). */\nexport type ScoreLevel = 'egal' | 'proche' | 'eloigne' | 'non_correspondant'\n\nexport type ScoreAttributeDetail = {\n matched: number | null\n total: number | null\n level?: ScoreLevel | null\n}\n\nexport type ChatScoreBreakdownLabels = {\n title: string\n compared: string\n notSpecified: string\n attributes: Record<ScoreSetAttributeKey, string> & Partial<Record<ScoreNumericAttributeKey, string>>\n levels?: Record<ScoreLevel, string>\n footer?: string\n}\n\nexport type ChatScoreBreakdownProps = {\n percent: number\n detail: Record<string, ScoreAttributeDetail>\n labels: ChatScoreBreakdownLabels\n /** Typology id of the AO product (1 = packaging). When provided, drives which attribute family is shown; falls back to inferring from the numeric specs when absent. */\n typologyId?: number\n}\n\nconst PACKAGING_TYPOLOGY_ID = 1\n\nconst ATTRIBUTE_ORDER: ScoreAttributeKey[] = [\n 'origin',\n 'rawMaterialOrigin',\n 'temperature',\n 'cutting',\n 'cooking',\n 'treatment',\n 'label',\n 'packaging',\n 'grammageGsm',\n 'recycledPct',\n 'thicknessMicron',\n]\n\n// Attributes that only exist for food products; hidden for packaging products.\nconst FOOD_ONLY_KEYS: ScoreAttributeKey[] = ['temperature', 'cutting', 'cooking']\n// Free numeric specs that only exist for packaging products; hidden for food products.\nconst PACKAGING_ONLY_KEYS: ScoreNumericAttributeKey[] = ['grammageGsm', 'recycledPct', 'thicknessMicron']\n\nconst LEVEL_COLORS: Record<ScoreLevel, { bg: string; color: string }> = {\n egal: { bg: '#E6F3D9', color: '#3B6D11' },\n proche: { bg: '#F0F6DC', color: '#5E8516' },\n eloigne: { bg: '#FDF0E0', color: '#C2740C' },\n non_correspondant: { bg: '#FCEBEB', color: '#A32D2D' },\n}\n\nfunction getHeadlineColor(percent: number): string {\n if (percent >= 70) return '#3B6D11'\n if (percent >= 40) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\nfunction hasLevel(detail?: ScoreAttributeDetail): boolean {\n return detail?.level != null\n}\n\nfunction isFraction(detail?: ScoreAttributeDetail): boolean {\n return detail?.matched != null && detail?.total != null\n}\n\nfunction isComparable(detail?: ScoreAttributeDetail): boolean {\n return hasLevel(detail) || isFraction(detail)\n}\n\nexport const ChatScoreBreakdown = ({ percent, detail, labels, typologyId }: ChatScoreBreakdownProps) => {\n // A packaging product hides food attributes (temperature/cutting/cooking) and shows the\n // numeric specs, and vice versa. Two independent signals mark a packaging product, combined\n // so neither can wrongly override the other: the AO product typology (authoritative, and the\n // only signal when no numeric spec is comparable), and the presence of a comparable numeric\n // spec (covers cases where the typology is absent or not sent as the expected value).\n const isPackaging =\n Number(typologyId) === PACKAGING_TYPOLOGY_ID || PACKAGING_ONLY_KEYS.some(key => detail[key]?.level != null)\n const hiddenKeys = new Set<ScoreAttributeKey>(isPackaging ? FOOD_ONLY_KEYS : PACKAGING_ONLY_KEYS)\n const visibleKeys = ATTRIBUTE_ORDER.filter(key => !hiddenKeys.has(key))\n\n const compared = visibleKeys.filter(key => isComparable(detail[key]))\n const notSpecified = visibleKeys.filter(key => !isComparable(detail[key]) && labels.attributes[key] != null)\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"220px\"\n maxW=\"240px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(percent) }}>\n {Math.round(percent)} %\n </Text>\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n {compared.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.compared}\n </Text>\n {compared.map(key => {\n const entry = detail[key]\n if (hasLevel(entry)) {\n const level = entry.level as ScoreLevel\n const colors = LEVEL_COLORS[level]\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\" justify=\"space-between\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n h=\"100%\"\n px=\"space-6\"\n borderRadius=\"full\"\n flexShrink=\"0\"\n style={{ backgroundColor: colors.bg }}\n >\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n style={{ color: colors.color, whiteSpace: 'nowrap', lineHeight: 1 }}\n >\n {labels.levels?.[level] ?? level}\n </Text>\n </Box>\n </HStack>\n )\n }\n\n const matched = entry.matched as number\n const total = entry.total as number\n const ratioPercent = total > 0 ? (matched / total) * 100 : 0\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box flex=\"1\" h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{ width: `${ratioPercent}%`, background: getBarColor(ratioPercent) }}\n />\n </Box>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n minW=\"40px\"\n textAlign=\"right\"\n style={{ color: getBarColor(ratioPercent), lineHeight: 1 }}\n >\n {matched}/{total}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n )}\n\n {compared.length > 0 && notSpecified.length > 0 && <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />}\n\n {notSpecified.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.notSpecified}\n </Text>\n <HStack flexWrap=\"wrap\" gap=\"space-4\">\n {notSpecified.map(key => (\n <Text\n key={key}\n as=\"span\"\n fontSize=\"body.sm\"\n color=\"grey.400\"\n border=\"1px solid\"\n borderColor=\"grey.100\"\n px=\"space-8\"\n py=\"2px\"\n borderRadius=\"full\"\n >\n {labels.attributes[key]}\n </Text>\n ))}\n </HStack>\n </VStack>\n )}\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":"A,4HAoCA,IAAMQ,EAAwB,EAExBC,EAAuC,CAC3C,SACA,oBACA,cACA,UACA,UACA,YACA,QACA,YACA,cACA,cACA,iBACF,EAGMC,EAAsC,CAAC,cAAe,UAAW,SAAS,EAE1EC,EAAkD,CAAC,cAAe,cAAe,iBAAiB,EAElGC,EAAkE,CACtE,KAAM,CAAE,GAAI,UAAW,MAAO,SAAU,EACxC,OAAQ,CAAE,GAAI,UAAW,MAAO,SAAU,EAC1C,QAAS,CAAE,GAAI,UAAW,MAAO,SAAU,EAC3C,kBAAmB,CAAE,GAAI,UAAW,MAAO,SAAU,CACvD,EAEA,SAASC,EAAiB,EAAyB,CAGjD,OAFIC,GAAW,GAAW,UACtBA,GAAW,GAAW,UACnB,SACT,CAEA,SAASC,EAAY,EAA8B,CAGjD,OAFIC,GAAgB,GAAW,UAC3BA,GAAgB,GAAW,UACxB,SACT,CA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MAAM,WACN,OAAO,YACP,YAAY,WACZ,GAAG,UACH,GAAG,MACH,aAAa,OAEZ,SAAA2B,EAAO,WAAWL,EACf,EAXCA,CAWD,CACP,CACK,CAAA,CACF,C,GAGTK,EAAO,SACN,EAAAtB,EAAA,KAAA,CAAAH,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAG,EAAA,IAAA,CAACP,EAAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAAO,EAAA,IAAA,CAACL,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA2B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
|
|
1
|
+
{"version":3,"file":"ChatScoreBreakdown.cjs","names":["Box","HStack","Text","VStack","_Fragment","require_Text","_stokelp_styled_system_jsx","react_jsx_runtime","PACKAGING_TYPOLOGY_ID","ATTRIBUTE_ORDER","FOOD_ONLY_KEYS","PACKAGING_ONLY_KEYS","LEVEL_COLORS","getHeadlineColor","percent","getBarColor","ratioPercent","hasLevel","detail","isFraction","isComparable","ChatScoreBreakdown","isPackaging","typologyId","key","hiddenKeys","visibleKeys","compared","notSpecified","labels","entry","level","colors","matched","total"],"sources":["../../../src/components/chat/ChatScoreBreakdown.tsx"],"sourcesContent":["import { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\nimport { Text } from '~/components/text/Text'\n\nexport type ScoreSetAttributeKey =\n 'origin' | 'rawMaterialOrigin' | 'temperature' | 'cutting' | 'cooking' | 'treatment' | 'label' | 'packaging'\n\nexport type ScoreNumericAttributeKey = 'grammageGsm' | 'recycledPct' | 'thicknessMicron'\n\nexport type ScoreAttributeKey = ScoreSetAttributeKey | ScoreNumericAttributeKey\n\n/** Proximity bucket for free numeric packaging specs: egal (equal) → non_correspondant (no match). */\nexport type ScoreLevel = 'egal' | 'proche' | 'eloigne' | 'non_correspondant'\n\nexport type ScoreAttributeDetail = {\n matched: number | null\n total: number | null\n level?: ScoreLevel | null\n}\n\nexport type ChatScoreBreakdownLabels = {\n title: string\n compared: string\n notSpecified: string\n attributes: Record<ScoreSetAttributeKey, string> & Partial<Record<ScoreNumericAttributeKey, string>>\n levels?: Record<ScoreLevel, string>\n footer?: string\n}\n\nexport type ChatScoreBreakdownProps = {\n percent: number\n detail: Record<string, ScoreAttributeDetail>\n labels: ChatScoreBreakdownLabels\n /** Typology id of the AO product (1 = packaging). When provided, drives which attribute family is shown; falls back to inferring from the numeric specs when absent. */\n typologyId?: number\n}\n\nconst PACKAGING_TYPOLOGY_ID = 1\n\nconst ATTRIBUTE_ORDER: ScoreAttributeKey[] = [\n 'origin',\n 'rawMaterialOrigin',\n 'temperature',\n 'cutting',\n 'cooking',\n 'treatment',\n 'label',\n 'packaging',\n 'grammageGsm',\n 'recycledPct',\n 'thicknessMicron',\n]\n\n// Attributes that only exist for food products; hidden for packaging products.\nconst FOOD_ONLY_KEYS: ScoreAttributeKey[] = ['temperature', 'cutting', 'cooking']\n// Free numeric specs that only exist for packaging products; hidden for food products.\nconst PACKAGING_ONLY_KEYS: ScoreNumericAttributeKey[] = ['grammageGsm', 'recycledPct', 'thicknessMicron']\n\nconst LEVEL_COLORS: Record<ScoreLevel, { bg: string; color: string }> = {\n egal: { bg: '#E6F3D9', color: '#3B6D11' },\n proche: { bg: '#F0F6DC', color: '#5E8516' },\n eloigne: { bg: '#FDF0E0', color: '#C2740C' },\n non_correspondant: { bg: '#FCEBEB', color: '#A32D2D' },\n}\n\nfunction getHeadlineColor(percent: number): string {\n if (percent >= 70) return '#3B6D11'\n if (percent >= 40) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\nfunction hasLevel(detail?: ScoreAttributeDetail): boolean {\n return detail?.level != null\n}\n\nfunction isFraction(detail?: ScoreAttributeDetail): boolean {\n return detail?.matched != null && detail?.total != null\n}\n\nfunction isComparable(detail?: ScoreAttributeDetail): boolean {\n return hasLevel(detail) || isFraction(detail)\n}\n\nexport const ChatScoreBreakdown = ({ percent, detail, labels, typologyId }: ChatScoreBreakdownProps) => {\n // A packaging product hides food attributes (temperature/cutting/cooking) and shows the\n // numeric specs, and vice versa. Two independent signals mark a packaging product, combined\n // so neither can wrongly override the other: the AO product typology (authoritative, and the\n // only signal when no numeric spec is comparable), and the presence of a comparable numeric\n // spec (covers cases where the typology is absent or not sent as the expected value).\n const isPackaging =\n Number(typologyId) === PACKAGING_TYPOLOGY_ID || PACKAGING_ONLY_KEYS.some(key => detail[key]?.level != null)\n const hiddenKeys = new Set<ScoreAttributeKey>(isPackaging ? FOOD_ONLY_KEYS : PACKAGING_ONLY_KEYS)\n const visibleKeys = ATTRIBUTE_ORDER.filter(key => !hiddenKeys.has(key))\n\n const compared = visibleKeys.filter(key => isComparable(detail[key]))\n const notSpecified = visibleKeys.filter(key => !isComparable(detail[key]) && labels.attributes[key] != null)\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"220px\"\n maxW=\"240px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(percent) }}>\n {Math.round(percent)} %\n </Text>\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n {compared.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.compared}\n </Text>\n {compared.map(key => {\n const entry = detail[key]\n if (hasLevel(entry)) {\n const level = entry.level as ScoreLevel\n const colors = LEVEL_COLORS[level]\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\" justify=\"space-between\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n h=\"100%\"\n px=\"space-6\"\n borderRadius=\"full\"\n flexShrink=\"0\"\n style={{ backgroundColor: colors.bg }}\n >\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n style={{ color: colors.color, whiteSpace: 'nowrap', lineHeight: 1 }}\n >\n {labels.levels?.[level] ?? level}\n </Text>\n </Box>\n </HStack>\n )\n }\n\n const matched = entry.matched as number\n const total = entry.total as number\n const ratioPercent = total > 0 ? (matched / total) * 100 : 0\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box flex=\"1\" h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{ width: `${ratioPercent}%`, background: getBarColor(ratioPercent) }}\n />\n </Box>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n minW=\"40px\"\n textAlign=\"right\"\n style={{ color: getBarColor(ratioPercent), lineHeight: 1 }}\n >\n {matched}/{total}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n )}\n\n {compared.length > 0 && notSpecified.length > 0 && <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />}\n\n {notSpecified.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.notSpecified}\n </Text>\n <HStack flexWrap=\"wrap\" gap=\"space-4\">\n {notSpecified.map(key => (\n <Text\n key={key}\n as=\"span\"\n fontSize=\"body.sm\"\n color=\"grey.400\"\n border=\"1px solid\"\n borderColor=\"grey.100\"\n px=\"space-8\"\n py=\"2px\"\n borderRadius=\"full\"\n >\n {labels.attributes[key]}\n </Text>\n ))}\n </HStack>\n </VStack>\n )}\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":"A,4HAoCA,IAAMQ,EAAwB,EAExBC,EAAuC,CAC3C,SACA,oBACA,cACA,UACA,UACA,YACA,QACA,YACA,cACA,cACA,iBACF,EAGMC,EAAsC,CAAC,cAAe,UAAW,SAAS,EAE1EC,EAAkD,CAAC,cAAe,cAAe,iBAAiB,EAElGC,EAAkE,CACtE,KAAM,CAAE,GAAI,UAAW,MAAO,SAAU,EACxC,OAAQ,CAAE,GAAI,UAAW,MAAO,SAAU,EAC1C,QAAS,CAAE,GAAI,UAAW,MAAO,SAAU,EAC3C,kBAAmB,CAAE,GAAI,UAAW,MAAO,SAAU,CACvD,EAEA,SAASC,EAAiB,EAAyB,CAGjD,OAFIC,GAAW,GAAW,UACtBA,GAAW,GAAW,UACnB,SACT,CAEA,SAASC,EAAY,EAA8B,CAGjD,OAFIC,GAAgB,GAAW,UAC3BA,GAAgB,GAAW,UACxB,SACT,CAEA,SAASC,EAAS,EAAwC,CACxD,OAAOC,GAAQ,OAAS,IAC1B,CAEA,SAASC,EAAW,EAAwC,CAC1D,OAAOD,GAAQ,SAAW,MAAQA,GAAQ,OAAS,IACrD,CAEA,SAASE,EAAa,EAAwC,CAC5D,OAAOH,EAASC,CAAM,GAAKC,EAAWD,CAAM,CAC9C,CAEA,IAAaG,GAAsB,CAAE,UAAS,SAAQ,SAAQ,gBAA0C,CAMtG,IAAMC,EACJ,OAAOC,CAAU,IAAM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D,EAAAO,EAAA,IAAA,CAACL,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA2B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatScoreBreakdown.js","names":["_Fragment","PACKAGING_TYPOLOGY_ID","ATTRIBUTE_ORDER","FOOD_ONLY_KEYS","PACKAGING_ONLY_KEYS","LEVEL_COLORS","getHeadlineColor","percent","getBarColor","ratioPercent","hasLevel","detail","isFraction","isComparable","ChatScoreBreakdown","isPackaging","typologyId","key","hiddenKeys","visibleKeys","compared","notSpecified","labels","Box","HStack","Text","VStack","entry","level","colors","matched","total","Fragment"],"sources":["../../../src/components/chat/ChatScoreBreakdown.tsx"],"sourcesContent":["import { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\nimport { Text } from '~/components'\n\nexport type ScoreSetAttributeKey =\n 'origin' | 'rawMaterialOrigin' | 'temperature' | 'cutting' | 'cooking' | 'treatment' | 'label' | 'packaging'\n\nexport type ScoreNumericAttributeKey = 'grammageGsm' | 'recycledPct' | 'thicknessMicron'\n\nexport type ScoreAttributeKey = ScoreSetAttributeKey | ScoreNumericAttributeKey\n\n/** Proximity bucket for free numeric packaging specs: egal (equal) → non_correspondant (no match). */\nexport type ScoreLevel = 'egal' | 'proche' | 'eloigne' | 'non_correspondant'\n\nexport type ScoreAttributeDetail = {\n matched: number | null\n total: number | null\n level?: ScoreLevel | null\n}\n\nexport type ChatScoreBreakdownLabels = {\n title: string\n compared: string\n notSpecified: string\n attributes: Record<ScoreSetAttributeKey, string> & Partial<Record<ScoreNumericAttributeKey, string>>\n levels?: Record<ScoreLevel, string>\n footer?: string\n}\n\nexport type ChatScoreBreakdownProps = {\n percent: number\n detail: Record<string, ScoreAttributeDetail>\n labels: ChatScoreBreakdownLabels\n /** Typology id of the AO product (1 = packaging). When provided, drives which attribute family is shown; falls back to inferring from the numeric specs when absent. */\n typologyId?: number\n}\n\nconst PACKAGING_TYPOLOGY_ID = 1\n\nconst ATTRIBUTE_ORDER: ScoreAttributeKey[] = [\n 'origin',\n 'rawMaterialOrigin',\n 'temperature',\n 'cutting',\n 'cooking',\n 'treatment',\n 'label',\n 'packaging',\n 'grammageGsm',\n 'recycledPct',\n 'thicknessMicron',\n]\n\n// Attributes that only exist for food products; hidden for packaging products.\nconst FOOD_ONLY_KEYS: ScoreAttributeKey[] = ['temperature', 'cutting', 'cooking']\n// Free numeric specs that only exist for packaging products; hidden for food products.\nconst PACKAGING_ONLY_KEYS: ScoreNumericAttributeKey[] = ['grammageGsm', 'recycledPct', 'thicknessMicron']\n\nconst LEVEL_COLORS: Record<ScoreLevel, { bg: string; color: string }> = {\n egal: { bg: '#E6F3D9', color: '#3B6D11' },\n proche: { bg: '#F0F6DC', color: '#5E8516' },\n eloigne: { bg: '#FDF0E0', color: '#C2740C' },\n non_correspondant: { bg: '#FCEBEB', color: '#A32D2D' },\n}\n\nfunction getHeadlineColor(percent: number): string {\n if (percent >= 70) return '#3B6D11'\n if (percent >= 40) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\nfunction hasLevel(detail?: ScoreAttributeDetail): boolean {\n return detail?.level != null\n}\n\nfunction isFraction(detail?: ScoreAttributeDetail): boolean {\n return detail?.matched != null && detail?.total != null\n}\n\nfunction isComparable(detail?: ScoreAttributeDetail): boolean {\n return hasLevel(detail) || isFraction(detail)\n}\n\nexport const ChatScoreBreakdown = ({ percent, detail, labels, typologyId }: ChatScoreBreakdownProps) => {\n // A packaging product hides food attributes (temperature/cutting/cooking) and shows the\n // numeric specs, and vice versa. Two independent signals mark a packaging product, combined\n // so neither can wrongly override the other: the AO product typology (authoritative, and the\n // only signal when no numeric spec is comparable), and the presence of a comparable numeric\n // spec (covers cases where the typology is absent or not sent as the expected value).\n const isPackaging =\n Number(typologyId) === PACKAGING_TYPOLOGY_ID || PACKAGING_ONLY_KEYS.some(key => detail[key]?.level != null)\n const hiddenKeys = new Set<ScoreAttributeKey>(isPackaging ? FOOD_ONLY_KEYS : PACKAGING_ONLY_KEYS)\n const visibleKeys = ATTRIBUTE_ORDER.filter(key => !hiddenKeys.has(key))\n\n const compared = visibleKeys.filter(key => isComparable(detail[key]))\n const notSpecified = visibleKeys.filter(key => !isComparable(detail[key]) && labels.attributes[key] != null)\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"220px\"\n maxW=\"240px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(percent) }}>\n {Math.round(percent)} %\n </Text>\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n {compared.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.compared}\n </Text>\n {compared.map(key => {\n const entry = detail[key]\n if (hasLevel(entry)) {\n const level = entry.level as ScoreLevel\n const colors = LEVEL_COLORS[level]\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\" justify=\"space-between\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n h=\"100%\"\n px=\"space-6\"\n borderRadius=\"full\"\n flexShrink=\"0\"\n style={{ backgroundColor: colors.bg }}\n >\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n style={{ color: colors.color, whiteSpace: 'nowrap', lineHeight: 1 }}\n >\n {labels.levels?.[level] ?? level}\n </Text>\n </Box>\n </HStack>\n )\n }\n\n const matched = entry.matched as number\n const total = entry.total as number\n const ratioPercent = total > 0 ? (matched / total) * 100 : 0\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box flex=\"1\" h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{ width: `${ratioPercent}%`, background: getBarColor(ratioPercent) }}\n />\n </Box>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n minW=\"40px\"\n textAlign=\"right\"\n style={{ color: getBarColor(ratioPercent), lineHeight: 1 }}\n >\n {matched}/{total}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n )}\n\n {compared.length > 0 && notSpecified.length > 0 && <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />}\n\n {notSpecified.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.notSpecified}\n </Text>\n <HStack flexWrap=\"wrap\" gap=\"space-4\">\n {notSpecified.map(key => (\n <Text\n key={key}\n as=\"span\"\n fontSize=\"body.sm\"\n color=\"grey.400\"\n border=\"1px solid\"\n borderColor=\"grey.100\"\n px=\"space-8\"\n py=\"2px\"\n borderRadius=\"full\"\n >\n {labels.attributes[key]}\n </Text>\n ))}\n </HStack>\n </VStack>\n )}\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.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,kBAACI,GAAD;MAEE,IAAG;MACH,UAAS;MACT,OAAM;MACN,QAAO;MACP,aAAY;MACZ,IAAG;MACH,IAAG;MACH,cAAa;MAEZ,UAAAH,EAAO,WAAWL;KACf,GAXCA,CAWD,CACP;IACK,CAAA,CACF;;GAGTK,EAAO,UACN,kBAAAtB,GAAA,EAAA,UAAA,CACE,kBAACuB,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAACE,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;IACpE,UAAAH,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
|
|
1
|
+
{"version":3,"file":"ChatScoreBreakdown.js","names":["_Fragment","PACKAGING_TYPOLOGY_ID","ATTRIBUTE_ORDER","FOOD_ONLY_KEYS","PACKAGING_ONLY_KEYS","LEVEL_COLORS","getHeadlineColor","percent","getBarColor","ratioPercent","hasLevel","detail","isFraction","isComparable","ChatScoreBreakdown","isPackaging","typologyId","key","hiddenKeys","visibleKeys","compared","notSpecified","labels","Box","HStack","Text","VStack","entry","level","colors","matched","total","Fragment"],"sources":["../../../src/components/chat/ChatScoreBreakdown.tsx"],"sourcesContent":["import { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\nimport { Text } from '~/components/text/Text'\n\nexport type ScoreSetAttributeKey =\n 'origin' | 'rawMaterialOrigin' | 'temperature' | 'cutting' | 'cooking' | 'treatment' | 'label' | 'packaging'\n\nexport type ScoreNumericAttributeKey = 'grammageGsm' | 'recycledPct' | 'thicknessMicron'\n\nexport type ScoreAttributeKey = ScoreSetAttributeKey | ScoreNumericAttributeKey\n\n/** Proximity bucket for free numeric packaging specs: egal (equal) → non_correspondant (no match). */\nexport type ScoreLevel = 'egal' | 'proche' | 'eloigne' | 'non_correspondant'\n\nexport type ScoreAttributeDetail = {\n matched: number | null\n total: number | null\n level?: ScoreLevel | null\n}\n\nexport type ChatScoreBreakdownLabels = {\n title: string\n compared: string\n notSpecified: string\n attributes: Record<ScoreSetAttributeKey, string> & Partial<Record<ScoreNumericAttributeKey, string>>\n levels?: Record<ScoreLevel, string>\n footer?: string\n}\n\nexport type ChatScoreBreakdownProps = {\n percent: number\n detail: Record<string, ScoreAttributeDetail>\n labels: ChatScoreBreakdownLabels\n /** Typology id of the AO product (1 = packaging). When provided, drives which attribute family is shown; falls back to inferring from the numeric specs when absent. */\n typologyId?: number\n}\n\nconst PACKAGING_TYPOLOGY_ID = 1\n\nconst ATTRIBUTE_ORDER: ScoreAttributeKey[] = [\n 'origin',\n 'rawMaterialOrigin',\n 'temperature',\n 'cutting',\n 'cooking',\n 'treatment',\n 'label',\n 'packaging',\n 'grammageGsm',\n 'recycledPct',\n 'thicknessMicron',\n]\n\n// Attributes that only exist for food products; hidden for packaging products.\nconst FOOD_ONLY_KEYS: ScoreAttributeKey[] = ['temperature', 'cutting', 'cooking']\n// Free numeric specs that only exist for packaging products; hidden for food products.\nconst PACKAGING_ONLY_KEYS: ScoreNumericAttributeKey[] = ['grammageGsm', 'recycledPct', 'thicknessMicron']\n\nconst LEVEL_COLORS: Record<ScoreLevel, { bg: string; color: string }> = {\n egal: { bg: '#E6F3D9', color: '#3B6D11' },\n proche: { bg: '#F0F6DC', color: '#5E8516' },\n eloigne: { bg: '#FDF0E0', color: '#C2740C' },\n non_correspondant: { bg: '#FCEBEB', color: '#A32D2D' },\n}\n\nfunction getHeadlineColor(percent: number): string {\n if (percent >= 70) return '#3B6D11'\n if (percent >= 40) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\nfunction hasLevel(detail?: ScoreAttributeDetail): boolean {\n return detail?.level != null\n}\n\nfunction isFraction(detail?: ScoreAttributeDetail): boolean {\n return detail?.matched != null && detail?.total != null\n}\n\nfunction isComparable(detail?: ScoreAttributeDetail): boolean {\n return hasLevel(detail) || isFraction(detail)\n}\n\nexport const ChatScoreBreakdown = ({ percent, detail, labels, typologyId }: ChatScoreBreakdownProps) => {\n // A packaging product hides food attributes (temperature/cutting/cooking) and shows the\n // numeric specs, and vice versa. Two independent signals mark a packaging product, combined\n // so neither can wrongly override the other: the AO product typology (authoritative, and the\n // only signal when no numeric spec is comparable), and the presence of a comparable numeric\n // spec (covers cases where the typology is absent or not sent as the expected value).\n const isPackaging =\n Number(typologyId) === PACKAGING_TYPOLOGY_ID || PACKAGING_ONLY_KEYS.some(key => detail[key]?.level != null)\n const hiddenKeys = new Set<ScoreAttributeKey>(isPackaging ? FOOD_ONLY_KEYS : PACKAGING_ONLY_KEYS)\n const visibleKeys = ATTRIBUTE_ORDER.filter(key => !hiddenKeys.has(key))\n\n const compared = visibleKeys.filter(key => isComparable(detail[key]))\n const notSpecified = visibleKeys.filter(key => !isComparable(detail[key]) && labels.attributes[key] != null)\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"220px\"\n maxW=\"240px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(percent) }}>\n {Math.round(percent)} %\n </Text>\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n {compared.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.compared}\n </Text>\n {compared.map(key => {\n const entry = detail[key]\n if (hasLevel(entry)) {\n const level = entry.level as ScoreLevel\n const colors = LEVEL_COLORS[level]\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\" justify=\"space-between\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n h=\"100%\"\n px=\"space-6\"\n borderRadius=\"full\"\n flexShrink=\"0\"\n style={{ backgroundColor: colors.bg }}\n >\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n style={{ color: colors.color, whiteSpace: 'nowrap', lineHeight: 1 }}\n >\n {labels.levels?.[level] ?? level}\n </Text>\n </Box>\n </HStack>\n )\n }\n\n const matched = entry.matched as number\n const total = entry.total as number\n const ratioPercent = total > 0 ? (matched / total) * 100 : 0\n return (\n <HStack key={key} h=\"18px\" alignItems=\"center\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\" minW=\"80px\">\n {labels.attributes[key]}\n </Text>\n <Box flex=\"1\" h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{ width: `${ratioPercent}%`, background: getBarColor(ratioPercent) }}\n />\n </Box>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n minW=\"40px\"\n textAlign=\"right\"\n style={{ color: getBarColor(ratioPercent), lineHeight: 1 }}\n >\n {matched}/{total}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n )}\n\n {compared.length > 0 && notSpecified.length > 0 && <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />}\n\n {notSpecified.length > 0 && (\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.notSpecified}\n </Text>\n <HStack flexWrap=\"wrap\" gap=\"space-4\">\n {notSpecified.map(key => (\n <Text\n key={key}\n as=\"span\"\n fontSize=\"body.sm\"\n color=\"grey.400\"\n border=\"1px solid\"\n borderColor=\"grey.100\"\n px=\"space-8\"\n py=\"2px\"\n borderRadius=\"full\"\n >\n {labels.attributes[key]}\n </Text>\n ))}\n </HStack>\n </VStack>\n )}\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":";;;;;AAoCA,IAAMC,IAAwB,GAExBC,IAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAGMC,IAAsC;CAAC;CAAe;CAAW;AAAS,GAE1EC,IAAkD;CAAC;CAAe;CAAe;AAAiB,GAElGC,IAAkE;CACtE,MAAM;EAAE,IAAI;EAAW,OAAO;CAAU;CACxC,QAAQ;EAAE,IAAI;EAAW,OAAO;CAAU;CAC1C,SAAS;EAAE,IAAI;EAAW,OAAO;CAAU;CAC3C,mBAAmB;EAAE,IAAI;EAAW,OAAO;CAAU;AACvD;AAEA,SAASC,EAAiB,GAAyB;CAGjD,OAFIC,KAAW,KAAW,YACtBA,KAAW,KAAW,YACnB;AACT;AAEA,SAASC,EAAY,GAA8B;CAGjD,OAFIC,KAAgB,KAAW,YAC3BA,KAAgB,KAAW,YACxB;AACT;AAEA,SAASC,EAAS,GAAwC;CACxD,OAAOC,GAAQ,SAAS;AAC1B;AAEA,SAASC,EAAW,GAAwC;CAC1D,OAAOD,GAAQ,WAAW,QAAQA,GAAQ,SAAS;AACrD;AAEA,SAASE,EAAa,GAAwC;CAC5D,OAAOH,EAASC,CAAM,KAAKC,EAAWD,CAAM;AAC9C;AAEA,IAAaG,KAAsB,EAAE,YAAS,WAAQ,WAAQ,oBAA0C;CAMtG,IAAMC,IACJ,OAAOC,CAAU,MAAMf,KAAyBG,EAAoB,MAAK,MAAOO,EAAOM,EAAI,EAAE,SAAS,IAAI,GACtGC,IAAa,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AAA;GAE3FF,EAAa,SAAS,KACrB,kBAACK,GAAD;IAAQ,YAAW;IAAU,KAAI;IAAjC,UAAA,CACE,kBAACD,GAAD;KAAM,IAAG;KAAO,UAAS;KAAU,YAAW;KAAO,OAAM;KACxD,UAAAH,EAAO;IACJ,CAAA,GACN,kBAACE,GAAD;KAAQ,UAAS;KAAO,KAAI;KACzB,UAAAH,EAAa,KAAI,MAChB,kBAACI,GAAD;MAEE,IAAG;MACH,UAAS;MACT,OAAM;MACN,QAAO;MACP,aAAY;MACZ,IAAG;MACH,IAAG;MACH,cAAa;MAEZ,UAAAH,EAAO,WAAWL;KACf,GAXCA,CAWD,CACP;IACK,CAAA,CACF;;GAGTK,EAAO,UACN,kBAAAtB,GAAA,EAAA,UAAA,CACE,kBAACuB,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAACE,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;IACpE,UAAAH,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatTextInput.cjs","names":["styled","Textarea","chatTextInput","useRef","useState","require_Textarea","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledTextarea","ChatTextInput","props","textareaRef","value","setValue","resize","el","computed","lineHeight","paddingTop","paddingBottom","minHeight","minRows","maxHeightPx","maxRows","scrollHeight","newHeight","onResize","onChange","text","onSend"],"sources":["../../../src/components/chat/ChatTextInput.tsx"],"sourcesContent":["import { useRef, useEffect, useState, KeyboardEvent, ChangeEvent } from 'react'\nimport { Textarea, TextareaProps } from '~/components'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { chatTextInput } from '@stokelp/styled-system/recipes'\n\ntype ChatTextInputProps = TextareaProps & {\n minRows?: number\n maxRows?: number\n onSend?: (message: string) => void\n}\n\nconst StyledTextarea = styled(Textarea, chatTextInput)\n\nexport const ChatTextInput: React.FC<ChatTextInputProps> = ({\n minRows = 1,\n maxRows = 6,\n onSend,\n onChange,\n ...props\n}) => {\n const textareaRef = useRef<HTMLTextAreaElement | null>(null)\n const [value, setValue] = useState('')\n\n const resize = () => {\n const el = textareaRef.current\n if (!el) return\n\n el.style.height = 'auto'\n\n const computed = window.getComputedStyle(el)\n const lineHeight = parseFloat(computed.lineHeight) || 20\n const paddingTop = parseFloat(computed.paddingTop)\n const paddingBottom = parseFloat(computed.paddingBottom)\n\n const minHeight = lineHeight * minRows + paddingTop + paddingBottom\n const maxHeightPx = lineHeight * maxRows + paddingTop + paddingBottom\n\n const scrollHeight = el.scrollHeight\n\n const newHeight = Math.min(scrollHeight, maxHeightPx)\n el.style.height = Math.max(newHeight, minHeight) + 'px'\n\n el.style.overflowY = scrollHeight > maxHeightPx ? 'auto' : 'hidden'\n el.style.scrollPaddingBottom = `${paddingBottom}px`\n }\n\n useEffect(() => {\n resize()\n const onResize = () => resize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [value])\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault()\n const text = value.trim()\n if (!text) {\n setValue('')\n resize()\n return\n }\n onSend?.(text)\n setValue('')\n requestAnimationFrame(() => {\n if (textareaRef.current) textareaRef.current.style.height = 'auto'\n resize()\n })\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!props?.maxLength || e.target.value.length < props?.maxLength) {\n setValue(e.target.value)\n onChange?.(e)\n }\n }\n\n return (\n <StyledTextarea\n ref={textareaRef}\n value={value}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n {...props}\n />\n )\n}\n"],"mappings":"A,mMAWA,IAAMU,GAAA,EAAiBV,EAAAA,OAAAA,CAAOC,EAAAA,SAAUC,EAAAA,aAAa,EAExCS,G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ACXC,EAAO,EACP,MACF,CACAe,IAASD,CAAI,EACbf,EAAS,EAAE,EACX,0BAA4B,CACtBF,EAAY,UAAS,EAAY,QAAQ,MAAM,OAAS,QAC5DG,EAAO,CACT,CAAC,CACH,CACF,EAeI,KAAMO,EACN,GAAIX,CACL,CAAA,CAEL,E"}
|
|
1
|
+
{"version":3,"file":"ChatTextInput.cjs","names":["styled","Textarea","chatTextInput","useRef","useState","require_Textarea","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","StyledTextarea","ChatTextInput","props","textareaRef","value","setValue","resize","el","computed","lineHeight","paddingTop","paddingBottom","minHeight","minRows","maxHeightPx","maxRows","scrollHeight","newHeight","onResize","onChange","text","onSend"],"sources":["../../../src/components/chat/ChatTextInput.tsx"],"sourcesContent":["import { useRef, useEffect, useState, KeyboardEvent, ChangeEvent } from 'react'\nimport { Textarea, TextareaProps } from '~/components/textarea/Textarea'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { chatTextInput } from '@stokelp/styled-system/recipes'\n\ntype ChatTextInputProps = TextareaProps & {\n minRows?: number\n maxRows?: number\n onSend?: (message: string) => void\n}\n\nconst StyledTextarea = styled(Textarea, chatTextInput)\n\nexport const ChatTextInput: React.FC<ChatTextInputProps> = ({\n minRows = 1,\n maxRows = 6,\n onSend,\n onChange,\n ...props\n}) => {\n const textareaRef = useRef<HTMLTextAreaElement | null>(null)\n const [value, setValue] = useState('')\n\n const resize = () => {\n const el = textareaRef.current\n if (!el) return\n\n el.style.height = 'auto'\n\n const computed = window.getComputedStyle(el)\n const lineHeight = parseFloat(computed.lineHeight) || 20\n const paddingTop = parseFloat(computed.paddingTop)\n const paddingBottom = parseFloat(computed.paddingBottom)\n\n const minHeight = lineHeight * minRows + paddingTop + paddingBottom\n const maxHeightPx = lineHeight * maxRows + paddingTop + paddingBottom\n\n const scrollHeight = el.scrollHeight\n\n const newHeight = Math.min(scrollHeight, maxHeightPx)\n el.style.height = Math.max(newHeight, minHeight) + 'px'\n\n el.style.overflowY = scrollHeight > maxHeightPx ? 'auto' : 'hidden'\n el.style.scrollPaddingBottom = `${paddingBottom}px`\n }\n\n useEffect(() => {\n resize()\n const onResize = () => resize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [value])\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault()\n const text = value.trim()\n if (!text) {\n setValue('')\n resize()\n return\n }\n onSend?.(text)\n setValue('')\n requestAnimationFrame(() => {\n if (textareaRef.current) textareaRef.current.style.height = 'auto'\n resize()\n })\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!props?.maxLength || e.target.value.length < props?.maxLength) {\n setValue(e.target.value)\n onChange?.(e)\n }\n }\n\n return (\n <StyledTextarea\n ref={textareaRef}\n value={value}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n {...props}\n />\n )\n}\n"],"mappings":"A,mMAWA,IAAMU,GAAA,EAAiBV,EAAAA,OAAAA,CAAOC,EAAAA,SAAUC,EAAAA,aAAa,EAExCS,GAA+C,CAC1D,UAAU,EACV,UAAU,EACV,SACA,WACA,GAAGC,KACC,CACJ,IAAMC,GAAA,EAAcV,EAAAA,OAAAA,CAAmC,IAAI,EACrD,CAACW,EAAOC,IAAA,EAAYX,EAAAA,SAAAA,CAAS,EAAE,EAE/BY,MAAe,CACnB,IAAMC,EAAKJ,EAAY,QACvB,GAAI,CAACI,EAAI,OAET,EAAG,MAAM,OAAS,OAElB,IAAMC,EAAW,OAAO,iBAAiBD,CAAE,EACrCE,EAAa,WAAWD,EAAS,UAAU,GAAK,GAChDE,EAAa,WAAWF,EAAS,UAAU,EAC3CG,EAAgB,WAAWH,EAAS,aAAa,EAEjDI,EAAYH,EAAaI,EAAUH,EAAaC,EAChDG,EAAcL,EAAaM,EAAUL,EAAaC,EAElDK,EAAeT,EAAG,aAElBU,EAAY,KAAK,IAAID,EAAcF,CAAW,EACpD,EAAG,MAAM,OAAS,KAAK,IAAIG,EAAWL,CAAS,EAAI,KAEnD,EAAG,MAAM,UAAYI,EAAeF,EAAc,OAAS,SAC3D,EAAG,MAAM,oBAAsB,GAAGH,EAAc,GAClD,EAkCA,OAhCA,EAAAb,EAAA,UAAA,KAAgB,CACdQ,EAAO,EACP,IAAMY,MAAiBZ,EAAO,EAE9B,OADA,OAAO,iBAAiB,SAAUY,CAAQ,MAC7B,OAAO,oBAAoB,SAAUA,CAAQ,CAC5D,EAAG,CAACd,CAAK,CAAC,GA4BR,EAAAL,EAAA,IAAA,CAACC,EAAD,CACE,IAAKG,EACE,QACP,SAXkB,GAAwC,EACxD,CAACD,GAAO,WAAa,EAAE,OAAO,MAAM,OAASA,GAAO,aACtDG,EAAS,EAAE,OAAO,KAAK,EACvBc,IAAW,CAAC,EAEhB,EAOI,UA9BmB,GAA0C,CAC/D,GAAI,EAAE,MAAQ,SAAW,CAAC,EAAE,SAAU,CACpC,EAAE,eAAe,EACjB,IAAMC,EAAOhB,EAAM,KAAK,EACxB,GAAI,CAACgB,EAAM,CACTf,EAAS,EAAE,EACXC,EAAO,EACP,MACF,CACAe,IAASD,CAAI,EACbf,EAAS,EAAE,EACX,0BAA4B,CACtBF,EAAY,UAAS,EAAY,QAAQ,MAAM,OAAS,QAC5DG,EAAO,CACT,CAAC,CACH,CACF,EAeI,KAAMO,EACN,GAAIX,CACL,CAAA,CAEL,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatTextInput.js","names":["StyledTextarea","styled","Textarea","chatTextInput","ChatTextInput","props","textareaRef","useRef","value","setValue","useState","resize","el","computed","lineHeight","paddingTop","paddingBottom","minHeight","minRows","maxHeightPx","maxRows","scrollHeight","newHeight","useEffect","onResize","onChange","text","onSend"],"sources":["../../../src/components/chat/ChatTextInput.tsx"],"sourcesContent":["import { useRef, useEffect, useState, KeyboardEvent, ChangeEvent } from 'react'\nimport { Textarea, TextareaProps } from '~/components'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { chatTextInput } from '@stokelp/styled-system/recipes'\n\ntype ChatTextInputProps = TextareaProps & {\n minRows?: number\n maxRows?: number\n onSend?: (message: string) => void\n}\n\nconst StyledTextarea = styled(Textarea, chatTextInput)\n\nexport const ChatTextInput: React.FC<ChatTextInputProps> = ({\n minRows = 1,\n maxRows = 6,\n onSend,\n onChange,\n ...props\n}) => {\n const textareaRef = useRef<HTMLTextAreaElement | null>(null)\n const [value, setValue] = useState('')\n\n const resize = () => {\n const el = textareaRef.current\n if (!el) return\n\n el.style.height = 'auto'\n\n const computed = window.getComputedStyle(el)\n const lineHeight = parseFloat(computed.lineHeight) || 20\n const paddingTop = parseFloat(computed.paddingTop)\n const paddingBottom = parseFloat(computed.paddingBottom)\n\n const minHeight = lineHeight * minRows + paddingTop + paddingBottom\n const maxHeightPx = lineHeight * maxRows + paddingTop + paddingBottom\n\n const scrollHeight = el.scrollHeight\n\n const newHeight = Math.min(scrollHeight, maxHeightPx)\n el.style.height = Math.max(newHeight, minHeight) + 'px'\n\n el.style.overflowY = scrollHeight > maxHeightPx ? 'auto' : 'hidden'\n el.style.scrollPaddingBottom = `${paddingBottom}px`\n }\n\n useEffect(() => {\n resize()\n const onResize = () => resize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [value])\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault()\n const text = value.trim()\n if (!text) {\n setValue('')\n resize()\n return\n }\n onSend?.(text)\n setValue('')\n requestAnimationFrame(() => {\n if (textareaRef.current) textareaRef.current.style.height = 'auto'\n resize()\n })\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!props?.maxLength || e.target.value.length < props?.maxLength) {\n setValue(e.target.value)\n onChange?.(e)\n }\n }\n\n return (\n <StyledTextarea\n ref={textareaRef}\n value={value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MC,IAAOlB,EAAM,KAAK;IACxB,IAAI,CAACkB,GAAM;KAET,AADAjB,EAAS,EAAE,GACXE,EAAO;KACP;IACF;IAGA,AAFAgB,IAASD,CAAI,GACbjB,EAAS,EAAE,GACX,4BAA4B;KAE1B,AADIH,EAAY,YAAS,EAAY,QAAQ,MAAM,SAAS,SAC5DK,EAAO;IACT,CAAC;GACH;EACF;EAeI,MAAMO;EACN,GAAIb;CACL,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"ChatTextInput.js","names":["StyledTextarea","styled","Textarea","chatTextInput","ChatTextInput","props","textareaRef","useRef","value","setValue","useState","resize","el","computed","lineHeight","paddingTop","paddingBottom","minHeight","minRows","maxHeightPx","maxRows","scrollHeight","newHeight","useEffect","onResize","onChange","text","onSend"],"sources":["../../../src/components/chat/ChatTextInput.tsx"],"sourcesContent":["import { useRef, useEffect, useState, KeyboardEvent, ChangeEvent } from 'react'\nimport { Textarea, TextareaProps } from '~/components/textarea/Textarea'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { chatTextInput } from '@stokelp/styled-system/recipes'\n\ntype ChatTextInputProps = TextareaProps & {\n minRows?: number\n maxRows?: number\n onSend?: (message: string) => void\n}\n\nconst StyledTextarea = styled(Textarea, chatTextInput)\n\nexport const ChatTextInput: React.FC<ChatTextInputProps> = ({\n minRows = 1,\n maxRows = 6,\n onSend,\n onChange,\n ...props\n}) => {\n const textareaRef = useRef<HTMLTextAreaElement | null>(null)\n const [value, setValue] = useState('')\n\n const resize = () => {\n const el = textareaRef.current\n if (!el) return\n\n el.style.height = 'auto'\n\n const computed = window.getComputedStyle(el)\n const lineHeight = parseFloat(computed.lineHeight) || 20\n const paddingTop = parseFloat(computed.paddingTop)\n const paddingBottom = parseFloat(computed.paddingBottom)\n\n const minHeight = lineHeight * minRows + paddingTop + paddingBottom\n const maxHeightPx = lineHeight * maxRows + paddingTop + paddingBottom\n\n const scrollHeight = el.scrollHeight\n\n const newHeight = Math.min(scrollHeight, maxHeightPx)\n el.style.height = Math.max(newHeight, minHeight) + 'px'\n\n el.style.overflowY = scrollHeight > maxHeightPx ? 'auto' : 'hidden'\n el.style.scrollPaddingBottom = `${paddingBottom}px`\n }\n\n useEffect(() => {\n resize()\n const onResize = () => resize()\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [value])\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === 'Enter' && !e.shiftKey) {\n e.preventDefault()\n const text = value.trim()\n if (!text) {\n setValue('')\n resize()\n return\n }\n onSend?.(text)\n setValue('')\n requestAnimationFrame(() => {\n if (textareaRef.current) textareaRef.current.style.height = 'auto'\n resize()\n })\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!props?.maxLength || e.target.value.length < props?.maxLength) {\n setValue(e.target.value)\n onChange?.(e)\n }\n }\n\n return (\n <StyledTextarea\n ref={textareaRef}\n value={value}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n {...props}\n />\n )\n}\n"],"mappings":";;;;;;;AAWA,IAAMA,IAAiBC,EAAOC,GAAUC,CAAa,GAExCC,KAA+C,EAC1D,aAAU,GACV,aAAU,GACV,WACA,aACA,GAAGC,QACC;CACJ,IAAMC,IAAcC,EAAmC,IAAI,GACrD,CAACC,GAAOC,KAAYC,EAAS,EAAE,GAE/BC,UAAe;EACnB,IAAMC,IAAKN,EAAY;EACvB,IAAI,CAACM,GAAI;EAET,EAAG,MAAM,SAAS;EAElB,IAAMC,IAAW,OAAO,iBAAiBD,CAAE,GACrCE,IAAa,WAAWD,EAAS,UAAU,KAAK,IAChDE,IAAa,WAAWF,EAAS,UAAU,GAC3CG,IAAgB,WAAWH,EAAS,aAAa,GAEjDI,IAAYH,IAAaI,IAAUH,IAAaC,GAChDG,IAAcL,IAAaM,IAAUL,IAAaC,GAElDK,IAAeT,EAAG,cAElBU,IAAY,KAAK,IAAID,GAAcF,CAAW;EAIpD,AAHA,E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