@stokelp/ui 2.123.0 → 2.124.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.
Files changed (37) hide show
  1. package/dist/components/app/navigation/language-select/AppNavigationLanguageSelect.cjs +1 -1
  2. package/dist/components/app/navigation/language-select/AppNavigationLanguageSelect.cjs.map +1 -1
  3. package/dist/components/app/navigation/language-select/AppNavigationLanguageSelect.d.ts +13 -0
  4. package/dist/components/app/navigation/language-select/AppNavigationLanguageSelect.js +85 -165
  5. package/dist/components/app/navigation/language-select/AppNavigationLanguageSelect.js.map +1 -1
  6. package/dist/components/combobox/Combobox.cjs +1 -1
  7. package/dist/components/combobox/Combobox.cjs.map +1 -1
  8. package/dist/components/combobox/Combobox.js +71 -70
  9. package/dist/components/combobox/Combobox.js.map +1 -1
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/select/Select.cjs +1 -1
  12. package/dist/components/select/Select.cjs.map +1 -1
  13. package/dist/components/select/Select.js +75 -74
  14. package/dist/components/select/Select.js.map +1 -1
  15. package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs +1 -1
  16. package/dist/components/supplier-rating-badge/SupplierRatingBadge.cjs.map +1 -1
  17. package/dist/components/supplier-rating-badge/SupplierRatingBadge.js +10 -9
  18. package/dist/components/supplier-rating-badge/SupplierRatingBadge.js.map +1 -1
  19. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs +1 -1
  20. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.cjs.map +1 -1
  21. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.d.ts +5 -43
  22. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js +69 -101
  23. package/dist/components/supplier-rating-badge/SupplierRatingBreakdown.js.map +1 -1
  24. package/dist/components/supplier-rating-badge/labels.cjs +2 -0
  25. package/dist/components/supplier-rating-badge/labels.cjs.map +1 -0
  26. package/dist/components/supplier-rating-badge/labels.d.ts +42 -0
  27. package/dist/components/supplier-rating-badge/labels.js +49 -0
  28. package/dist/components/supplier-rating-badge/labels.js.map +1 -0
  29. package/dist/components/ui-labels/UiLabelsProvider.cjs +2 -0
  30. package/dist/components/ui-labels/UiLabelsProvider.cjs.map +1 -0
  31. package/dist/components/ui-labels/UiLabelsProvider.d.ts +27 -0
  32. package/dist/components/ui-labels/UiLabelsProvider.js +28 -0
  33. package/dist/components/ui-labels/UiLabelsProvider.js.map +1 -0
  34. package/dist/components/ui-labels/index.d.ts +1 -0
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.js +57 -55
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SupplierRatingBreakdown.cjs","names":[],"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'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): 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 `${days.toFixed(1).replace('.', ',')} ${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 labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\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 ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : 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)} / {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":"4aAKA,IAAa,EAAsB,EAgDtB,EAAuD,CAClE,MAAO,mBACP,iBAAkB,WAClB,gBAAiB,oBACjB,gBAAiB,uBACjB,aAAc,IACd,MAAO,CAAE,QAAS,MAAO,MAAO,IAAK,KAAM,GAAI,EAC/C,WAAY,CACV,aAAc,kBACd,cAAe,mBACf,WAAY,sBACd,EACA,WAAY,CACV,QAAS,gCACT,SAAU,eACV,SAAU,UACV,aAAc,mCACd,OAAQ,qBACR,YAAa,YACf,CACF,EAEM,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAEA,SAAgB,EAAc,EAAyB,CACrD,OAAO,EAAQ,QAAQ,CAAC,EAAE,QAAQ,IAAK,GAAG,CAC5C,CAGA,SAAgB,EAAoB,EAAiB,EAA8C,CACjG,GAAI,EAAU,GAAI,MAAO,GAAG,KAAK,MAAM,CAAO,EAAE,GAAG,EAAM,UACzD,IAAM,EAAQ,EAAU,GAGxB,OAFI,EAAQ,GAAW,GAAG,KAAK,MAAM,CAAK,EAAE,GAAG,EAAM,QAE9C,IADM,EAAQ,IACN,QAAQ,CAAC,EAAE,QAAQ,IAAK,GAAG,EAAE,GAAG,EAAM,MACvD,CAEA,SAAgB,EAAiB,EAAyB,CACxD,IAAM,EAAQ,EAAA,EAGd,OAFI,GAAS,GAAY,UACrB,GAAS,GAAY,UAClB,SACT,CAEA,SAAS,EAAY,EAA8B,CAGjD,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js","names":[],"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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mBAA1C,EACE,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,KAAK,KAAK,MAAO,EAAO,cAAgB,WAAY,WAAW,aAClE,GAAO,EAAA,EAAA,KAAC,EAAA,QAAD,CAAkB,CAAA,GAAI,EAAA,EAAA,KAAC,EAAA,QAAD,CAAc,CAAA,CACxC,CAAA,GACN,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,MAAO,EAAO,WAAa,oBAC3D,EAAO,WAAW,EACf,CAAA,CACA,GAPK,CAOL,CAEZ,CAAC,CACK,IAEP,EAAO,SACN,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,EACE,EAAA,EAAA,KAAC,EAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,WACpE,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,GAET"}
@@ -1,47 +1,10 @@
1
+ import { SupplierRating, SupplierRatingLabels } from './labels';
2
+ export * from './labels';
1
3
  export declare const SUPPLIER_RATING_MAX = 5;
