@homefile/components-v2 2.26.5 → 2.26.6

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 (29) hide show
  1. package/dist/assets/locales/en/index.json +7 -0
  2. package/dist/components/homeItems/HomeItemList.d.ts +2 -0
  3. package/dist/components/homeItems/HomeItemList.js +32 -0
  4. package/dist/components/homeItems/ProductRadioCardContent.d.ts +2 -0
  5. package/dist/components/homeItems/ProductRadioCardContent.js +11 -0
  6. package/dist/components/homeItems/index.d.ts +1 -0
  7. package/dist/components/homeItems/index.js +1 -0
  8. package/dist/components/receipts/receipt/DetailsColumn.d.ts +1 -1
  9. package/dist/components/receipts/receipt/DetailsColumn.js +6 -3
  10. package/dist/interfaces/homeItems/HomeItemList.interface.d.ts +5 -0
  11. package/dist/interfaces/homeItems/HomeItemList.interface.js +1 -0
  12. package/dist/interfaces/homeItems/ProductRadioCardContent.interface.d.ts +6 -0
  13. package/dist/interfaces/homeItems/ProductRadioCardContent.interface.js +1 -0
  14. package/dist/interfaces/homeItems/index.d.ts +2 -0
  15. package/dist/interfaces/homeItems/index.js +2 -0
  16. package/dist/interfaces/receipts/receipt/DetailsColumn.interface.d.ts +5 -3
  17. package/dist/stories/homeItems/HomeItemList.stories.d.ts +5 -0
  18. package/dist/stories/homeItems/HomeItemList.stories.js +29 -0
  19. package/package.json +1 -1
  20. package/src/assets/locales/en/index.json +7 -0
  21. package/src/components/homeItems/HomeItemList.tsx +61 -0
  22. package/src/components/homeItems/ProductRadioCardContent.tsx +27 -0
  23. package/src/components/homeItems/index.ts +1 -0
  24. package/src/components/receipts/receipt/DetailsColumn.tsx +17 -7
  25. package/src/interfaces/homeItems/HomeItemList.interface.ts +6 -0
  26. package/src/interfaces/homeItems/ProductRadioCardContent.interface.ts +6 -0
  27. package/src/interfaces/homeItems/index.ts +2 -0
  28. package/src/interfaces/receipts/receipt/DetailsColumn.interface.ts +5 -2
  29. package/src/stories/homeItems/HomeItemList.stories.tsx +40 -0
@@ -453,6 +453,13 @@
453
453
  "viewDetails": "View All"
454
454
  },
455
455
  "homeItems": {
456
+ "addDetail": "Add more detail",
457
+ "addDetailsManually": "You can enter item detail manually",
458
+ "itemsFound": "We’ve found {{ count }} items with that serial number.",
459
+ "noneAbove": "None of the above, add more detail",
460
+ "noItemsFound": "We didn’t find your item, but don’t worry!",
461
+ "pleaseSelect": "Please select your item from the list below. This also double confirms your selection.",
462
+ "showing": "Showing {{ count }} of {{ total }}",
456
463
  "title": "Viewing Home Item"
457
464
  },
