@stokelp/ui 4.0.2 → 4.1.0
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 +1 -1
- package/dist/components/alert/Alert.cjs.map +1 -1
- package/dist/components/alert/Alert.d.ts +1 -1
- package/dist/components/alert/Alert.js +57 -53
- 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/combobox/Combobox.cjs +2 -2
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.js +17 -17
- package/dist/components/date-picker/DatePicker.cjs +1 -1
- package/dist/components/date-picker/DatePicker.cjs.map +1 -1
- package/dist/components/date-picker/DatePicker.js +68 -53
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/dialog/styled.cjs +1 -1
- package/dist/components/dialog/styled.cjs.map +1 -1
- package/dist/components/dialog/styled.js +58 -54
- package/dist/components/dialog/styled.js.map +1 -1
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.cjs.map +1 -1
- package/dist/components/drawer/Drawer.js +46 -42
- package/dist/components/drawer/Drawer.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/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.cjs.map +1 -1
- package/dist/components/pagination/Pagination.js +37 -36
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.cjs.map +1 -1
- package/dist/components/select/Select.js +15 -15
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.js +4 -4
- package/dist/components/supplier-rating-badge/SupplierRatingBadge.js.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js +33 -33
- package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js.map +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.cjs +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.cjs.map +1 -1
- package/dist/components/ui-labels/UiLabelsProvider.d.ts +34 -2
- package/dist/components/ui-labels/UiLabelsProvider.js +32 -7
- package/dist/components/ui-labels/UiLabelsProvider.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +69 -69
- package/package.json +20 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","names":["createStyleContext","select","styled","ArkSelect","css","useSelectContext","useSelectItemContext","_Fragment","ConditionalWrapper","Tooltip","useUiLabels","createListCollection","useRef","Fragment","Portal","Text","List","require_slots","require_Tooltip","require_Text","require_ConditionalWrapper","require_UiLabelsProvider","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","Root","withProvider","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","MultipleCheckedIndicator","DefaultInnerTrigger","context","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","isMultiple","renderItem","VirtualRow","index","ariaAttributes","toGroupRuns","runs","current","Select","props","uiLabels","collection","$dialogContent","renderOption","positioning","node","usePortal","emptyLabel","virtualized","rowHeight","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends SelectItem> {\n items: readonly Item[]\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends SelectItem>({\n index,\n style,\n ariaAttributes,\n items,\n isMultiple,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={isMultiple} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<Item>}\n rowProps={{ items, isMultiple: props.multiple, renderItem }}\n rowCount={items.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * items.length, 180) }}\n />\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${run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C6D,EAAI,MAAM,IAAIP,CAAY,CAAY,EAA5D,SAASQ,GAAmD,GAE3E,EAAAjD,EAAA,KAAA,CAACW,EAAD,CAAA,SAAA,EACE,EAAAX,EAAA,IAAA,CAACY,EAAD,CAAA,SAAiBoC,EAAI,KAAsB,CAAA,EAC1CA,EAAI,MAAM,IAAIP,CAAY,CAClB,CAAA,EAHK,SAASQ,GAGd,CAEf,CAEK,CAAA,CACC,CAAA,CACM,CAAA,GACpB,EAAAjD,EAAA,IAAA,CAACvB,EAAAA,OAAU,aAAX,CAAyB,CAAA,CACrB,C,EAEV,C"}
|
|
1
|
+
{"version":3,"file":"Select.cjs","names":["createStyleContext","select","styled","ArkSelect","css","useSelectContext","useSelectItemContext","_Fragment","ConditionalWrapper","Tooltip","useUiLabels","createListCollection","useRef","Fragment","Portal","Text","List","require_slots","require_UiLabelsProvider","require_Tooltip","require_Text","require_ConditionalWrapper","_ark_ui_react","_stokelp_styled_system_jsx","_stokelp_styled_system_recipes","react","react_jsx_runtime","_stokelp_styled_system_css","react_window","Root","withProvider","ClearTrigger","withContext","Content","Control","Indicator","Item","ItemGroup","ItemGroupLabel","ItemText","Positioner","Trigger","ValueText","MultipleUncheckedIndicator","MultipleCheckedIndicator","DefaultInnerTrigger","context","items","selectedItems","item","allSelectedLabel","CustomInnerTrigger","renderTrigger","CustomInnerItem","isMultiple","renderItem","VirtualRow","index","ariaAttributes","toGroupRuns","runs","current","Select","props","uiLabels","collection","$dialogContent","renderOption","positioning","node","usePortal","emptyLabel","virtualized","rowHeight","run","runIndex"],"sources":["../../../src/components/select/Select.tsx"],"sourcesContent":["import {\n createListCollection,\n Portal,\n Select as ArkSelect,\n type SelectRootProps,\n useSelectItemContext,\n useSelectContext,\n} from '@ark-ui/react'\nimport { FC, Fragment, ReactNode, useRef } from 'react'\nimport { styled } from '@stokelp/styled-system/jsx'\n\nimport { select } from '@stokelp/styled-system/recipes'\nimport { createStyleContext } from '~/utils/slots'\n\nimport { ConditionalWrapper } from '~/shared/ConditionalWrapper'\nimport { Text } from '~/components/text/Text'\nimport { Tooltip } from '~/components/tooltip/Tooltip'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport { HTMLStyledProps, RecipeVariantProps } from '@stokelp/styled-system/types'\nimport { List, type RowComponentProps } from 'react-window'\nimport { css } from '@stokelp/styled-system/css'\n\nconst { withProvider, withContext } = createStyleContext(select)\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Root = withProvider(styled(ArkSelect.Root<any>), 'root', {\n defaultProps: {\n loopFocus: true,\n },\n})\n\nconst ClearTrigger = withContext(styled(ArkSelect.ClearTrigger), 'clearTrigger')\nconst Content = withContext(styled(ArkSelect.Content), 'content')\nconst Control = withContext(styled(ArkSelect.Control), 'control')\nconst Indicator = withContext(styled(ArkSelect.Indicator), 'indicator')\nconst Item = withContext(styled(ArkSelect.Item), 'item')\nconst ItemGroup = withContext(styled(ArkSelect.ItemGroup), 'itemGroup')\nconst ItemGroupLabel = withContext(styled(ArkSelect.ItemGroupLabel), 'itemGroupLabel')\nconst ItemText = withContext(styled(ArkSelect.ItemText), 'itemText')\nconst Positioner = withContext(styled(ArkSelect.Positioner), 'positioner')\nconst Trigger = withContext(styled(ArkSelect.Trigger), 'trigger')\nconst ValueText = withContext(styled(ArkSelect.ValueText), 'valueText')\n\nexport interface SelectItem {\n value: string | number\n label: string\n tooltip?: ReactNode\n disabled?: boolean\n /**\n * Renders a thin divider line after this item, separating option groups.\n * Ignored by the virtualized list (fixed row heights).\n */\n separatorAfter?: boolean\n /**\n * Heading for the group this item belongs to. Consecutive items sharing a label are\n * wrapped in one labelled group, so the heading is announced by screen readers instead\n * of being faked with a decorative row inside `renderItem`. Items without a label stay\n * ungrouped. Ignored by the virtualized list (fixed row heights).\n */\n groupLabel?: string\n}\n\nexport type SelectProps<Item extends SelectItem> = Omit<SelectRootProps<Item>, 'collection'> & {\n items: Item[] | readonly Item[]\n renderItem?: (item: Item) => ReactNode\n renderTrigger?: (item: Item) => ReactNode\n emptyLabel?: string\n placeholder?: string\n allSelectedLabel?: string\n usePortal?: boolean\n virtualized?: boolean\n rowHeight?: number\n} & HTMLStyledProps<'div'> &\n RecipeVariantProps<typeof select>\n\nconst MultipleUncheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"1\" width=\"15\" height=\"15\" rx=\"3.5\" className={css({ stroke: 'grey.100' })} />\n </svg>\n)\n\nconst MultipleCheckedIndicator: FC = () => (\n <svg width=\"16\" height=\"17\" viewBox=\"0 0 16 17\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect y=\"0.5\" width=\"16\" height=\"16\" rx=\"4\" className={css({ fill: 'primary.500' })} />\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M11.958 4.81298C12.1303 4.92787 12.1769 5.16069 12.062 5.33301L7.56202 12.083C7.4997 12.1765 7.39875 12.2371 7.28695 12.2482C7.17515 12.2592 7.06428 12.2196 6.98483 12.1402L3.98483 9.14017C3.83839 8.99372 3.83839 8.75628 3.98483 8.60984C4.13128 8.46339 4.36872 8.46339 4.51517 8.60984L7.19172 11.2864L11.438 4.91699C11.5529 4.74467 11.7857 4.6981 11.958 4.81298Z\"\n fill=\"white\"\n />\n </svg>\n)\n\ninterface InnerItemProps<Item extends SelectItem> {\n item: Item\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\ninterface InnerTriggerProps<Item extends SelectItem> {\n renderTrigger: (item: Item) => ReactNode\n placeholder?: string\n allSelectedLabel?: string\n}\n\ninterface DefaultInnerTriggerProps {\n placeholder?: string\n allSelectedLabel?: string\n}\n\nfunction DefaultInnerTrigger({ placeholder, allSelectedLabel }: DefaultInnerTriggerProps) {\n const context = useSelectContext()\n const items = context.collection.items\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >= items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return <ValueText truncate placeholder={placeholder} />\n}\n\nfunction CustomInnerTrigger<Item extends SelectItem>({\n renderTrigger,\n placeholder,\n allSelectedLabel,\n}: InnerTriggerProps<Item>) {\n const context = useSelectContext()\n const items = context.value && context.value.length > 0 ? context.collection.findMany(context.value) : []\n\n if (items.length === 0) {\n return <ValueText className=\"custom\" truncate placeholder={placeholder} />\n }\n\n const selectedItems = context.selectedItems\n\n if (\n context.multiple &&\n selectedItems.filter(item => !item.disabled).length >=\n context.collection.items.filter(item => !item.disabled).length &&\n allSelectedLabel\n ) {\n return (\n <ValueText className=\"custom\" truncate>\n {allSelectedLabel}\n </ValueText>\n )\n }\n\n return (\n <ValueText className=\"custom\" placeholder={placeholder}>\n {items.map(item => (\n <span key={item.value}>{renderTrigger(item)}</span>\n ))}\n </ValueText>\n )\n}\n\nfunction CustomInnerItem<Item extends SelectItem>({ item, isMultiple, renderItem }: InnerItemProps<Item>) {\n const context = useSelectItemContext()\n\n return (\n <>\n {isMultiple ? context.selected ? <MultipleCheckedIndicator /> : <MultipleUncheckedIndicator /> : null}\n {renderItem ? renderItem(item) : <ItemText truncate>{item.label}</ItemText>}\n </>\n )\n}\n\ninterface VirtualRowProps<Item extends SelectItem> {\n items: readonly Item[]\n isMultiple?: boolean\n renderItem?: (item: Item) => ReactNode\n}\n\n// Declared at module level: react-window memoizes the row component by identity, so a\n// component created during render would remount every visible row on each render.\nfunction VirtualRow<Item extends SelectItem>({\n index,\n style,\n ariaAttributes,\n items,\n isMultiple,\n renderItem,\n}: RowComponentProps<VirtualRowProps<Item>>) {\n const item = items[index]\n\n return (\n <ConditionalWrapper when={!!item.tooltip} wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}>\n {/* Only the position attributes: the option keeps its role from Ark, not react-window's listitem. */}\n <Item\n item={item}\n style={style}\n aria-posinset={ariaAttributes['aria-posinset']}\n aria-setsize={ariaAttributes['aria-setsize']}\n >\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={isMultiple} />\n </Item>\n </ConditionalWrapper>\n )\n}\n\n/**\n * Splits the flat item list into consecutive runs sharing a `groupLabel`. Runs are built\n * from adjacency rather than by collecting every item with the same label, so the caller\n * keeps full control of the order: sorting is the caller's business, grouping is ours.\n */\nfunction toGroupRuns<Item extends SelectItem>(items: readonly Item[]) {\n const runs: Array<{ label?: string; items: Item[] }> = []\n\n for (const item of items) {\n const current = runs[runs.length - 1]\n if (current && current.label === item.groupLabel) {\n current.items.push(item)\n continue\n }\n runs.push({ label: item.groupLabel, items: [item] })\n }\n\n return runs\n}\n\nexport function Select<Item extends SelectItem>({\n items,\n placeholder,\n emptyLabel,\n usePortal = true,\n positioning,\n renderItem,\n renderTrigger,\n virtualized,\n rowHeight = 34,\n ...props\n}: SelectProps<Item>) {\n const uiLabels = useUiLabels()\n const collection = createListCollection({\n items,\n })\n const $dialogContent = useRef<HTMLDivElement | null>(null)\n\n const renderOption = (item: Item) => (\n <Fragment key={item.value}>\n <ConditionalWrapper\n key={item.value}\n when={!!item.tooltip}\n wrapper={children => <Tooltip label={item.tooltip}>{children}</Tooltip>}\n >\n <Item key={item.value} item={item}>\n <CustomInnerItem renderItem={renderItem} item={item} isMultiple={props.multiple} />\n </Item>\n </ConditionalWrapper>\n {item.separatorAfter && (\n <div\n role=\"separator\"\n className={css({\n height: '1px',\n flexShrink: 0,\n backgroundColor: 'grey.100',\n marginY: 'space-4',\n marginX: 'space-8',\n })}\n />\n )}\n </Fragment>\n )\n\n return (\n <Root\n lazyMount\n unmountOnExit\n collection={collection}\n positioning={{ sameWidth: true, gutter: 0, ...positioning }}\n data-recipe=\"select\"\n {...props}\n ref={(node: HTMLDivElement | null) => {\n if (node) {\n $dialogContent.current = node.closest('[role=\"dialog\"]') as HTMLDivElement | null\n }\n }}\n >\n <Control>\n <Trigger>\n {renderTrigger ? (\n <CustomInnerTrigger\n renderTrigger={renderTrigger}\n placeholder={placeholder}\n allSelectedLabel={props.allSelectedLabel}\n />\n ) : (\n <DefaultInnerTrigger placeholder={placeholder} allSelectedLabel={props.allSelectedLabel} />\n )}\n <Indicator asChild>\n <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M12.5303 16.2803C12.2374 16.5732 11.7626 16.5732 11.4697 16.2803L3.96967 8.78033C3.67678 8.48744 3.67678 8.01256 3.96967 7.71967C4.26256 7.42678 4.73744 7.42678 5.03033 7.71967L12 14.6893L18.9697 7.71967C19.2626 7.42678 19.7374 7.42678 20.0303 7.71967C20.3232 8.01256 20.3232 8.48744 20.0303 8.78033L12.5303 16.2803Z\"\n fill=\"currentColor\"\n />\n </svg>\n </Indicator>\n </Trigger>\n <ClearTrigger disabled={props.readOnly} asChild>\n <button>\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M10 3.125C6.20304 3.125 3.125 6.20304 3.125 10C3.125 13.797 6.20304 16.875 10 16.875C13.797 16.875 16.875 13.797 16.875 10C16.875 6.20304 13.797 3.125 10 3.125ZM1.875 10C1.875 5.51269 5.51269 1.875 10 1.875C14.4873 1.875 18.125 5.51269 18.125 10C18.125 14.4873 14.4873 18.125 10 18.125C5.51269 18.125 1.875 14.4873 1.875 10ZM7.68306 7.68306C7.92714 7.43898 8.32286 7.43898 8.56694 7.68306L10 9.11612L11.4331 7.68306C11.6771 7.43898 12.0729 7.43898 12.3169 7.68306C12.561 7.92714 12.561 8.32286 12.3169 8.56694L10.8839 10L12.3169 11.4331C12.561 11.6771 12.561 12.0729 12.3169 12.3169C12.0729 12.561 11.6771 12.561 11.4331 12.3169L10 10.8839L8.56694 12.3169C8.32286 12.561 7.92714 12.561 7.68306 12.3169C7.43898 12.0729 7.43898 11.6771 7.68306 11.4331L9.11612 10L7.68306 8.56694C7.43898 8.32286 7.43898 7.92714 7.68306 7.68306Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n </ClearTrigger>\n </Control>\n <ConditionalWrapper when={usePortal} wrapper={children => <Portal container={$dialogContent}>{children}</Portal>}>\n <Positioner>\n <Content>\n {items.length === 0 ? (\n <Text px=\"space-8\" textAlign=\"center\">\n {emptyLabel ?? uiLabels.noResults}\n </Text>\n ) : virtualized ? (\n // role=\"presentation\" overrides the list's own role=\"list\": the options must stay\n // owned by the listbox.\n <List\n role=\"presentation\"\n rowComponent={VirtualRow<Item>}\n rowProps={{ items, isMultiple: props.multiple, renderItem }}\n rowCount={items.length}\n rowHeight={rowHeight}\n style={{ height: Math.min(rowHeight * items.length, 180) }}\n />\n ) : (\n toGroupRuns<Item>(items).map((run, runIndex) =>\n run.label === undefined ? (\n <Fragment key={`group-${runIndex}`}>{run.items.map(renderOption)}</Fragment>\n ) : (\n <ItemGroup key={`group-${runIndex}`}>\n <ItemGroupLabel>{run.label}</ItemGroupLabel>\n {run.items.map(renderOption)}\n </ItemGroup>\n ),\n )\n )}\n </Content>\n </Positioner>\n </ConditionalWrapper>\n <ArkSelect.HiddenSelect />\n </Root>\n )\n}\n"],"mappings":"A,+bAsBA,GAAM,CAAE,eAAc,eAAgBA,EAAAA,mBAAmBC,EAAAA,MAAM,EAGzD4B,EAAOC,GAAA,EAAa5B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,IAAS,EAAG,OAAQ,CAC7D,aAAc,CACZ,UAAW,EACb,CACF,CAAC,EAEK4B,EAAeC,GAAA,EAAY9B,EAAAA,OAAAA,CAAOC,EAAAA,OAAU,YAAY,EAAG,cAAc,EACzE8B,EAAUD,GAAA,EAAY9B,EAAAA,OAAAA,CAA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5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { useUiLabels as t } from "../ui-labels/UiLabelsProvider.js";
|
|
4
|
+
import { Tooltip as n } from "../tooltip/Tooltip.js";
|
|
5
|
+
import { Text as r } from "../text/Text.js";
|
|
6
|
+
import { ConditionalWrapper as i } from "../../shared/ConditionalWrapper.js";
|
|
7
7
|
import { Portal as a, Select as o, createListCollection as s, useSelectContext as c, useSelectItemContext as l } from "@ark-ui/react";
|
|
8
8
|
import { styled as u } from "@stokelp/styled-system/jsx";
|
|
9
9
|
import { select as d } from "@stokelp/styled-system/recipes";
|
|
@@ -88,19 +88,19 @@ function L({ item: e, isMultiple: t, renderItem: n }) {
|
|
|
88
88
|
children: e.label
|
|
89
89
|
})] });
|
|
90
90
|
}
|
|
91
|
-
function R({ index: e, style:
|
|
91
|
+
function R({ index: e, style: t, ariaAttributes: r, items: a, isMultiple: o, renderItem: s }) {
|
|
92
92
|
let c = a[e];
|
|
93
|
-
return /* @__PURE__ */ h(
|
|
93
|
+
return /* @__PURE__ */ h(i, {
|
|
94
94
|
when: !!c.tooltip,
|
|
95
|
-
wrapper: (e) => /* @__PURE__ */ h(
|
|
95
|
+
wrapper: (e) => /* @__PURE__ */ h(n, {
|
|
96
96
|
label: c.tooltip,
|
|
97
97
|
children: e
|
|
98
98
|
}),
|
|
99
99
|
children: /* @__PURE__ */ h(E, {
|
|
100
100
|
item: c,
|
|
101
|
-
style:
|
|
102
|
-
"aria-posinset":
|
|
103
|
-
"aria-setsize":
|
|
101
|
+
style: t,
|
|
102
|
+
"aria-posinset": r["aria-posinset"],
|
|
103
|
+
"aria-setsize": r["aria-setsize"],
|
|
104
104
|
children: /* @__PURE__ */ h(L, {
|
|
105
105
|
renderItem: s,
|
|
106
106
|
item: c,
|
|
@@ -121,11 +121,11 @@ function z(e) {
|
|
|
121
121
|
return t;
|
|
122
122
|
}
|
|
123
123
|
function B({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positioning: d, renderItem: m, renderTrigger: y, virtualized: b, rowHeight: k = 34, ...M }) {
|
|
124
|
-
let N =
|
|
124
|
+
let N = t(), P = s({ items: e }), B = p(null), V = (e) => /* @__PURE__ */ g(f, { children: [/* @__PURE__ */ h(i, {
|
|
125
125
|
when: !!e.tooltip,
|
|
126
|
-
wrapper: (
|
|
126
|
+
wrapper: (t) => /* @__PURE__ */ h(n, {
|
|
127
127
|
label: e.tooltip,
|
|
128
|
-
children:
|
|
128
|
+
children: t
|
|
129
129
|
}),
|
|
130
130
|
children: /* @__PURE__ */ h(E, {
|
|
131
131
|
item: e,
|
|
@@ -199,13 +199,13 @@ function B({ items: e, placeholder: c, emptyLabel: l, usePortal: u = !0, positio
|
|
|
199
199
|
})
|
|
200
200
|
}) })
|
|
201
201
|
})] }),
|
|
202
|
-
/* @__PURE__ */ h(
|
|
202
|
+
/* @__PURE__ */ h(i, {
|
|
203
203
|
when: u,
|
|
204
204
|
wrapper: (e) => /* @__PURE__ */ h(a, {
|
|
205
205
|
container: B,
|
|
206
206
|
children: e
|
|
207
207
|
}),
|
|
208
|
-
children: /* @__PURE__ */ h(A, { children: /* @__PURE__ */ h(C, { children: e.length === 0 ? /* @__PURE__ */ h(
|
|
208
|
+
children: /* @__PURE__ */ h(A, { children: /* @__PURE__ */ h(C, { children: e.length === 0 ? /* @__PURE__ */ h(r, {
|
|
209
209
|
px: "space-8",
|
|
210
210
|
textAlign: "center",
|
|
211
211
|
children: l ?? N.noResults
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../
|
|
1
|
+
"use client";const e=require("../ui-labels/UiLabelsProvider.cjs"),t=require("../text/Text.cjs"),n=require("../popover/Popover.cjs"),r=require("./SupplierRatingBreakdown.cjs");let i=require("@stokelp/styled-system/jsx"),a=require("react"),o=require("react/jsx-runtime");function s(e){let t=e/5;return t>=.8?{bg:`#E6F3D9`,color:`#3B6D11`}:t>=.6?{bg:`#FBF1CC`,color:`#92750C`}:t>=.4?{bg:`#FDF0E0`,color:`#C2740C`}:{bg:`#FCEBEB`,color:`#A32D2D`}}function c({rating:c,responseRate:l,labels:u}){let[d,f]=(0,a.useState)(!1),p=(0,a.useRef)(null),m=(0,a.useCallback)(()=>{p.current&&=(clearTimeout(p.current),null)},[]),h=(0,a.useCallback)(()=>{m(),p.current=setTimeout(()=>f(!1),120)},[m]);(0,a.useEffect)(()=>m,[m]);let g=e=>{e.pointerType===`mouse`&&(m(),f(!0))},_=e=>{e.pointerType===`mouse`&&h()},v=c.insufficientData||c.overall==null,y=e.useUiLabels(),b=u?.insufficientData??y.supplierRating.insufficientData,x=v?{bg:`#F1F2F4`,color:`#5B6472`}:s(c.overall);return(0,o.jsxs)(n.Popover,{open:d,onOpenChange:e=>f(e.open),positioning:{placement:`top-end`,gutter:8},autoFocus:!1,restoreFocus:!1,lazyMount:!0,unmountOnExit:!0,children:[(0,o.jsx)(n.PopoverTrigger,{asChild:!0,children:(0,o.jsx)(i.Box,{display:`inline-flex`,alignItems:`center`,w:`fit-content`,maxW:`100%`,px:`space-8`,py:`space-2`,borderRadius:`full`,tabIndex:0,cursor:`default`,style:{backgroundColor:x.bg},onPointerEnter:g,onPointerLeave:_,onFocus:()=>{m(),f(!0)},onBlur:()=>f(!1),children:(0,o.jsx)(t.Text,{size:`sm`,bold:!0,whiteSpace:`nowrap`,style:{color:x.color},children:v?b:`${r.formatOverall(c.overall,y.locale)} ★`})})}),(0,o.jsx)(n.PopoverContent,{className:`panda-preflight-enabled`,zIndex:1e4,p:`0`,bg:`transparent`,border:`none`,borderRadius:`radius-8`,boxShadow:`0px 8px 16px 4px #1624861A`,onPointerEnter:g,onPointerLeave:_,children:(0,o.jsx)(r.SupplierRatingBreakdown,{rating:c,responseRate:l,labels:u})})]})}exports.SupplierRatingBadge=c;
|
|
2
2
|
//# sourceMappingURL=SupplierRatingBadge.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupplierRatingBadge.cjs","names":["useState","useRef","useCallback","useUiLabels","Popover","PopoverTrigger","Box","Text","formatOverall","PopoverContent","SupplierRatingBreakdown","
|
|
1
|
+
{"version":3,"file":"SupplierRatingBadge.cjs","names":["useState","useRef","useCallback","useUiLabels","Popover","PopoverTrigger","Box","Text","formatOverall","PopoverContent","SupplierRatingBreakdown","require_UiLabelsProvider","require_Text","require_Popover","require_SupplierRatingBreakdown","_stokelp_styled_system_jsx","react","react_jsx_runtime","getBadgeColors","ratio","overall","SupplierRatingBadge","open","setOpen","closeTimer","cancelClose","scheduleClose","openOnMouse","closeOnMouse","insufficient","rating","uiLabels","insufficientLabel","labels","colors"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBadge.tsx"],"sourcesContent":["import { Box } from '@stokelp/styled-system/jsx'\nimport { PointerEvent, useCallback, useEffect, useRef, useState } from 'react'\n\nimport { Popover, PopoverContent, PopoverTrigger } from '~/components/popover/Popover'\nimport { Text } from '~/components/text/Text'\n\nimport {\n formatOverall,\n SUPPLIER_RATING_MAX,\n SupplierRatingBreakdown,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './SupplierRatingBreakdown'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\n\nexport type SupplierRatingBadgeProps = {\n rating: SupplierRating\n /** Optional original response rate (0..100) reminded inside the breakdown. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nfunction getBadgeColors(overall: number): { bg: string; color: string } {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.8) return { bg: '#E6F3D9', color: '#3B6D11' }\n if (ratio >= 0.6) return { bg: '#FBF1CC', color: '#92750C' }\n if (ratio >= 0.4) return { bg: '#FDF0E0', color: '#C2740C' }\n return { bg: '#FCEBEB', color: '#A32D2D' }\n}\n\n/** Compact supplier-rating pill (note /5) with an accessible, keyboard-openable breakdown popover. */\nexport function SupplierRatingBadge({ rating, responseRate, labels }: SupplierRatingBadgeProps) {\n const [open, setOpen] = useState(false)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n }, [])\n\n const scheduleClose = useCallback(() => {\n cancelClose()\n closeTimer.current = setTimeout(() => setOpen(false), 120)\n }, [cancelClose])\n\n useEffect(() => cancelClose, [cancelClose])\n\n const openOnMouse = (e: PointerEvent) => {\n if (e.pointerType !== 'mouse') return\n cancelClose()\n setOpen(true)\n }\n const closeOnMouse = (e: PointerEvent) => {\n if (e.pointerType !== 'mouse') return\n scheduleClose()\n }\n\n const insufficient = rating.insufficientData || rating.overall == null\n const uiLabels = useUiLabels()\n const insufficientLabel = labels?.insufficientData ?? uiLabels.supplierRating.insufficientData\n const colors = insufficient ? { bg: '#F1F2F4', color: '#5B6472' } : getBadgeColors(rating.overall as number)\n\n return (\n <Popover\n open={open}\n onOpenChange={e => setOpen(e.open)}\n positioning={{ placement: 'top-end', gutter: 8 }}\n autoFocus={false}\n restoreFocus={false}\n lazyMount\n unmountOnExit\n >\n <PopoverTrigger asChild>\n <Box\n display=\"inline-flex\"\n alignItems=\"center\"\n w=\"fit-content\"\n maxW=\"100%\"\n px=\"space-8\"\n py=\"space-2\"\n borderRadius=\"full\"\n tabIndex={0}\n cursor=\"default\"\n style={{ backgroundColor: colors.bg }}\n onPointerEnter={openOnMouse}\n onPointerLeave={closeOnMouse}\n onFocus={() => {\n cancelClose()\n setOpen(true)\n }}\n onBlur={() => setOpen(false)}\n >\n <Text size=\"sm\" bold whiteSpace=\"nowrap\" style={{ color: colors.color }}>\n {insufficient ? insufficientLabel : `${formatOverall(rating.overall as number, uiLabels.locale)} ★`}\n </Text>\n </Box>\n </PopoverTrigger>\n <PopoverContent\n className=\"panda-preflight-enabled\"\n zIndex={10000}\n p=\"0\"\n bg=\"transparent\"\n border=\"none\"\n borderRadius=\"radius-8\"\n boxShadow=\"0px 8px 16px 4px #1624861A\"\n onPointerEnter={openOnMouse}\n onPointerLeave={closeOnMouse}\n >\n <SupplierRatingBreak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E,IAAI,EACjC,YAAa,CAAE,UAAW,UAAW,OAAQ,CAAE,EAC/C,UAAW,GACX,aAAc,GACd,UAAA,GACA,cAAA,GAPF,SAAA,EASE,EAAAN,EAAA,IAAA,CAACZ,EAAAA,eAAD,CAAgB,QAAA,GACd,UAAA,EAAAY,EAAA,IAAA,CAACX,EAAAA,IAAD,CACE,QAAQ,cACR,WAAW,SACX,EAAE,cACF,KAAK,OACL,GAAG,UACH,GAAG,UACH,aAAa,OACb,SAAU,EACV,OAAO,UACP,MAAO,CAAE,gBAAiB4B,EAAO,EAAG,EACpC,eAAgBP,EAChB,eAAgBC,EAChB,YAAe,CACbH,EAAY,EACZF,EAAQ,EAAI,CACd,EACA,WAAcA,EAAQ,EAAK,EAE3B,UAAA,EAAAN,EAAA,IAAA,CAACV,EAAAA,KAAD,CAAM,KAAK,KAAK,KAAA,GAAK,WAAW,SAAS,MAAO,CAAE,MAAO2B,EAAO,KAAM,EACnE,SAAAL,EAAeG,EAAoB,GAAGxB,EAAAA,cAAcsB,EAAO,QAAmBC,EAAS,MAAM,EAAE,GAC5F,CAAA,CACH,CAAA,CACS,CAAA,GAChB,EAAAd,EAAA,IAAA,CAACR,EAAAA,eAAD,CACE,UAAU,0BACV,OAAQ,IACR,EAAE,IACF,GAAG,cACH,OAAO,OACP,aAAa,WACb,UAAU,6BACV,eAAgBkB,EAChB,eAAgBC,EAEhB,UAAA,EAAAX,EAAA,IAAA,CAACP,EAAAA,wBAAD,CAAiC,SAAsB,eAAsB,QAAS,CAAA,CACxE,CAAA,CACT,C,EAEb,C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useUiLabels as e } from "../ui-labels/UiLabelsProvider.js";
|
|
3
|
+
import { Text as t } from "../text/Text.js";
|
|
4
4
|
import { Popover as n, PopoverContent as r, PopoverTrigger as i } from "../popover/Popover.js";
|
|
5
5
|
import { SupplierRatingBreakdown as a, formatOverall as o } from "./SupplierRatingBreakdown.js";
|
|
6
6
|
import { Box as s } from "@stokelp/styled-system/jsx";
|
|
@@ -34,7 +34,7 @@ function h({ rating: h, responseRate: g, labels: _ }) {
|
|
|
34
34
|
e.pointerType === "mouse" && (x(), y(!0));
|
|
35
35
|
}, w = (e) => {
|
|
36
36
|
e.pointerType === "mouse" && S();
|
|
37
|
-
}, T = h.insufficientData || h.overall == null, E =
|
|
37
|
+
}, T = h.insufficientData || h.overall == null, E = e(), D = _?.insufficientData ?? E.supplierRating.insufficientData, O = T ? {
|
|
38
38
|
bg: "#F1F2F4",
|
|
39
39
|
color: "#5B6472"
|
|
40
40
|
} : m(h.overall);
|
|
@@ -68,7 +68,7 @@ function h({ rating: h, responseRate: g, labels: _ }) {
|
|
|
68
68
|
x(), y(!0);
|
|
69
69
|
},
|
|
70
70
|
onBlur: () => y(!1),
|
|
71
|
-
children: /* @__PURE__ */ f(
|
|
71
|
+
children: /* @__PURE__ */ f(t, {
|
|
72
72
|
size: "sm",
|
|
73
73
|
bold: !0,
|
|
74
74
|
whiteSpace: "nowrap",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupplierRatingBadge.js","names":["getBadgeColors","ratio","overall","SupplierRatingBadge","open","setOpen","useState","closeTimer","useRef","cancelClose","useCallback","scheduleClose","openOnMouse","closeOnMouse","insufficient","rating","uiLabels","useUiLabels","insufficientLabel","labels","colors","Popover","PopoverTrigger","Box","Text","formatOverall","PopoverContent","SupplierRatingBreakdown"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBadge.tsx"],"sourcesContent":["import { Box } from '@stokelp/styled-system/jsx'\nimport { PointerEvent, useCallback, useEffect, useRef, useState } from 'react'\n\nimport { Popover, PopoverContent, PopoverTrigger
|
|
1
|
+
{"version":3,"file":"SupplierRatingBadge.js","names":["getBadgeColors","ratio","overall","SupplierRatingBadge","open","setOpen","useState","closeTimer","useRef","cancelClose","useCallback","scheduleClose","openOnMouse","closeOnMouse","insufficient","rating","uiLabels","useUiLabels","insufficientLabel","labels","colors","Popover","PopoverTrigger","Box","Text","formatOverall","PopoverContent","SupplierRatingBreakdown"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBadge.tsx"],"sourcesContent":["import { Box } from '@stokelp/styled-system/jsx'\nimport { PointerEvent, useCallback, useEffect, useRef, useState } from 'react'\n\nimport { Popover, PopoverContent, PopoverTrigger } from '~/components/popover/Popover'\nimport { Text } from '~/components/text/Text'\n\nimport {\n formatOverall,\n SUPPLIER_RATING_MAX,\n SupplierRatingBreakdown,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './SupplierRatingBreakdown'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\n\nexport type SupplierRatingBadgeProps = {\n rating: SupplierRating\n /** Optional original response rate (0..100) reminded inside the breakdown. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nfunction getBadgeColors(overall: number): { bg: string; color: string } {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.8) return { bg: '#E6F3D9', color: '#3B6D11' }\n if (ratio >= 0.6) return { bg: '#FBF1CC', color: '#92750C' }\n if (ratio >= 0.4) return { bg: '#FDF0E0', color: '#C2740C' }\n return { bg: '#FCEBEB', color: '#A32D2D' }\n}\n\n/** Compact supplier-rating pill (note /5) with an accessible, keyboard-openable breakdown popover. */\nexport function SupplierRatingBadge({ rating, responseRate, labels }: SupplierRatingBadgeProps) {\n const [open, setOpen] = useState(false)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n }, [])\n\n const scheduleClose = useCallback(() => {\n cancelClose()\n closeTimer.current = setTimeout(() => setOpen(false), 120)\n }, [cancelClose])\n\n useEffect(() => cancelClose, [cancelClose])\n\n const openOnMouse = (e: PointerEvent) => {\n if (e.pointerType !== 'mouse') return\n cancelClose()\n setOpen(true)\n }\n const closeOnMouse = (e: PointerEvent) => {\n if (e.pointerType !== 'mouse') return\n scheduleClose()\n }\n\n const insufficient = rating.insufficientData || rating.overall == null\n const uiLabels = useUiLabels()\n const insufficientLabel = labels?.insufficientData ?? uiLabels.supplierRating.insufficientData\n const colors = insufficient ? { bg: '#F1F2F4', color: '#5B6472' } : getBadgeColors(rating.overall as number)\n\n return (\n <Popover\n open={open}\n onOpenChange={e => setOpen(e.open)}\n positioning={{ placement: 'top-end', gutter: 8 }}\n autoFocus={false}\n restoreFocus={false}\n lazyMount\n unmountOnExit\n >\n <PopoverTrigger asChild>\n <Box\n display=\"inline-flex\"\n alignItems=\"center\"\n w=\"fit-content\"\n maxW=\"100%\"\n px=\"space-8\"\n py=\"space-2\"\n borderRadius=\"full\"\n tabIndex={0}\n cursor=\"default\"\n style={{ backgroundColor: colors.bg }}\n onPointerEnter={openOnMouse}\n onPointerLeave={closeOnMouse}\n onFocus={() => {\n cancelClose()\n setOpen(true)\n }}\n onBlur={() => setOpen(false)}\n >\n <Text size=\"sm\" bold whiteSpace=\"nowrap\" style={{ color: colors.color }}>\n {insufficient ? insufficientLabel : `${formatOverall(rating.overall as number, uiLabels.locale)} ★`}\n </Text>\n </Box>\n </PopoverTrigger>\n <PopoverContent\n className=\"panda-preflight-enabled\"\n zIndex={10000}\n p=\"0\"\n bg=\"transparent\"\n border=\"none\"\n borderRadius=\"radius-8\"\n boxShadow=\"0px 8px 16px 4px #1624861A\"\n onPointerEnter={openOnMouse}\n onPointerLeave={closeOnMouse}\n >\n <SupplierRatingBreakdown rating={rating} responseRate={responseRate} labels={labels} />\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;AAsBA,SAASA,EAAe,GAAgD;CACtE,IAAMC,IAAQC,IAAA;CAId,OAHID,KAAS,KAAY;EAAE,IAAI;EAAW,OAAO;CAAU,IACvDA,KAAS,KAAY;EAAE,IAAI;EAAW,OAAO;CAAU,IACvDA,KAAS,KAAY;EAAE,IAAI;EAAW,OAAO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IACA,cAAcA,EAAQ,EAAK;IAE3B,UAAA,kBAACmB,GAAD;KAAM,MAAK;KAAK,MAAA;KAAK,YAAW;KAAS,OAAO,EAAE,OAAOJ,EAAO,MAAM;KACnE,UAAAN,IAAeI,IAAoB,GAAGO,EAAcV,EAAO,SAAmBC,EAAS,MAAM,EAAE;IAC5F,CAAA;GACH,CAAA;EACS,CAAA,GAChB,kBAACU,GAAD;GACE,WAAU;GACV,QAAQ;GACR,GAAE;GACF,IAAG;GACH,QAAO;GACP,cAAa;GACb,WAAU;GACV,gBAAgBd;GAChB,gBAAgBC;GAEhB,UAAA,kBAACc,GAAD;IAAiC;IAAsB;IAAsB;GAAS,CAAA;EACxE,CAAA,CACT;;AAEb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("
|
|
1
|
+
"use client";const e=require("./labels.cjs"),t=require("../ui-labels/UiLabelsProvider.cjs"),n=require("../text/Text.cjs"),r=require("../icon/Icon.cjs"),i=require("../../node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs"),a=require("../../node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs");let o=require("@stokelp/styled-system/jsx"),s=require("react/jsx-runtime");var c=5,l=[`profile`,`location`,`contacts`,`legalBanking`,`sector`,`certificate`];function u(e,t=`fr-FR`){return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e)}function d(e,t,n=`fr-FR`){if(e<60)return`${Math.round(e)} ${t.minutes}`;let r=e/60;if(r<48)return`${Math.round(r)} ${t.hours}`;let i=r/24;return`${new Intl.NumberFormat(n,{maximumFractionDigits:1}).format(i)} ${t.days}`}function f(e){let t=e/5;return t>=.7?`#3B6D11`:t>=.4?`#854F0B`:`#A32D2D`}function p(e){return e>=70?`#639922`:e>=40?`#BA7517`:`#E24B4A`}var m=({rating:c,responseRate:m,labels:h})=>{let g=t.useUiLabels(),_=e.mergeSupplierRatingLabels(g.supplierRating,h),v=m!=null,y=c.responseDelayMinutes!=null,b=c.responseDelayScore==null?null:Math.round(c.responseDelayScore*100),x=Math.round(c.completionScore*100),S=[{key:`responseRate`,value:v?`${Math.round(m)} %`:_.notAvailable,barPercent:v?Math.round(m):null,color:v?p(Math.round(m)):void 0},{key:`responseDelay`,value:y?d(c.responseDelayMinutes,_.units,g.locale):_.notAvailable,barPercent:b,color:b==null?void 0:p(b)},{key:`completion`,value:`${x} %`,barPercent:x,color:p(x)}];return(0,s.jsxs)(o.Box,{bg:`white`,borderRadius:`radius-8`,p:`space-16`,minW:`240px`,maxW:`260px`,css:{"& *":{fontFamily:`inherit`}},children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,mb:`space-8`,children:[(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.md`,fontWeight:`bold`,children:_.title}),c.insufficientData||c.overall==null?(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,color:`grey.400`,children:_.insufficientData}):(0,s.jsxs)(n.Text,{as:`span`,fontSize:`body.lg`,fontWeight:`medium`,style:{color:f(c.overall)},children:[u(c.overall,g.locale),` / `,5,` ★`]})]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-8`,mb:`space-8`,children:[(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.componentsTitle}),S.map(e=>(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-2`,children:[(0,s.jsxs)(o.HStack,{justify:`space-between`,alignItems:`baseline`,gap:`space-8`,children:[(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,color:`grey.500`,children:_.components[e.key]}),(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,whiteSpace:`nowrap`,style:{color:e.color},color:e.color?void 0:`grey.300`,children:e.value})]}),(0,s.jsx)(o.Box,{h:`3px`,bg:`grey.100`,borderRadius:`full`,overflow:`hidden`,children:(0,s.jsx)(o.Box,{h:`100%`,borderRadius:`full`,style:{width:e.barPercent==null?`0%`:`${e.barPercent}%`,background:e.color??`transparent`}})})]},e.key))]}),(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,s.jsxs)(o.VStack,{alignItems:`stretch`,gap:`space-4`,children:[(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:_.completionTitle}),l.map(e=>{let t=c.completion[e];return(0,s.jsxs)(o.HStack,{alignItems:`center`,gap:`space-8`,children:[(0,s.jsx)(r.Icon,{size:`sm`,color:t?`success.500`:`grey.300`,flexShrink:`0`,children:t?(0,s.jsx)(i.default,{}):(0,s.jsx)(a.default,{})}),(0,s.jsx)(n.Text,{as:`span`,fontSize:`body.sm`,color:t?`grey.500`:`grey.400`,children:_.completion[e]})]},e)})]}),_.footer&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.Box,{h:`1px`,bg:`grey.100`,mt:`space-8`,mb:`space-8`}),(0,s.jsx)(n.Text,{as:`span`,fontSize:`9px`,color:`grey.300`,style:{lineHeight:1},children:_.footer})]})]})};exports.DEFAULT_SUPPLIER_RATING_LABELS=e.DEFAULT_SUPPLIER_RATING_LABELS,exports.SUPPLIER_RATING_MAX=c,exports.SupplierRatingBreakdown=m,exports.formatOverall=u,exports.formatResponseDelay=d,exports.getHeadlineColor=f,exports.mergeSupplierRatingLabels=e.mergeSupplierRatingLabels;
|
|
2
2
|
//# sourceMappingURL=SupplierRatingBreakdown.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupplierRatingBreakdown.cjs","names":["useUiLabels","mergeSupplierRatingLabels","Box","HStack","Text","VStack","Icon","CheckCircleIcon","XCircleIcon","_Fragment","require_Text","require_labels","require_UiLabelsProvider","require_Icon","require_CheckCircleIcon","require_XCircleIcon","_stokelp_styled_system_jsx","react_jsx_runtime","SUPPLIER_RATING_MAX","COMPLETION_ORDER","formatOverall","locale","overall","formatResponseDelay","minutes","units","hours","days","getHeadlineColor","ratio","getBarColor","ratioPercent","SupplierRatingBreakdown","labelsProp","uiLabels","labels","hasResponseRate","responseRate","hasDelay","rating","delayPercent","completionPercent","rows","row","done","key"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport {\n mergeSupplierRatingLabels,\n type SupplierRatingCompletionKey,\n type SupplierRatingComponentKey,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './labels'\n\nexport * from './labels'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\n/** Note with one decimal in the reader's number format (\"4,2\" in French, \"4.2\" in English). */\nexport function formatOverall(overall: number, locale = 'fr-FR'): string {\n return new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(overall)\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units'], locale = 'fr-FR'): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(days)} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) 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\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const uiLabels = useUiLabels()\n const labels = mergeSupplierRatingLabels(uiLabels.supplierRating, labelsProp)\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay\n ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units, uiLabels.locale)\n : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\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 {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall, uiLabels.locale)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\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,uYAeA,IAAakB,EAAsB,EAE7BC,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAGA,SAAgBC,EAAc,EAAiB,EAAS,QAAiB,CACvE,OAAO,IAAI,KAAK,aAAaC,EAAQ,CAAE,sBAAuB,EAAG,sBAAuB,CAAE,CAAC,CAAC,CAAC,OAAOC,CAAO,CAC7G,CAGA,SAAgBC,EAAoB,EAAiB,EAAsC,EAAS,QAAiB,CACnH,GAAIC,EAAU,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAO,EAAE,GAAGC,EAAM,UACzD,IAAMC,EAAQF,EAAU,GACxB,GAAIE,EAAQ,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAK,EAAE,GAAGD,EAAM,QACrD,IAAME,EAAOD,EAAQ,GACrB,MAAO,GAAG,IAAI,KAAK,aAAaL,EAAQ,CAAE,sBAAuB,CAAE,CAAC,CAAC,CAAC,OAAOM,CAAI,EAAE,GAAGF,EAAM,MAC9F,CAEA,SAAgBG,EAAiB,EAAyB,CACxD,IAAMC,EAAQP,EAAA,EAGd,OAFIO,GAAS,GAAY,UACrBA,GAAS,GAAY,UAClB,SACT,CAEA,SAASC,EAAY,EAA8B,CAGjD,OAFIC,GAAgB,GAAW,UAC3BA,GAAgB,GAAW,UACxB,SACT,CAkBA,IAAaC,GAA2B,CAAE,SAAQ,eAAc,OAAQC,KAA+C,CACrH,IAAMC,EAAWlC,EAAAA,YAAY,EACvBmC,EAASlC,EAAAA,0BAA0BiC,EAAS,eAAgBD,CAAU,EAEtE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D,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA+B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
|
|
1
|
+
{"version":3,"file":"SupplierRatingBreakdown.cjs","names":["useUiLabels","mergeSupplierRatingLabels","Box","HStack","Text","VStack","Icon","CheckCircleIcon","XCircleIcon","_Fragment","require_labels","require_UiLabelsProvider","require_Text","require_Icon","require_CheckCircleIcon","require_XCircleIcon","_stokelp_styled_system_jsx","react_jsx_runtime","SUPPLIER_RATING_MAX","COMPLETION_ORDER","formatOverall","locale","overall","formatResponseDelay","minutes","units","hours","days","getHeadlineColor","ratio","getBarColor","ratioPercent","SupplierRatingBreakdown","labelsProp","uiLabels","labels","hasResponseRate","responseRate","hasDelay","rating","delayPercent","completionPercent","rows","row","done","key"],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon } from '~/components/icon/Icon'\nimport { Text } from '~/components/text/Text'\nimport { useUiLabels } from '~/components/ui-labels/UiLabelsProvider'\nimport {\n mergeSupplierRatingLabels,\n type SupplierRatingCompletionKey,\n type SupplierRatingComponentKey,\n type SupplierRating,\n type SupplierRatingLabels,\n} from './labels'\n\nexport * from './labels'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\n/** Note with one decimal in the reader's number format (\"4,2\" in French, \"4.2\" in English). */\nexport function formatOverall(overall: number, locale = 'fr-FR'): string {\n return new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 }).format(overall)\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units'], locale = 'fr-FR'): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(days)} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) 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\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const uiLabels = useUiLabels()\n const labels = mergeSupplierRatingLabels(uiLabels.supplierRating, labelsProp)\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay\n ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units, uiLabels.locale)\n : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\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 {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall, uiLabels.locale)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\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,uYAgBA,IAAakB,EAAsB,EAE7BC,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAGA,SAAgBC,EAAc,EAAiB,EAAS,QAAiB,CACvE,OAAO,IAAI,KAAK,aAAaC,EAAQ,CAAE,sBAAuB,EAAG,sBAAuB,CAAE,CAAC,CAAC,CAAC,OAAOC,CAAO,CAC7G,CAGA,SAAgBC,EAAoB,EAAiB,EAAsC,EAAS,QAAiB,CACnH,GAAIC,EAAU,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAO,EAAE,GAAGC,EAAM,UACzD,IAAMC,EAAQF,EAAU,GACxB,GAAIE,EAAQ,GAAI,MAAO,GAAG,KAAK,MAAMA,CAAK,EAAE,GAAGD,EAAM,QACrD,IAAME,EAAOD,EAAQ,GACrB,MAAO,GAAG,IAAI,KAAK,aAAaL,EAAQ,CAAE,sBAAuB,CAAE,CAAC,CAAC,CAAC,O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S,EAAA,IAAA,CAACb,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,MAAOwC,EAAO,WAAa,WAC3D,SAAAT,EAAO,WAAWU,EACf,CAAA,CACA,CAPK,EAAAA,CAOL,CAEZ,CAAC,CACK,C,GAEPV,EAAO,SACN,EAAAlB,EAAA,KAAA,CAAAR,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAQ,EAAA,IAAA,CAACf,EAAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAAe,EAAA,IAAA,CAACb,EAAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,EACpE,SAAA+B,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,C,EAET,E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { DEFAULT_SUPPLIER_RATING_LABELS as e, mergeSupplierRatingLabels as t } from "./labels.js";
|
|
3
|
+
import { useUiLabels as n } from "../ui-labels/UiLabelsProvider.js";
|
|
4
|
+
import { Text as r } from "../text/Text.js";
|
|
5
5
|
import { Icon as i } from "../icon/Icon.js";
|
|
6
6
|
import a from "../../node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.js";
|
|
7
7
|
import o from "../../node_modules/@heroicons/react/24/outline/esm/XCircleIcon.js";
|
|
@@ -36,8 +36,8 @@ function _(e) {
|
|
|
36
36
|
function v(e) {
|
|
37
37
|
return e >= 70 ? "#639922" : e >= 40 ? "#BA7517" : "#E24B4A";
|
|
38
38
|
}
|
|
39
|
-
var y = ({ rating:
|
|
40
|
-
let b =
|
|
39
|
+
var y = ({ rating: e, responseRate: p, labels: y }) => {
|
|
40
|
+
let b = n(), x = t(b.supplierRating, y), S = p != null, C = e.responseDelayMinutes != null, w = e.responseDelayScore == null ? null : Math.round(e.responseDelayScore * 100), T = Math.round(e.completionScore * 100), E = [
|
|
41
41
|
{
|
|
42
42
|
key: "responseRate",
|
|
43
43
|
value: S ? `${Math.round(p)} %` : x.notAvailable,
|
|
@@ -46,7 +46,7 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
key: "responseDelay",
|
|
49
|
-
value: C ? g(
|
|
49
|
+
value: C ? g(e.responseDelayMinutes, x.units, b.locale) : x.notAvailable,
|
|
50
50
|
barPercent: w,
|
|
51
51
|
color: w == null ? void 0 : v(w)
|
|
52
52
|
},
|
|
@@ -69,24 +69,24 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
69
69
|
justify: "space-between",
|
|
70
70
|
alignItems: "baseline",
|
|
71
71
|
mb: "space-8",
|
|
72
|
-
children: [/* @__PURE__ */ d(
|
|
72
|
+
children: [/* @__PURE__ */ d(r, {
|
|
73
73
|
as: "span",
|
|
74
74
|
fontSize: "body.md",
|
|
75
75
|
fontWeight: "bold",
|
|
76
76
|
children: x.title
|
|
77
|
-
}),
|
|
77
|
+
}), e.insufficientData || e.overall == null ? /* @__PURE__ */ d(r, {
|
|
78
78
|
as: "span",
|
|
79
79
|
fontSize: "body.sm",
|
|
80
80
|
fontWeight: "medium",
|
|
81
81
|
color: "grey.400",
|
|
82
82
|
children: x.insufficientData
|
|
83
|
-
}) : /* @__PURE__ */ f(
|
|
83
|
+
}) : /* @__PURE__ */ f(r, {
|
|
84
84
|
as: "span",
|
|
85
85
|
fontSize: "body.lg",
|
|
86
86
|
fontWeight: "medium",
|
|
87
|
-
style: { color: _(
|
|
87
|
+
style: { color: _(e.overall) },
|
|
88
88
|
children: [
|
|
89
|
-
h(
|
|
89
|
+
h(e.overall, b.locale),
|
|
90
90
|
" / ",
|
|
91
91
|
5,
|
|
92
92
|
" ★"
|
|
@@ -102,32 +102,32 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
102
102
|
alignItems: "stretch",
|
|
103
103
|
gap: "space-8",
|
|
104
104
|
mb: "space-8",
|
|
105
|
-
children: [/* @__PURE__ */ d(
|
|
105
|
+
children: [/* @__PURE__ */ d(r, {
|
|
106
106
|
as: "span",
|
|
107
107
|
fontSize: "body.sm",
|
|
108
108
|
fontWeight: "bold",
|
|
109
109
|
color: "grey.400",
|
|
110
110
|
children: x.componentsTitle
|
|
111
|
-
}), E.map((
|
|
111
|
+
}), E.map((e) => /* @__PURE__ */ f(l, {
|
|
112
112
|
alignItems: "stretch",
|
|
113
113
|
gap: "space-2",
|
|
114
114
|
children: [/* @__PURE__ */ f(c, {
|
|
115
115
|
justify: "space-between",
|
|
116
116
|
alignItems: "baseline",
|
|
117
117
|
gap: "space-8",
|
|
118
|
-
children: [/* @__PURE__ */ d(
|
|
118
|
+
children: [/* @__PURE__ */ d(r, {
|
|
119
119
|
as: "span",
|
|
120
120
|
fontSize: "body.sm",
|
|
121
121
|
color: "grey.500",
|
|
122
|
-
children: x.components[
|
|
123
|
-
}), /* @__PURE__ */ d(
|
|
122
|
+
children: x.components[e.key]
|
|
123
|
+
}), /* @__PURE__ */ d(r, {
|
|
124
124
|
as: "span",
|
|
125
125
|
fontSize: "body.sm",
|
|
126
126
|
fontWeight: "medium",
|
|
127
127
|
whiteSpace: "nowrap",
|
|
128
|
-
style: { color:
|
|
129
|
-
color:
|
|
130
|
-
children:
|
|
128
|
+
style: { color: e.color },
|
|
129
|
+
color: e.color ? void 0 : "grey.300",
|
|
130
|
+
children: e.value
|
|
131
131
|
})]
|
|
132
132
|
}), /* @__PURE__ */ d(s, {
|
|
133
133
|
h: "3px",
|
|
@@ -138,12 +138,12 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
138
138
|
h: "100%",
|
|
139
139
|
borderRadius: "full",
|
|
140
140
|
style: {
|
|
141
|
-
width:
|
|
142
|
-
background:
|
|
141
|
+
width: e.barPercent == null ? "0%" : `${e.barPercent}%`,
|
|
142
|
+
background: e.color ?? "transparent"
|
|
143
143
|
}
|
|
144
144
|
})
|
|
145
145
|
})]
|
|
146
|
-
},
|
|
146
|
+
}, e.key))]
|
|
147
147
|
}),
|
|
148
148
|
/* @__PURE__ */ d(s, {
|
|
149
149
|
h: "1px",
|
|
@@ -153,29 +153,29 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
153
153
|
/* @__PURE__ */ f(l, {
|
|
154
154
|
alignItems: "stretch",
|
|
155
155
|
gap: "space-4",
|
|
156
|
-
children: [/* @__PURE__ */ d(
|
|
156
|
+
children: [/* @__PURE__ */ d(r, {
|
|
157
157
|
as: "span",
|
|
158
158
|
fontSize: "body.sm",
|
|
159
159
|
fontWeight: "bold",
|
|
160
160
|
color: "grey.400",
|
|
161
161
|
children: x.completionTitle
|
|
162
|
-
}), m.map((
|
|
163
|
-
let
|
|
162
|
+
}), m.map((t) => {
|
|
163
|
+
let n = e.completion[t];
|
|
164
164
|
return /* @__PURE__ */ f(c, {
|
|
165
165
|
alignItems: "center",
|
|
166
166
|
gap: "space-8",
|
|
167
167
|
children: [/* @__PURE__ */ d(i, {
|
|
168
168
|
size: "sm",
|
|
169
|
-
color:
|
|
169
|
+
color: n ? "success.500" : "grey.300",
|
|
170
170
|
flexShrink: "0",
|
|
171
|
-
children: d(
|
|
172
|
-
}), /* @__PURE__ */ d(
|
|
171
|
+
children: d(n ? a : o, {})
|
|
172
|
+
}), /* @__PURE__ */ d(r, {
|
|
173
173
|
as: "span",
|
|
174
174
|
fontSize: "body.sm",
|
|
175
|
-
color:
|
|
176
|
-
children: x.completion[
|
|
175
|
+
color: n ? "grey.500" : "grey.400",
|
|
176
|
+
children: x.completion[t]
|
|
177
177
|
})]
|
|
178
|
-
},
|
|
178
|
+
}, t);
|
|
179
179
|
})]
|
|
180
180
|
}),
|
|
181
181
|
x.footer && /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(s, {
|
|
@@ -183,7 +183,7 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
183
183
|
bg: "grey.100",
|
|
184
184
|
mt: "space-8",
|
|
185
185
|
mb: "space-8"
|
|
186
|
-
}), /* @__PURE__ */ d(
|
|
186
|
+
}), /* @__PURE__ */ d(r, {
|
|
187
187
|
as: "span",
|
|
188
188
|
fontSize: "9px",
|
|
189
189
|
color: "grey.300",
|
|
@@ -193,6 +193,6 @@ var y = ({ rating: t, responseRate: p, labels: y }) => {
|
|
|
193
193
|
]
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
|
-
export {
|
|
196
|
+
export { e as DEFAULT_SUPPLIER_RATING_LABELS, p as SUPPLIER_RATING_MAX, y as SupplierRatingBreakdown, h as formatOverall, g as formatResponseDelay, _ as getHeadlineColor, t as mergeSupplierRatingLabels };
|
|
197
197
|
|
|
198
198
|
//# sourceMappingURL=SupplierRatingBreakdown.js.map
|