2
- export type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion';
3
- export type SupplierRatingCompletionKey = 'profile' | 'location' | 'contacts' | 'legalBanking' | 'sector' | 'certificate';
4
- export type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>;
5
- export type SupplierRating = {
6
- /** Overall note out of 5. Absent when insufficientData is true. */
7
- overall?: number;
8
- /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */
9
- responseRateScore?: number;
10
- /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */
11
- responseDelayScore?: number;
12
- /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */
13
- responseDelayMinutes?: number;
14
- /** Account-completion sub-score, 0..1. Always present. */
15
- completionScore: number;
16
- /** True when the supplier has too few interactions for a reliable note. */
17
- insufficientData: boolean;
18
- /** Completion checklist shown in the breakdown. */
19
- completion: SupplierRatingCompletion;
20
- };
21
- export type SupplierRatingLabels = {
22
- title: string;
23
- /** Neutral state shown instead of a note when data is insufficient. */
24
- insufficientData: string;
25
- /** Section heading above the sub-scores. */
26
- componentsTitle: string;
27
- /** Section heading above the completion checklist. */
28
- completionTitle: string;
29
- /** Value shown when a component has no data yet (e.g. "—"). */
30
- notAvailable: string;
31
- /** Unit suffixes for the average response-delay value. */
32
- units: {
33
- minutes: string;
34
- hours: string;
35
- days: string;
36
- };
37
- components: Record<SupplierRatingComponentKey, string>;
38
- completion: Record<SupplierRatingCompletionKey, string>;
39
- footer?: string;
40
- };
41
- export declare const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels;
42
- export declare function formatOverall(overall: number): string;
4
+ /** Note with one decimal in the reader's number format ("4,2" in French, "4.2" in English). */
5
+ export declare function formatOverall(overall: number, locale?: string): string;
43
6
  /** Average response delay: minutes → "45 min" / "18 h" / "2,5 j". */
44
- export declare function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): string;
7
+ export declare function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units'], locale?: string): string;
45
8
  export declare function getHeadlineColor(overall: number): string;