458
465
  "homeHeader": {
@@ -0,0 +1,2 @@
1
+ import { HomeItemListI } from '../../interfaces';
2
+ export declare const HomeItemList: ({ items, onChange }: HomeItemListI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { t } from 'i18next';
3
+ import { Container, Stack, Text, useRadioGroup } from '@chakra-ui/react';
4
+ import { RadioCard, BaseCounter } from '..';
5
+ import { ProductRadioCardContent } from './ProductRadioCardContent';
6
+ export const HomeItemList = ({ items, onChange }) => {
7
+ const hasItems = items.length > 0;
8
+ const firstItemId = items[0].id;
9
+ const { getRadioProps } = useRadioGroup({
10
+ name: 'productItem',
11
+ defaultValue: firstItemId,
12
+ onChange,
13
+ });
14
+ const itemsWithNone = [
15
+ ...items,
16
+ {
17
+ id: 'none',
18
+ name: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
19
+ },
20
+ ];
21
+ return (_jsxs(Container, { h: "full", children: [_jsxs(Stack, { align: "center", spacing: "base", px: "20", py: "8", children: [_jsx(Text, { fontSize: "24px", lineHeight: "28px", textAlign: "center", children: hasItems
22
+ ? t('homeItems.itemsFound', { count: items.length })
23
+ : t('homeItems.noItemsFound') }), _jsx(Text, { fontFamily: "secondary", fontSize: "16px", lineHeight: "20px", textAlign: "center", children: hasItems
24
+ ? t('homeItems.pleaseSelect')
25
+ : t('homeItems.addDetailsManually') })] }), _jsxs(Stack, { bg: "lightViolet.1", p: "base", spacing: "base", h: "full", children: [_jsx(BaseCounter, { text: t('homeItems.showing', {
26
+ count: items.length,
27
+ total: items.length,
28
+ }) }), itemsWithNone.map((item) => {
29
+ const radio = getRadioProps({ value: item.id });
30
+ return (_jsx(RadioCard, Object.assign({}, radio, { children: _jsx(ProductRadioCardContent, Object.assign({}, item)) }), item.id));
31
+ })] })] }));
32
+ };
@@ -0,0 +1,2 @@
1
+ import { ProductRadioCardContentI } from '../../interfaces';
2
+ export declare const ProductRadioCardContent: ({ id, name, brand, model, }: ProductRadioCardContentI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Stack, Text } from '@chakra-ui/react';
3
+ import { DetailsColumn } from '..';
4
+ export const ProductRadioCardContent = ({ id, name, brand, model, }) => {
5
+ const isNone = id === 'none';
6
+ const details = [
7
+ brand && { label: 'Brand:', value: brand },
8
+ model && { label: 'Model#:', value: model },
9
+ ].filter(Boolean);
10
+ return (_jsxs(Stack, { spacing: "base", w: "full", children: [_jsx(Text, { fontSize: isNone ? 'md' : 'lg', children: name }), _jsx(DetailsColumn, { color: "gray.2", details: details, fontSize: "md", leftFlexPercent: 20 })] }));
11
+ };
@@ -1 +1,2 @@
1
+ export * from './HomeItemList';
1
2
  export * from './ViewingHomeItemPanel';
@@ -1 +1,2 @@
1
+ export * from './HomeItemList';
1
2
  export * from './ViewingHomeItemPanel';
@@ -1,2 +1,2 @@
1
1
  import { DetailsColumnI } from '../../../interfaces';
2
- export declare const DetailsColumn: ({ align, details }: DetailsColumnI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const DetailsColumn: ({ align, color, details, fontSize, leftFlexPercent, }: DetailsColumnI) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,10 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Stack, Flex, Text } from '@chakra-ui/react';
3
- export const DetailsColumn = ({ align = 'left', details }) => {
3
+ export const DetailsColumn = ({ align = 'left', color, details, fontSize = 'xs', leftFlexPercent = 45, }) => {
4
4
  const isLeft = align === 'left';
5
+ if (!details || details.length === 0) {
6
+ return null;
7
+ }
5
8
  return (_jsx(Stack, { spacing: "0", flex: "auto", children: details.map((item, index) => {
6
9
  var _a;
7
- const value = (_a = item.value) !== null && _a !== void 0 ? _a : '-';
8
- return (_jsxs(Flex, { justify: "space-between", children: [_jsx(Text, { fontSize: "xs", fontFamily: "secondary", lineHeight: "1.4", flex: isLeft ? '45%' : '', children: item.label }), _jsx(Text, { fontSize: "xs", fontFamily: "secondary", fontWeight: "medium", lineHeight: "1.4", flex: isLeft ? '55%' : '', children: value })] }, index + index));
10
+ const value = (_a = String(item.value)) !== null && _a !== void 0 ? _a : '-';
11
+ return (_jsxs(Flex, { justify: "space-between", children: [_jsx(Text, { fontSize: fontSize, fontFamily: "secondary", lineHeight: "1.4", flex: isLeft ? `${leftFlexPercent}%` : '', color: color, children: item.label }), _jsx(Text, { fontSize: fontSize, fontFamily: "secondary", fontWeight: "medium", lineHeight: "1.4", flex: isLeft ? `${100 - leftFlexPercent}%` : '', children: value })] }, String(item.value) + index));
9
12
  }) }));
10
13
  };
@@ -0,0 +1,5 @@
1
+ import { ProductRadioCardContentI } from '..';
2
+ export interface HomeItemListI {
3
+ items: ProductRadioCardContentI[];
4
+ onChange?: (id: string) => void;
5
+ }
@@ -0,0 +1,6 @@
1
+ export interface ProductRadioCardContentI {
2
+ id: string;
3
+ name?: string;
4
+ brand?: string;
5
+ model?: string;
6
+ }
@@ -1 +1,3 @@
1
1
  export * from './ViewingHomeItemPanel.interface';
2
+ export * from './ProductRadioCardContent.interface';
3
+ export * from './HomeItemList.interface';
@@ -1 +1,3 @@
1
1
  export * from './ViewingHomeItemPanel.interface';
2
+ export * from './ProductRadioCardContent.interface';
3
+ export * from './HomeItemList.interface';
@@ -1,9 +1,11 @@
1
- interface DetailRowI {
1
+ export interface DetailRowI {
2
2
  label?: string;
3
3
  value?: string | number | Date;
4
4
  }
5
5
  export interface DetailsColumnI {
6
6
  align?: 'left' | 'right';
7
- details: DetailRowI[];
7
+ color?: string;
8
+ details?: DetailRowI[];
9
+ fontSize?: string;
10
+ leftFlexPercent?: number;
8
11
  }
9
- export {};
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { HomeItemListI } from '../../interfaces';
3
+ declare const _default: Meta<HomeItemListI>;
4
+ export default _default;
5
+ export declare const HomeItemListComponent: (args: HomeItemListI) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { action } from '@storybook/addon-actions';
3
+ import { DrawerContent } from '@chakra-ui/react';
4
+ import { RightPanel, HomeItemList } from '../../components';
5
+ export default {
6
+ title: 'Components/HomeItems',
7
+ component: HomeItemList,
8
+ args: {
9
+ onChange: action('onChange'),
10
+ items: [
11
+ {
12
+ id: '1',
13
+ name: 'Item 1',
14
+ brand: 'Brand A',
15
+ model: 'Model X',
16
+ },
17
+ {
18
+ id: '2',
19
+ name: 'Item 2',
20
+ brand: 'Brand B',
21
+ model: 'Model Y',
22
+ },
23
+ ],
24
+ },
25
+ decorators: [
26
+ (Story) => (_jsx(RightPanel, { isOpen: true, onClose: action('onClose'), children: _jsx(DrawerContent, { bg: "lightBlue.1", p: "base", children: _jsx(Story, {}) }) })),
27
+ ],
28
+ };
29
+ export const HomeItemListComponent = (args) => (_jsx(HomeItemList, Object.assign({}, args)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.26.5",
3
+ "version": "2.26.6",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -453,6 +453,13 @@
453
453
  "viewDetails": "View All"
454
454
  },
455
455
  "homeItems": {
456
+ "addDetail": "Add more detail",
457
+ "addDetailsManually": "You can enter item detail manually",
458
+ "itemsFound": "We’ve found {{ count }} items with that serial number.",
459
+ "noneAbove": "None of the above, add more detail",
460
+ "noItemsFound": "We didn’t find your item, but don’t worry!",
461
+ "pleaseSelect": "Please select your item from the list below. This also double confirms your selection.",
462
+ "showing": "Showing {{ count }} of {{ total }}",
456
463
  "title": "Viewing Home Item"
457
464
  },
458
465
  "homeHeader": {
@@ -0,0 +1,61 @@
1
+ import { t } from 'i18next'
2
+ import { Container, Stack, Text, useRadioGroup } from '@chakra-ui/react'
3
+ import { RadioCard, BaseCounter } from '@/components'
4
+ import { ProductRadioCardContent } from './ProductRadioCardContent'
5
+ import { HomeItemListI } from '@/interfaces'
6
+
7
+ export const HomeItemList = ({ items, onChange }: HomeItemListI) => {
8
+ const hasItems = items.length > 0
9
+ const firstItemId = items[0].id
10
+ const { getRadioProps } = useRadioGroup({
11
+ name: 'productItem',
12
+ defaultValue: firstItemId,
13
+ onChange,
14
+ })
15
+
16
+ const itemsWithNone = [
17
+ ...items,
18
+ {
19
+ id: 'none',
20
+ name: hasItems ? t('homeItems.noneAbove') : t('homeItems.addDetail'),
21
+ },
22
+ ]
23
+
24
+ return (
25
+ <Container h="full">
26
+ <Stack align="center" spacing="base" px="20" py="8">
27
+ <Text fontSize="24px" lineHeight="28px" textAlign="center">
28
+ {hasItems
29
+ ? t('homeItems.itemsFound', { count: items.length })
30
+ : t('homeItems.noItemsFound')}
31
+ </Text>
32
+ <Text
33
+ fontFamily="secondary"
34
+ fontSize="16px"
35
+ lineHeight="20px"
36
+ textAlign="center"
37
+ >
38
+ {hasItems
39
+ ? t('homeItems.pleaseSelect')
40
+ : t('homeItems.addDetailsManually')}
41
+ </Text>
42
+ </Stack>
43
+ <Stack bg="lightViolet.1" p="base" spacing="base" h="full">
44
+ <BaseCounter
45
+ text={t('homeItems.showing', {
46
+ count: items.length,
47
+ total: items.length,
48
+ })}
49
+ />
50
+ {itemsWithNone.map((item) => {
51
+ const radio = getRadioProps({ value: item.id })
52
+ return (
53
+ <RadioCard key={item.id} {...radio}>
54
+ <ProductRadioCardContent {...item} />
55
+ </RadioCard>
56
+ )
57
+ })}
58
+ </Stack>
59
+ </Container>
60
+ )
61
+ }
@@ -0,0 +1,27 @@
1
+ import { Stack, Text } from '@chakra-ui/react'
2
+ import { ProductRadioCardContentI, DetailRowI } from '@/interfaces'
3
+ import { DetailsColumn } from '@/components'
4
+
5
+ export const ProductRadioCardContent = ({
6
+ id,
7
+ name,
8
+ brand,
9
+ model,
10
+ }: ProductRadioCardContentI) => {
11
+ const isNone = id === 'none'
12
+ const details = [
13
+ brand && { label: 'Brand:', value: brand },
14
+ model && { label: 'Model#:', value: model },
15
+ ].filter(Boolean) as DetailRowI[]
16
+ return (
17
+ <Stack spacing="base" w="full">
18
+ <Text fontSize={isNone ? 'md' : 'lg'}>{name}</Text>
19
+ <DetailsColumn
20
+ color="gray.2"
21
+ details={details}
22
+ fontSize="md"
23
+ leftFlexPercent={20}
24
+ />
25
+ </Stack>
26
+ )
27
+ }
@@ -1 +1,2 @@
1
+ export * from './HomeItemList'
1
2
  export * from './ViewingHomeItemPanel'
@@ -1,28 +1,38 @@
1
1
  import { Stack, Flex, Text } from '@chakra-ui/react'
2
2
  import { DetailsColumnI } from '@/interfaces'
3
3
 
4
- export const DetailsColumn = ({ align = 'left', details }: DetailsColumnI) => {
4
+ export const DetailsColumn = ({
5
+ align = 'left',
6
+ color,
7
+ details,
8
+ fontSize = 'xs',
9
+ leftFlexPercent = 45,
10
+ }: DetailsColumnI) => {
5
11
  const isLeft = align === 'left'
12
+ if (!details || details.length === 0) {
13
+ return null
14
+ }
6
15
  return (
7
16
  <Stack spacing="0" flex="auto">
8
17
  {details.map((item, index) => {
9
- const value = (item.value as string) ?? '-'
18
+ const value = String(item.value) ?? '-'
10
19
  return (
11
- <Flex key={index + index} justify="space-between">
20
+ <Flex key={String(item.value) + index} justify="space-between">
12
21
  <Text
13
- fontSize="xs"
22
+ fontSize={fontSize}
14
23
  fontFamily="secondary"
15
24
  lineHeight="1.4"
16
- flex={isLeft ? '45%' : ''}
25
+ flex={isLeft ? `${leftFlexPercent}%` : ''}
26
+ color={color}
17
27
  >
18
28
  {item.label}
19
29
  </Text>
20
30
  <Text
21
- fontSize="xs"
31
+ fontSize={fontSize}
22
32
  fontFamily="secondary"
23
33
  fontWeight="medium"
24
34
  lineHeight="1.4"
25
- flex={isLeft ? '55%' : ''}
35
+ flex={isLeft ? `${100 - leftFlexPercent}%` : ''}
26
36
  >
27
37
  {value}
28
38
  </Text>
@@ -0,0 +1,6 @@
1
+ import { ProductRadioCardContentI } from '@/interfaces'
2
+
3
+ export interface HomeItemListI {
4
+ items: ProductRadioCardContentI[]
5
+ onChange?: (id: string) => void
6
+ }
@@ -0,0 +1,6 @@
1
+ export interface ProductRadioCardContentI {
2
+ id: string
3
+ name?: string
4
+ brand?: string
5
+ model?: string
6
+ }
@@ -1 +1,3 @@
1
1
  export * from './ViewingHomeItemPanel.interface'
2
+ export * from './ProductRadioCardContent.interface'
3
+ export * from './HomeItemList.interface'
@@ -1,9 +1,12 @@
1
- interface DetailRowI {
1
+ export interface DetailRowI {
2
2
  label?: string
3
3
  value?: string | number | Date
4
4
  }
5
5
 
6
6
  export interface DetailsColumnI {
7
7
  align?: 'left' | 'right'
8
- details: DetailRowI[]
8
+ color?: string
9
+ details?: DetailRowI[]
10
+ fontSize?: string
11
+ leftFlexPercent?: number
9
12
  }
@@ -0,0 +1,40 @@
1
+ import { Meta } from '@storybook/react'
2
+ import { action } from '@storybook/addon-actions'
3
+ import { DrawerContent } from '@chakra-ui/react'
4
+ import { RightPanel, HomeItemList } from '@/components'
5
+ import { HomeItemListI } from '@/interfaces'
6
+
7
+ export default {
8
+ title: 'Components/HomeItems',
9
+ component: HomeItemList,
10
+ args: {
11
+ onChange: action('onChange'),
12
+ items: [
13
+ {
14
+ id: '1',
15
+ name: 'Item 1',
16
+ brand: 'Brand A',
17
+ model: 'Model X',
18
+ },
19
+ {
20
+ id: '2',
21
+ name: 'Item 2',
22
+ brand: 'Brand B',
23
+ model: 'Model Y',
24
+ },
25
+ ],
26
+ },
27
+ decorators: [
28
+ (Story) => (
29
+ <RightPanel isOpen onClose={action('onClose')}>
30
+ <DrawerContent bg="lightBlue.1" p="base">
31
+ <Story />
32
+ </DrawerContent>
33
+ </RightPanel>
34
+ ),
35
+ ],
36
+ } as Meta<HomeItemListI>
37
+
38
+ export const HomeItemListComponent = (args: HomeItemListI) => (
39
+ <HomeItemList {...args} />
40
+ )