46
9
  type SupplierRatingBreakdownProps = {
47
10
  rating: SupplierRating;
@@ -50,4 +13,3 @@ type SupplierRatingBreakdownProps = {
50
13
  labels?: Partial<SupplierRatingLabels>;
51
14
  };
52
15
  export declare const SupplierRatingBreakdown: ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => import("react/jsx-runtime").JSX.Element;
53
- export {};
@@ -1,36 +1,14 @@
1
1
  "use client";
2
2
  import { Text as e } from "../text/Text.js";
3
- import { Icon as t } from "../icon/Icon.js";
4
- import n from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.js";
5
- import r from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.js";
6
- import { Box as i, HStack as a, VStack as o } from "@stokelp/styled-system/jsx";
7
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
3
+ import { mergeSupplierRatingLabels as t } from "./labels.js";
4
+ import { useUiLabels as n } from "../ui-labels/UiLabelsProvider.js";
5
+ import { Icon as r } from "../icon/Icon.js";
6
+ import i from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.js";
7
+ import a from "../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.js";
8
+ import { Box as o, HStack as s, VStack as c } from "@stokelp/styled-system/jsx";
9
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
10
  //#region src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx
9
- var u = 5, d = {
10
- title: "Note fournisseur",
11
- insufficientData: "Non noté",
12
- componentsTitle: "Détail de la note",
13
- completionTitle: "Complétion du compte",
14
- notAvailable: "—",
15
- units: {
16
- minutes: "min",
17
- hours: "h",
18
- days: "j"
19
- },
20
- components: {
21
- responseRate: "Taux de réponse",
22
- responseDelay: "Délai de réponse",
23
- completion: "Complétion du compte"
24
- },
25
- completion: {
26
- profile: "Profil (photo et description)",
27
- location: "Localisation",
28
- contacts: "Contact",
29
- legalBanking: "Coordonnées légales et bancaires",
30
- sector: "Secteur d'activité",
31
- certificate: "Certificat"
32
- }
33
- }, f = [
11
+ var f = 5, p = [
34
12
  "profile",
35
13
  "location",
36
14
  "contacts",
@@ -38,58 +16,48 @@ var u = 5, d = {
38
16
  "sector",
39
17
  "certificate"
40
18
  ];
41
- function p(e) {
42
- return e.toFixed(1).replace(".", ",");
19
+ function m(e, t = "fr-FR") {
20
+ return new Intl.NumberFormat(t, {
21
+ minimumFractionDigits: 1,
22
+ maximumFractionDigits: 1
23
+ }).format(e);
43
24
  }
44
- function m(e, t) {
25
+ function h(e, t, n = "fr-FR") {
45
26
  if (e < 60) return `${Math.round(e)} ${t.minutes}`;
46
- let n = e / 60;
47
- return n < 48 ? `${Math.round(n)} ${t.hours}` : `${(n / 24).toFixed(1).replace(".", ",")} ${t.days}`;
27
+ let r = e / 60;
28
+ if (r < 48) return `${Math.round(r)} ${t.hours}`;
29
+ let i = r / 24;
30
+ return `${new Intl.NumberFormat(n, { maximumFractionDigits: 1 }).format(i)} ${t.days}`;
48
31
  }
49
- function h(e) {
32
+ function g(e) {
50
33
  let t = e / 5;
51
34
  return t >= .7 ? "#3B6D11" : t >= .4 ? "#854F0B" : "#A32D2D";
52
35
  }
53
- function g(e) {
36
+ function _(e) {
54
37
  return e >= 70 ? "#639922" : e >= 40 ? "#BA7517" : "#E24B4A";
55
38
  }
56
- var _ = ({ rating: u, responseRate: _, labels: v }) => {
57
- let y = {
58
- ...d,
59
- ...v,
60
- units: {
61
- ...d.units,
62
- ...v?.units
63
- },
64
- components: {
65
- ...d.components,
66
- ...v?.components
67
- },
68
- completion: {
69
- ...d.completion,
70
- ...v?.completion
71
- }
72
- }, b = _ != null, x = u.responseDelayMinutes != null, S = u.responseDelayScore == null ? null : Math.round(u.responseDelayScore * 100), C = Math.round(u.completionScore * 100), w = [
39
+ var v = ({ rating: f, responseRate: v, labels: y }) => {
40
+ let b = n(), x = t(b.supplierRating, y), S = v != null, C = f.responseDelayMinutes != null, w = f.responseDelayScore == null ? null : Math.round(f.responseDelayScore * 100), T = Math.round(f.completionScore * 100), E = [
73
41
  {
74
42
  key: "responseRate",
75
- value: b ? `${Math.round(_)} %` : y.notAvailable,
76
- barPercent: b ? Math.round(_) : null,
77
- color: b ? g(Math.round(_)) : void 0
43
+ value: S ? `${Math.round(v)} %` : x.notAvailable,
44
+ barPercent: S ? Math.round(v) : null,
45
+ color: S ? _(Math.round(v)) : void 0
78
46
  },
79
47
  {
80
48
  key: "responseDelay",
81
- value: x ? m(u.responseDelayMinutes, y.units) : y.notAvailable,
82
- barPercent: S,
83
- color: S == null ? void 0 : g(S)
49
+ value: C ? h(f.responseDelayMinutes, x.units, b.locale) : x.notAvailable,
50
+ barPercent: w,
51
+ color: w == null ? void 0 : _(w)
84
52
  },
85
53
  {
86
54
  key: "completion",
87
- value: `${C} %`,
88
- barPercent: C,
89
- color: g(C)
55
+ value: `${T} %`,
56
+ barPercent: T,
57
+ color: _(T)
90
58
  }
91
59
  ];
92
- return /* @__PURE__ */ l(i, {
60
+ return /* @__PURE__ */ d(o, {
93
61
  bg: "white",
94
62
  borderRadius: "radius-8",
95
63
  p: "space-16",
@@ -97,62 +65,62 @@ var _ = ({ rating: u, responseRate: _, labels: v }) => {
97
65
  maxW: "260px",
98
66
  css: { "& *": { fontFamily: "inherit" } },
99
67
  children: [
100
- /* @__PURE__ */ l(a, {
68
+ /* @__PURE__ */ d(s, {
101
69
  justify: "space-between",
102
70
  alignItems: "baseline",
103
71
  mb: "space-8",
104
- children: [/* @__PURE__ */ c(e, {
72
+ children: [/* @__PURE__ */ u(e, {
105
73
  as: "span",
106
74
  fontSize: "body.md",
107
75
  fontWeight: "bold",
108
- children: y.title
109
- }), u.insufficientData || u.overall == null ? /* @__PURE__ */ c(e, {
76
+ children: x.title
77
+ }), f.insufficientData || f.overall == null ? /* @__PURE__ */ u(e, {
110
78
  as: "span",
111
79
  fontSize: "body.sm",
112
80
  fontWeight: "medium",
113
81
  color: "grey.400",
114
- children: y.insufficientData
115
- }) : /* @__PURE__ */ l(e, {
82
+ children: x.insufficientData
83
+ }) : /* @__PURE__ */ d(e, {
116
84
  as: "span",
117
85
  fontSize: "body.lg",
118
86
  fontWeight: "medium",
119
- style: { color: h(u.overall) },
87
+ style: { color: g(f.overall) },
120
88
  children: [
121
- p(u.overall),
89
+ m(f.overall, b.locale),
122
90
  " / ",
123
91
  5,
124
92
  " ★"
125
93
  ]
126
94
  })]
127
95
  }),
128
- /* @__PURE__ */ c(i, {
96
+ /* @__PURE__ */ u(o, {
129
97
  h: "1px",
130
98
  bg: "grey.100",
131
99
  mb: "space-8"
132
100
  }),
133
- /* @__PURE__ */ l(o, {
101
+ /* @__PURE__ */ d(c, {
134
102
  alignItems: "stretch",
135
103
  gap: "space-8",
136
104
  mb: "space-8",
137
- children: [/* @__PURE__ */ c(e, {
105
+ children: [/* @__PURE__ */ u(e, {
138
106
  as: "span",
139
107
  fontSize: "body.sm",
140
108
  fontWeight: "bold",
141
109
  color: "grey.400",
142
- children: y.componentsTitle
143
- }), w.map((t) => /* @__PURE__ */ l(o, {
110
+ children: x.componentsTitle
111
+ }), E.map((t) => /* @__PURE__ */ d(c, {
144
112
  alignItems: "stretch",
145
113
  gap: "space-2",
146
- children: [/* @__PURE__ */ l(a, {
114
+ children: [/* @__PURE__ */ d(s, {
147
115
  justify: "space-between",
148
116
  alignItems: "baseline",
149
117
  gap: "space-8",
150
- children: [/* @__PURE__ */ c(e, {
118
+ children: [/* @__PURE__ */ u(e, {
151
119
  as: "span",
152
120
  fontSize: "body.sm",
153
121
  color: "grey.500",
154
- children: y.components[t.key]
155
- }), /* @__PURE__ */ c(e, {
122
+ children: x.components[t.key]
123
+ }), /* @__PURE__ */ u(e, {
156
124
  as: "span",
157
125
  fontSize: "body.sm",
158
126
  fontWeight: "medium",
@@ -161,12 +129,12 @@ var _ = ({ rating: u, responseRate: _, labels: v }) => {
161
129
  color: t.color ? void 0 : "grey.300",
162
130
  children: t.value
163
131
  })]
164
- }), /* @__PURE__ */ c(i, {
132
+ }), /* @__PURE__ */ u(o, {
165
133
  h: "3px",
166
134
  bg: "grey.100",
167
135
  borderRadius: "full",
168
136
  overflow: "hidden",
169
- children: /* @__PURE__ */ c(i, {
137
+ children: /* @__PURE__ */ u(o, {
170
138
  h: "100%",
171
139
  borderRadius: "full",
172
140
  style: {
@@ -177,55 +145,55 @@ var _ = ({ rating: u, responseRate: _, labels: v }) => {
177
145
  })]
178
146
  }, t.key))]
179
147
  }),
180
- /* @__PURE__ */ c(i, {
148
+ /* @__PURE__ */ u(o, {
181
149
  h: "1px",
182
150
  bg: "grey.100",
183
151
  mb: "space-8"
184
152
  }),
185
- /* @__PURE__ */ l(o, {
153
+ /* @__PURE__ */ d(c, {
186
154
  alignItems: "stretch",
187
155
  gap: "space-4",
188
- children: [/* @__PURE__ */ c(e, {
156
+ children: [/* @__PURE__ */ u(e, {
189
157
  as: "span",
190
158
  fontSize: "body.sm",
191
159
  fontWeight: "bold",
192
160
  color: "grey.400",
193
- children: y.completionTitle
194
- }), f.map((i) => {
195
- let o = u.completion[i];
196
- return /* @__PURE__ */ l(a, {
161
+ children: x.completionTitle
162
+ }), p.map((t) => {
163
+ let n = f.completion[t];
164
+ return /* @__PURE__ */ d(s, {
197
165
  alignItems: "center",
198
166
  gap: "space-8",
199
- children: [/* @__PURE__ */ c(t, {
167
+ children: [/* @__PURE__ */ u(r, {
200
168
  size: "sm",
201
- color: o ? "success.500" : "grey.300",
169
+ color: n ? "success.500" : "grey.300",
202
170
  flexShrink: "0",
203
- children: c(o ? n : r, {})
204
- }), /* @__PURE__ */ c(e, {
171
+ children: u(n ? i : a, {})
172
+ }), /* @__PURE__ */ u(e, {
205
173
  as: "span",
206
174
  fontSize: "body.sm",
207
- color: o ? "grey.500" : "grey.400",
208
- children: y.completion[i]
175
+ color: n ? "grey.500" : "grey.400",
176
+ children: x.completion[t]
209
177
  })]
210
- }, i);
178
+ }, t);
211
179
  })]
212
180
  }),
213
- y.footer && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(i, {
181
+ x.footer && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(o, {
214
182
  h: "1px",
215
183
  bg: "grey.100",
216
184
  mt: "space-8",
217
185
  mb: "space-8"
218
- }), /* @__PURE__ */ c(e, {
186
+ }), /* @__PURE__ */ u(e, {
219
187
  as: "span",
220
188
  fontSize: "9px",
221
189
  color: "grey.300",
222
190
  style: { lineHeight: 1 },
223
- children: y.footer
191
+ children: x.footer
224
192
  })] })
225
193
  ]
226
194
  });
227
195
  };
228
196
  //#endregion
229
- export { d as DEFAULT_SUPPLIER_RATING_LABELS, u as SUPPLIER_RATING_MAX, _ as SupplierRatingBreakdown, p as formatOverall, m as formatResponseDelay, h as getHeadlineColor };
197
+ export { f as SUPPLIER_RATING_MAX, v as SupplierRatingBreakdown, m as formatOverall, h as formatResponseDelay, g as getHeadlineColor };
230
198
 
231
199
  //# sourceMappingURL=SupplierRatingBreakdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SupplierRatingBreakdown.js","names":[],"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'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): 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 `${days.toFixed(1).replace('.', ',')} ${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 labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\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 ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : 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)} / {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":";;;;;;;;AAKA,IAAa,IAAsB,GAgDtB,IAAuD;CAClE,OAAO;CACP,kBAAkB;CAClB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,OAAO;EAAE,SAAS;EAAO,OAAO;EAAK,MAAM;CAAI;CAC/C,YAAY;EACV,cAAc;EACd,eAAe;EACf,YAAY;CACd;CACA,YAAY;EACV,SAAS;EACT,UAAU;EACV,UAAU;EACV,cAAc;EACd,QAAQ;EACR,aAAa;CACf;AACF,GAEM,IAAkD;CACtD;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,EAAc,GAAyB;CACrD,OAAO,EAAQ,QAAQ,CAAC,EAAE,QAAQ,KAAK,GAAG;AAC5C;AAGA,SAAgB,EAAoB,GAAiB,GAA8C;CACjG,IAAI,IAAU,IAAI,OAAO,GAAG,KAAK,MAAM,CAAO,EAAE,GAAG,EAAM;CACzD,IAAM,IAAQ,IAAU;CAGxB,OAFI,IAAQ,KAAW,GAAG,KAAK,MAAM,CAAK,EAAE,GAAG,EAAM,UAE9C,IADM,IAAQ,IACN,QAAQ,CAAC,EAAE,QAAQ,KAAK,GAAG,EAAE,GAAG,EAAM;AACvD;AAEA,SAAgB,EAAiB,GAAyB;CACxD,IAAM,IAAQ,IAAA;CAGd,OAFI,KAAS,KAAY,YACrB,KAAS,KAAY,YAClB;AACT;AAEA,SAAS,EAAY,GAA8B;CAGjD,OAFI,KAAgB,KAAW,YAC3B,KAAgB,KAAW,YACxB;AACT;AAkBA,IAAa,KAA2B,E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AAW;KAAO,OAAM;eACxD,EAAO;IACJ,CAAA,GACL,EAAiB,KAAI,MAAO;KAC3B,IAAM,IAAO,EAAO,WAAW;KAC/B,OACE,kBAAC,GAAD;MAAkB,YAAW;MAAS,KAAI;gBAA1C,CACE,kBAAC,GAAD;OAAM,MAAK;OAAK,OAAO,IAAO,gBAAgB;OAAY,YAAW;iBAC3D,EAAP,IAAQ,IAAsB,GAAvB,CAAkB,CAAkB;MACxC,CAAA,GACN,kBAAC,GAAD;OAAM,IAAG;OAAO,UAAS;OAAU,OAAO,IAAO,aAAa;iBAC3D,EAAO,WAAW;MACf,CAAA,CACA;QAPK,CAOL;IAEZ,CAAC,CACK;;GAEP,EAAO,UACN,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAAC,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;cACpE,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
1
+ {"version":3,"file":"SupplierRatingBreakdown.js","names":[],"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":";;;;;;;;;;AAeA,IAAa,IAAsB,GAE7B,IAAkD;CACtD;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,SAAgB,EAAc,GAAiB,IAAS,SAAiB;CACvE,OAAO,IAAI,KAAK,aAAa,GAAQ;EAAE,uBAAuB;EAAG,uBAAuB;CAAE,CAAC,EAAE,OAAO,CAAO;AAC7G;AAGA,SAAgB,EAAoB,GAAiB,GAAsC,IAAS,SAAiB;CACnH,IAAI,IAAU,IAAI,OAAO,GAAG,KAAK,MAAM,CAAO,EAAE,GAAG,EAAM;CACzD,IAAM,IAAQ,IAAU;CACxB,IAAI,IAAQ,IAAI,OAAO,GAAG,KAAK,MAA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AY,EAAI,SAAS;OAC3B;MACD,CAAA;KACE,CAAA,CACC;OA1BK,EAAI,GA0BT,CACT,CACK;;GAER,kBAAC,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;GAAW,CAAA;GAEzC,kBAAC,GAAD;IAAQ,YAAW;IAAU,KAAI;cAAjC,CACE,kBAAC,GAAD;KAAM,IAAG;KAAO,UAAS;KAAU,YAAW;KAAO,OAAM;eACxD,EAAO;IACJ,CAAA,GACL,EAAiB,KAAI,MAAO;KAC3B,IAAM,IAAO,EAAO,WAAW;KAC/B,OACE,kBAAC,GAAD;MAAkB,YAAW;MAAS,KAAI;gBAA1C,CACE,kBAAC,GAAD;OAAM,MAAK;OAAK,OAAO,IAAO,gBAAgB;OAAY,YAAW;iBAC3D,EAAP,IAAQ,IAAsB,GAAvB,CAAkB,CAAkB;MACxC,CAAA,GACN,kBAAC,GAAD;OAAM,IAAG;OAAO,UAAS;OAAU,OAAO,IAAO,aAAa;iBAC3D,EAAO,WAAW;MACf,CAAA,CACA;QAPK,CAOL;IAEZ,CAAC,CACK;;GAEP,EAAO,UACN,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAAC,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;cACpE,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
@@ -0,0 +1,2 @@
1
+ "use client";var e={title:`Note fournisseur`,insufficientData:`Non noté`,componentsTitle:`Détail de la note`,completionTitle:`Complétion du compte`,notAvailable:`-`,units:{minutes:`min`,hours:`h`,days:`j`},components:{responseRate:`Taux de réponse`,responseDelay:`Délai de réponse`,completion:`Complétion du compte`},completion:{profile:`Profil (photo et description)`,location:`Localisation`,contacts:`Contact`,legalBanking:`Coordonnées légales et bancaires`,sector:`Secteur d'activité`,certificate:`Certificat`}};function t(e,t){return{...e,...t,units:{...e.units,...t?.units},components:{...e.components,...t?.components},completion:{...e.completion,...t?.completion}}}exports.DEFAULT_SUPPLIER_RATING_LABELS=e,exports.mergeSupplierRatingLabels=t;
2
+ //# sourceMappingURL=labels.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.cjs","names":[],"sources":["../../../src/components/supplier-rating-badge/labels.ts"],"sourcesContent":["// Labels of the supplier rating, apart from the components so UiLabelsProvider can carry an\n// app-wide translation without an import cycle. The defaults are French: an app that renders in\n// another locale passes its own through UiLabelsProvider (or the `labels` prop).\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"-\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '-',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\n/** `base` overridden by `override`, nested groups merged key by key. */\nexport function mergeSupplierRatingLabels(\n base: SupplierRatingLabels,\n override?: Partial<SupplierRatingLabels>,\n): SupplierRatingLabels {\n return {\n ...base,\n ...override,\n units: { ...base.units, ...override?.units },\n components: { ...base.components, ...override?.components },\n completion: { ...base.completion, ...override?.completion },\n }\n}\n"],"mappings":"aAkDA,IAAa,EAAuD,CAClE,MAAO,mBACP,iBAAkB,WAClB,gBAAiB,oBACjB,gBAAiB,uBACjB,aAAc,IACd,MAAO,CAAE,QAAS,MAAO,MAAO,IAAK,KAAM,GAAI,EAC/C,WAAY,CACV,aAAc,kBACd,cAAe,mBACf,WAAY,sBACd,EACA,WAAY,CACV,QAAS,gCACT,SAAU,eACV,SAAU,UACV,aAAc,mCACd,OAAQ,qBACR,YAAa,YACf,CACF,EAGA,SAAgB,EACd,EACA,EACsB,CACtB,MAAO,CACL,GAAG,EACH,GAAG,EACH,MAAO,CAAE,GAAG,EAAK,MAAO,GAAG,GAAU,KAAM,EAC3C,WAAY,CAAE,GAAG,EAAK,WAAY,GAAG,GAAU,UAAW,EAC1D,WAAY,CAAE,GAAG,EAAK,WAAY,GAAG,GAAU,UAAW,CAC5D,CACF"}
@@ -0,0 +1,42 @@
1
+ export type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion';
2
+ export type SupplierRatingCompletionKey = 'profile' | 'location' | 'contacts' | 'legalBanking' | 'sector' | 'certificate';
3
+ export type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>;
4
+ export type SupplierRating = {
5
+ /** Overall note out of 5. Absent when insufficientData is true. */
6
+ overall?: number;
7
+ /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */
8
+ responseRateScore?: number;
9
+ /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */
10
+ responseDelayScore?: number;
11
+ /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */
12
+ responseDelayMinutes?: number;
13
+ /** Account-completion sub-score, 0..1. Always present. */
14
+ completionScore: number;
15
+ /** True when the supplier has too few interactions for a reliable note. */
16
+ insufficientData: boolean;
17
+ /** Completion checklist shown in the breakdown. */
18
+ completion: SupplierRatingCompletion;
19
+ };
20
+ export type SupplierRatingLabels = {
21
+ title: string;
22
+ /** Neutral state shown instead of a note when data is insufficient. */
23
+ insufficientData: string;
24
+ /** Section heading above the sub-scores. */
25
+ componentsTitle: string;
26
+ /** Section heading above the completion checklist. */
27
+ completionTitle: string;
28
+ /** Value shown when a component has no data yet (e.g. "-"). */
29
+ notAvailable: string;
30
+ /** Unit suffixes for the average response-delay value. */
31
+ units: {
32
+ minutes: string;
33
+ hours: string;
34
+ days: string;
35
+ };
36
+ components: Record<SupplierRatingComponentKey, string>;
37
+ completion: Record<SupplierRatingCompletionKey, string>;
38
+ footer?: string;
39
+ };
40
+ export declare const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels;
41
+ /** `base` overridden by `override`, nested groups merged key by key. */
42
+ export declare function mergeSupplierRatingLabels(base: SupplierRatingLabels, override?: Partial<SupplierRatingLabels>): SupplierRatingLabels;
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ //#region src/components/supplier-rating-badge/labels.ts
3
+ var e = {
4
+ title: "Note fournisseur",
5
+ insufficientData: "Non noté",
6
+ componentsTitle: "Détail de la note",
7
+ completionTitle: "Complétion du compte",
8
+ notAvailable: "-",
9
+ units: {
10
+ minutes: "min",
11
+ hours: "h",
12
+ days: "j"
13
+ },
14
+ components: {
15
+ responseRate: "Taux de réponse",
16
+ responseDelay: "Délai de réponse",
17
+ completion: "Complétion du compte"
18
+ },
19
+ completion: {
20
+ profile: "Profil (photo et description)",
21
+ location: "Localisation",
22
+ contacts: "Contact",
23
+ legalBanking: "Coordonnées légales et bancaires",
24
+ sector: "Secteur d'activité",
25
+ certificate: "Certificat"
26
+ }
27
+ };
28
+ function t(e, t) {
29
+ return {
30
+ ...e,
31
+ ...t,
32
+ units: {
33
+ ...e.units,
34
+ ...t?.units
35
+ },
36
+ components: {
37
+ ...e.components,
38
+ ...t?.components
39
+ },
40
+ completion: {
41
+ ...e.completion,
42
+ ...t?.completion
43
+ }
44
+ };
45
+ }
46
+ //#endregion
47
+ export { e as DEFAULT_SUPPLIER_RATING_LABELS, t as mergeSupplierRatingLabels };
48
+
49
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.js","names":[],"sources":["../../../src/components/supplier-rating-badge/labels.ts"],"sourcesContent":["// Labels of the supplier rating, apart from the components so UiLabelsProvider can carry an\n// app-wide translation without an import cycle. The defaults are French: an app that renders in\n// another locale passes its own through UiLabelsProvider (or the `labels` prop).\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"-\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '-',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\n/** `base` overridden by `override`, nested groups merged key by key. */\nexport function mergeSupplierRatingLabels(\n base: SupplierRatingLabels,\n override?: Partial<SupplierRatingLabels>,\n): SupplierRatingLabels {\n return {\n ...base,\n ...override,\n units: { ...base.units, ...override?.units },\n components: { ...base.components, ...override?.components },\n completion: { ...base.completion, ...override?.completion },\n }\n}\n"],"mappings":";;AAkDA,IAAa,IAAuD;CAClE,OAAO;CACP,kBAAkB;CAClB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,OAAO;EAAE,SAAS;EAAO,OAAO;EAAK,MAAM;CAAI;CAC/C,YAAY;EACV,cAAc;EACd,eAAe;EACf,YAAY;CACd;CACA,YAAY;EACV,SAAS;EACT,UAAU;EACV,UAAU;EACV,cAAc;EACd,QAAQ;EACR,aAAa;CACf;AACF;AAGA,SAAgB,EACd,GACA,GACsB;CACtB,OAAO;EACL,GAAG;EACH,GAAG;EACH,OAAO;GAAE,GAAG,EAAK;GAAO,GAAG,GAAU;EAAM;EAC3C,YAAY;GAAE,GAAG,EAAK;GAAY,GAAG,GAAU;EAAW;EAC1D,YAAY;GAAE,GAAG,EAAK;GAAY,GAAG,GAAU;EAAW;CAC5D;AACF"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../supplier-rating-badge/labels.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={locale:`fr-FR`,noResults:`Aucun résultat`,loading:`Chargement...`,supplierRating:e.DEFAULT_SUPPLIER_RATING_LABELS},i=(0,t.createContext)(r),a=({labels:a,children:o})=>{let s=(0,t.useMemo)(()=>({...r,...a,supplierRating:e.mergeSupplierRatingLabels(r.supplierRating,a.supplierRating)}),[a]);return(0,n.jsx)(i.Provider,{value:s,children:o})};function o(){return(0,t.useContext)(i)}exports.DEFAULT_UI_LABELS=r,exports.UiLabelsProvider=a,exports.useUiLabels=o;
2
+ //# sourceMappingURL=UiLabelsProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UiLabelsProvider.cjs","names":[],"sources":["../../../src/components/ui-labels/UiLabelsProvider.tsx"],"sourcesContent":["import { createContext, type FC, type ReactNode, useContext, useMemo } from 'react'\n\nimport {\n DEFAULT_SUPPLIER_RATING_LABELS,\n mergeSupplierRatingLabels,\n type SupplierRatingLabels,\n} from '../supplier-rating-badge/labels'\n\n/**\n * The words and number format the kit renders on its own (empty lists, loading states, the\n * supplier rating). The kit carries no translations: an app wraps its tree once in\n * UiLabelsProvider with its own, in the reader's locale. Without a provider the kit reads French,\n * as it always has.\n */\nexport type UiLabels = {\n /** BCP 47 tag the kit formats numbers with (the supplier rating's note). */\n locale: string\n /** Shown by Select and Combobox when there is nothing to pick. */\n noResults: string\n /** Shown by Combobox while its items load. */\n loading: string\n supplierRating: SupplierRatingLabels\n}\n\nexport type UiLabelsInput = Partial<Omit<UiLabels, 'supplierRating'>> & {\n supplierRating?: Partial<SupplierRatingLabels>\n}\n\nexport const DEFAULT_UI_LABELS: UiLabels = {\n locale: 'fr-FR',\n noResults: 'Aucun résultat',\n loading: 'Chargement...',\n supplierRating: DEFAULT_SUPPLIER_RATING_LABELS,\n}\n\nconst UiLabelsContext = createContext<UiLabels>(DEFAULT_UI_LABELS)\n\nexport const UiLabelsProvider: FC<{ labels: UiLabelsInput; children: ReactNode }> = ({ labels, children }) => {\n const value = useMemo<UiLabels>(\n () => ({\n ...DEFAULT_UI_LABELS,\n ...labels,\n supplierRating: mergeSupplierRatingLabels(DEFAULT_UI_LABELS.supplierRating, labels.supplierRating),\n }),\n [labels],\n )\n return <UiLabelsContext.Provider value={value}>{children}</UiLabelsContext.Provider>\n}\n\n/** The labels of the nearest UiLabelsProvider, or the French defaults. */\nexport function useUiLabels(): UiLabels {\n return useContext(UiLabelsContext)\n}\n"],"mappings":"0HA4BA,IAAa,EAA8B,CACzC,OAAQ,QACR,UAAW,iBACX,QAAS,gBACT,eAAgB,EAAA,8BAClB,EAEM,GAAA,EAAA,EAAA,eAA0C,CAAiB,EAEpD,GAAwE,CAAE,SAAQ,cAAe,CAC5G,IAAM,GAAA,EAAA,EAAA,cACG,CACL,GAAG,EACH,GAAG,EACH,eAAgB,EAAA,0BAA0B,EAAkB,eAAgB,EAAO,cAAc,CACnG,GACA,CAAC,CAAM,CACT,EACA,OAAO,EAAA,EAAA,KAAC,EAAgB,SAAjB,CAAiC,QAAQ,UAAmC,CAAA,CACrF,EAGA,SAAgB,GAAwB,CACtC,OAAA,EAAA,EAAA,YAAkB,CAAe,CACnC"}