@pareto-engineering/design-system 0.0.1-alpha.67 → 0.0.1-alpha.70

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 (94) hide show
  1. package/config/global-setup.js +3 -0
  2. package/dist/cjs/a/Timestamp/Timestamp.js +139 -0
  3. package/dist/cjs/a/{RatingsInput/common/Rating → Timestamp}/index.js +3 -3
  4. package/dist/cjs/a/Timestamp/styles.scss +7 -0
  5. package/dist/cjs/a/index.js +9 -1
  6. package/dist/cjs/f/FormInput/FormInput.js +109 -0
  7. package/dist/cjs/{a/RatingsInput → f/FormInput}/index.js +3 -3
  8. package/dist/cjs/f/common/Label/Label.js +10 -3
  9. package/dist/cjs/f/common/Label/styles.scss +3 -3
  10. package/dist/cjs/f/fields/CheckboxInput/CheckboxInput.js +3 -1
  11. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +32 -11
  12. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +10 -3
  13. package/dist/cjs/f/fields/ChoicesInput/styles.scss +32 -29
  14. package/dist/cjs/f/fields/RadioInput/RadioInput.js +3 -1
  15. package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +3 -1
  16. package/dist/cjs/f/fields/SelectInput/SelectInput.js +15 -5
  17. package/dist/cjs/{a/RatingsInput/common/Rating/Rating.js → f/fields/TaskRecommendationInput/TaskRecommendationInput.js} +57 -46
  18. package/dist/cjs/f/fields/TaskRecommendationInput/index.js +15 -0
  19. package/{src/ui/f/fields/TaskRecommendation → dist/cjs/f/fields/TaskRecommendationInput}/styles.scss +1 -1
  20. package/dist/cjs/f/fields/TextInput/TextInput.js +15 -5
  21. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +151 -0
  22. package/dist/cjs/f/fields/TextareaInput/index.js +15 -0
  23. package/{src/ui/f/fields/TextArea → dist/cjs/f/fields/TextareaInput}/styles.scss +1 -1
  24. package/dist/cjs/f/fields/index.js +6 -6
  25. package/dist/cjs/f/index.js +14 -1
  26. package/dist/es/a/Timestamp/Timestamp.js +122 -0
  27. package/dist/es/a/Timestamp/index.js +2 -0
  28. package/dist/es/a/Timestamp/styles.scss +7 -0
  29. package/dist/es/a/index.js +2 -1
  30. package/dist/es/f/FormInput/FormInput.js +84 -0
  31. package/dist/es/f/FormInput/index.js +2 -0
  32. package/dist/es/f/common/Label/Label.js +10 -3
  33. package/dist/es/f/common/Label/styles.scss +3 -3
  34. package/dist/es/f/fields/CheckboxInput/CheckboxInput.js +2 -2
  35. package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +32 -13
  36. package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +10 -3
  37. package/dist/es/f/fields/ChoicesInput/styles.scss +32 -29
  38. package/dist/es/f/fields/RadioInput/RadioInput.js +2 -2
  39. package/dist/es/f/fields/RatingsInput/RatingsInput.js +2 -2
  40. package/dist/es/f/fields/SelectInput/SelectInput.js +14 -6
  41. package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +111 -0
  42. package/dist/es/f/fields/TaskRecommendationInput/index.js +2 -0
  43. package/dist/es/f/fields/TaskRecommendationInput/styles.scss +37 -0
  44. package/dist/es/f/fields/TextInput/TextInput.js +14 -6
  45. package/dist/es/f/fields/TextareaInput/TextareaInput.js +132 -0
  46. package/dist/es/f/fields/TextareaInput/index.js +2 -0
  47. package/dist/es/f/fields/TextareaInput/styles.scss +19 -0
  48. package/dist/es/f/fields/index.js +2 -2
  49. package/dist/es/f/index.js +2 -1
  50. package/jest.config.js +2 -1
  51. package/package.json +1 -1
  52. package/src/__snapshots__/Storyshots.test.js.snap +1204 -383
  53. package/src/stories/a/Timestamp.stories.jsx +102 -0
  54. package/src/stories/f/ChoicesInput.stories.jsx +54 -6
  55. package/src/stories/f/FormInput.stories.jsx +187 -0
  56. package/src/stories/f/SelectInput.stories.jsx +14 -0
  57. package/src/stories/f/{TaskRecommendation.stories.jsx → TaskRecommendationInput.stories.jsx} +4 -4
  58. package/src/stories/f/TextInput.stories.jsx +10 -0
  59. package/src/stories/f/{TextArea.stories.jsx → TextareaInput.stories.jsx} +15 -5
  60. package/src/ui/a/Timestamp/Timestamp.jsx +168 -0
  61. package/src/ui/a/Timestamp/index.js +2 -0
  62. package/src/ui/a/Timestamp/styles.scss +7 -0
  63. package/src/ui/a/index.js +1 -0
  64. package/src/ui/f/FormInput/FormInput.jsx +121 -0
  65. package/src/ui/f/FormInput/index.js +2 -0
  66. package/src/ui/f/common/Label/Label.jsx +10 -2
  67. package/src/ui/f/common/Label/styles.scss +3 -3
  68. package/src/ui/f/fields/CheckboxInput/CheckboxInput.jsx +2 -2
  69. package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +37 -17
  70. package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +6 -0
  71. package/src/ui/f/fields/ChoicesInput/styles.scss +32 -29
  72. package/src/ui/f/fields/RadioInput/RadioInput.jsx +2 -2
  73. package/src/ui/f/fields/RatingsInput/RatingsInput.jsx +2 -2
  74. package/src/ui/f/fields/SelectInput/SelectInput.jsx +9 -4
  75. package/src/ui/f/fields/{TaskRecommendation/TaskRecommendation.jsx → TaskRecommendationInput/TaskRecommendationInput.jsx} +6 -6
  76. package/src/ui/f/fields/TaskRecommendationInput/index.js +2 -0
  77. package/src/ui/f/fields/TaskRecommendationInput/styles.scss +37 -0
  78. package/src/ui/f/fields/TextInput/TextInput.jsx +10 -3
  79. package/src/ui/f/fields/{TextArea/TextArea.jsx → TextareaInput/TextareaInput.jsx} +13 -6
  80. package/src/ui/f/fields/TextareaInput/index.js +2 -0
  81. package/src/ui/f/fields/TextareaInput/styles.scss +19 -0
  82. package/src/ui/f/fields/index.js +2 -2
  83. package/src/ui/f/index.js +1 -0
  84. package/dist/cjs/a/RatingsInput/RatingsInput.js +0 -88
  85. package/dist/cjs/a/RatingsInput/common/index.js +0 -13
  86. package/dist/cjs/a/RatingsInput/styles.scss +0 -35
  87. package/dist/es/a/RatingsInput/RatingsInput.js +0 -72
  88. package/dist/es/a/RatingsInput/common/Rating/Rating.js +0 -102
  89. package/dist/es/a/RatingsInput/common/Rating/index.js +0 -2
  90. package/dist/es/a/RatingsInput/common/index.js +0 -1
  91. package/dist/es/a/RatingsInput/index.js +0 -2
  92. package/dist/es/a/RatingsInput/styles.scss +0 -35
  93. package/src/ui/f/fields/TaskRecommendation/index.js +0 -2
  94. package/src/ui/f/fields/TextArea/index.js +0 -2
@@ -0,0 +1,102 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { Timestamp } from 'ui'
5
+
6
+ import { subDays } from 'date-fns'
7
+
8
+ export default {
9
+ title :'a/Timestamp',
10
+ component :Timestamp,
11
+ subcomponents:{
12
+ // Item:Timestamp.Item
13
+ },
14
+ decorators:[
15
+ // storyfn => <div className="">{ storyfn() }</div>,
16
+ ],
17
+ argTypes:{
18
+ backgroundColor:{ control: 'color' },
19
+ },
20
+ }
21
+
22
+ const date = Date.UTC(2021, 9, 15)
23
+ // const timezoneCorrectedDate = addMinutes(date, date.getTimezoneOffset())
24
+
25
+ export const Base = () => (
26
+ <>
27
+ <Timestamp time={date} />
28
+ </>
29
+ )
30
+
31
+ export const DateFormat = () => (
32
+ <Timestamp
33
+ time={date}
34
+ enabledFormats={['date']}
35
+ dateFormat={'yyyy-MM-dd\' at \'HH:mm'}
36
+ />
37
+ )
38
+
39
+ export const DistanceFormat = () => (
40
+ <Timestamp
41
+ time={subDays(date, 3)}
42
+ enabledFormats={['distance', 'date']}
43
+ />
44
+ )
45
+
46
+ export const RelativeFormat = () => (
47
+ <>
48
+ Click to see relative format.
49
+ Relative format has not been enabled by default because of chromatic snapshots.
50
+ <Timestamp
51
+ time={subDays(date, 5)}
52
+ enabledFormats={['date', 'relative']}
53
+ />
54
+ </>
55
+ )
56
+
57
+ export const Prefix = () => (
58
+ <Timestamp
59
+ time={date}
60
+ prefix={(
61
+ <strong>
62
+ Updated :
63
+ </strong>
64
+ )}
65
+ />
66
+ )
67
+
68
+ // export const DistanceFormatMaxDays = () => (
69
+ // <>
70
+ // This should appear as distance
71
+ // <Timestamp
72
+ // time={subDays(Date.now(), 3)}
73
+ // enabledFormats={['distance', 'date']}
74
+ // distanceMaxDays={4}
75
+ // />
76
+ // <br />
77
+
78
+ // But this should appear as date
79
+ // <Timestamp
80
+ // time={subDays(Date.now(), 5)}
81
+ // enabledFormats={['distance', 'date']}
82
+ // distanceMaxDays={4}
83
+ // />
84
+ // </>
85
+ // )
86
+
87
+ // export const RelativeFormatMaxDays = () => (
88
+ // <>
89
+ // This should appear as distance
90
+ // <Timestamp
91
+ // time={subDays(Date.now(), 3)}
92
+ // enabledFormats={['relative', 'date']}
93
+ // relativeMaxDays={4}
94
+ // />
95
+ // But this should appear as date
96
+ // <Timestamp
97
+ // time={subDays(Date.now(), 5)}
98
+ // enabledFormats={['relative', 'date']}
99
+ // relativeMaxDays={4}
100
+ // />
101
+ // </>
102
+ // )
@@ -27,7 +27,7 @@ export default {
27
27
  }
28
28
 
29
29
  export const Base = () => {
30
- const choicesMap = [
30
+ const optionsMap = [
31
31
  {
32
32
  value:'red',
33
33
  label:'Color Red',
@@ -45,14 +45,14 @@ export const Base = () => {
45
45
  return (
46
46
 
47
47
  <>
48
- <ChoicesInput id="colors" choices={choicesMap} name="color" />
48
+ <ChoicesInput id="colors" options={optionsMap} name="color" />
49
49
  <FormDebugger />
50
50
  </>
51
51
  )
52
52
  }
53
53
 
54
54
  export const Multiple = () => {
55
- const choicesMap = [
55
+ const optionsMap = [
56
56
  {
57
57
  value:'red',
58
58
  label:'Color Red',
@@ -69,14 +69,14 @@ export const Multiple = () => {
69
69
 
70
70
  return (
71
71
  <>
72
- <ChoicesInput id="colors" choices={choicesMap} name="color" multiple />
72
+ <ChoicesInput id="colors" options={optionsMap} name="color" multiple />
73
73
  <FormDebugger />
74
74
  </>
75
75
  )
76
76
  }
77
77
 
78
78
  export const MultipleWithGrid = () => {
79
- const choicesMap = [
79
+ const optionsMap = [
80
80
  {
81
81
  value:'red',
82
82
  label:'Color Red',
@@ -113,7 +113,55 @@ export const MultipleWithGrid = () => {
113
113
 
114
114
  return (
115
115
  <>
116
- <ChoicesInput id="colors" choices={choicesMap} name="color" multiple gridColumnsDesktop={2} />
116
+ <ChoicesInput id="colors" options={optionsMap} name="color" multiple gridColumnsDesktop={2} />
117
+ <FormDebugger />
118
+ </>
119
+ )
120
+ }
121
+
122
+ export const ChoicesWithLabel = () => {
123
+ const optionsMap = [
124
+ {
125
+ value:'triangle',
126
+ label:'Triangle',
127
+ },
128
+ {
129
+ value:'square',
130
+ label:'Square',
131
+ },
132
+ {
133
+ value:'rectangle',
134
+ label:'Rectangle',
135
+ },
136
+ ]
137
+
138
+ return (
139
+ <>
140
+ <ChoicesInput id="shapes" options={optionsMap} name="shape" label="Geometric Shapes" />
141
+ <FormDebugger />
142
+ </>
143
+ )
144
+ }
145
+
146
+ export const DisabledChoicesInput = () => {
147
+ const optionsMap = [
148
+ {
149
+ value:'triangle',
150
+ label:'Triangle',
151
+ },
152
+ {
153
+ value:'square',
154
+ label:'Square',
155
+ },
156
+ {
157
+ value:'rectangle',
158
+ label:'Rectangle',
159
+ },
160
+ ]
161
+
162
+ return (
163
+ <>
164
+ <ChoicesInput id="shapes" options={optionsMap} name="shape" label="Geometric Shapes" disabled />
117
165
  <FormDebugger />
118
166
  </>
119
167
  )
@@ -0,0 +1,187 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+ import { Formik, Form } from 'formik'
4
+
5
+ import {
6
+ FormInput,
7
+ TextInput,
8
+ FormDebugger,
9
+ } from 'ui'
10
+
11
+ export default {
12
+ title :'f/FormInput',
13
+ component :FormInput,
14
+ subcomponents:{
15
+ // Item:FormInput.Item
16
+ },
17
+ decorators:[
18
+ (storyfn) => (
19
+ <Formik
20
+ initialValues={{ firstName: 'Test' }}
21
+ >
22
+ <Form>
23
+
24
+ { storyfn() }
25
+ </Form>
26
+ </Formik>
27
+ ),
28
+ ],
29
+ argTypes:{
30
+ backgroundColor:{ control: 'color' },
31
+ },
32
+ }
33
+
34
+ export const Base = () => {
35
+ const inputMap = [
36
+ {
37
+ type :'text',
38
+ name :'firstName',
39
+ label:"What's your first name ?",
40
+ },
41
+ {
42
+ type :'text',
43
+ name :'lastName',
44
+ label:"What's your last name ?",
45
+ },
46
+ {
47
+ type :'textarea',
48
+ name :'description',
49
+ label:'Describe yourself in a few sentences',
50
+ },
51
+ {
52
+ type :'choices',
53
+ name :'colors',
54
+ label :'What are your favourite colors ?',
55
+ options:[
56
+ {
57
+ value:'red',
58
+ label:'Color Red',
59
+ },
60
+ {
61
+ value:'blue',
62
+ label:'Color Blue',
63
+ },
64
+ {
65
+ value:'green',
66
+ label:'Color Green',
67
+ },
68
+ ],
69
+ },
70
+ {
71
+ type :'select',
72
+ name :'food',
73
+ label :'What do you want for dinner ?',
74
+ options:[
75
+ {
76
+ value:'italian',
77
+ label:'A nice pizza',
78
+ },
79
+ {
80
+ value:'turkish',
81
+ label:'A delicious kebab',
82
+ },
83
+ {
84
+ value:'french',
85
+ label:'A three course delicate french meal',
86
+ },
87
+ ],
88
+ },
89
+
90
+ ]
91
+ return (
92
+ <>
93
+ {
94
+ inputMap.map((input) => <FormInput {...input} key={input.name} />)
95
+ }
96
+ <FormDebugger />
97
+
98
+ </>
99
+ )
100
+ }
101
+
102
+ export const ExtensibleFormInput = () => {
103
+ const ExtendedTextInput = (props) => (
104
+ <TextInput
105
+ {...props}
106
+ name="extended"
107
+ label="Extended type input"
108
+ />
109
+ )
110
+
111
+ const extraTypes = { extendedTypeInput: ExtendedTextInput }
112
+
113
+ return (
114
+ <>
115
+ <FormInput extraTypes={extraTypes} type="extendedTypeInput" />
116
+ <FormDebugger />
117
+ </>
118
+ )
119
+ }
120
+
121
+ export const DisabledFormInput = () => {
122
+ const inputMap = [
123
+ {
124
+ type :'text',
125
+ name :'firstName',
126
+ label:"What's your first name ?",
127
+ },
128
+ {
129
+ type :'text',
130
+ name :'lastName',
131
+ label:"What's your last name ?",
132
+ },
133
+ {
134
+ type :'textarea',
135
+ name :'description',
136
+ label:'Describe yourself in a few sentences',
137
+ },
138
+ {
139
+ type :'choices',
140
+ name :'colors',
141
+ label :'What are your favourite colors ?',
142
+ options:[
143
+ {
144
+ value:'red',
145
+ label:'Color Red',
146
+ },
147
+ {
148
+ value:'blue',
149
+ label:'Color Blue',
150
+ },
151
+ {
152
+ value:'green',
153
+ label:'Color Green',
154
+ },
155
+ ],
156
+ },
157
+ {
158
+ type :'select',
159
+ name :'food',
160
+ label :'What do you want for dinner ?',
161
+ options:[
162
+ {
163
+ value:'italian',
164
+ label:'A nice pizza',
165
+ },
166
+ {
167
+ value:'turkish',
168
+ label:'A delicious kebab',
169
+ },
170
+ {
171
+ value:'french',
172
+ label:'A three course delicate french meal',
173
+ },
174
+ ],
175
+ },
176
+
177
+ ]
178
+ return (
179
+ <>
180
+ {
181
+ inputMap.map((input) => <FormInput disabled {...input} key={input.name} />)
182
+ }
183
+ <FormDebugger />
184
+
185
+ </>
186
+ )
187
+ }
@@ -65,3 +65,17 @@ export const StringAndObjects = () => (
65
65
  <FormDebugger />
66
66
  </>
67
67
  )
68
+ export const DisabledSelectInput = () => (
69
+ <>
70
+ <SelectInput
71
+ name="workType"
72
+ label="Work Type"
73
+ options={['Work', 'Managing', 'Training',
74
+ { value: '20th Aug 2020 to 19th Sept, 2020', label: '20th Aug 2020 to 19th Sept, 2020' },
75
+ { value: '20th Sept 2020 to 19th Oct, 2020', label: '20th Sept 2020 to 19th Oct, 2020' },
76
+ ]}
77
+ disabled
78
+ />
79
+ <FormDebugger />
80
+ </>
81
+ )
@@ -1,11 +1,11 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  import * as React from 'react'
3
3
  import { Formik, Form } from 'formik'
4
- import { TaskRecommendation } from 'ui'
4
+ import { TaskRecommendationInput } from 'ui'
5
5
 
6
6
  export default {
7
- title :'f/fields/TaskRecommendation',
8
- component :TaskRecommendation,
7
+ title :'f/fields/TaskRecommendationInput',
8
+ component :TaskRecommendationInput,
9
9
  subcomponents:{
10
10
  // Item:TaskRecommendation.Item
11
11
  },
@@ -27,7 +27,7 @@ export default {
27
27
 
28
28
  export const Base = () => (
29
29
  <div className="y-background b-y v2 p-v" style={{ height: '100%' }}>
30
- <TaskRecommendation
30
+ <TaskRecommendationInput
31
31
  name="taskRecommendations"
32
32
  value="businessTypes"
33
33
  oneLiner="Build a list of contacts at businesses based on my criteria for potential customers"
@@ -51,3 +51,13 @@ export const Base = () => {
51
51
  </>
52
52
  )
53
53
  }
54
+
55
+ export const DisabledTextInput = () => (
56
+ <div className="y-background b-y u2 pb-u">
57
+ <TextInput
58
+ name="firstName"
59
+ label="What's your first name ?"
60
+ disabled
61
+ />
62
+ </div>
63
+ )
@@ -3,13 +3,13 @@ import * as React from 'react'
3
3
 
4
4
  import { Formik, Form } from 'formik'
5
5
 
6
- import { TextArea, FormDebugger } from 'ui'
6
+ import { TextareaInput, FormDebugger } from 'ui'
7
7
 
8
8
  export default {
9
- title :'f/fields/TextArea',
10
- component :TextArea,
9
+ title :'f/fields/TextareaInput',
10
+ component :TextareaInput,
11
11
  subcomponents:{
12
- // Item:TextArea.Item
12
+ // Item:TextareaInput.Item
13
13
  },
14
14
  decorators:[
15
15
  (storyfn) => (
@@ -30,10 +30,20 @@ export default {
30
30
 
31
31
  export const Base = () => (
32
32
  <div className="y-background b-y">
33
- <TextArea
33
+ <TextareaInput
34
34
  name="feedBack"
35
35
  label="What can we improve on?"
36
36
  />
37
37
  <FormDebugger />
38
38
  </div>
39
39
  )
40
+ export const DisabledTextareaInput = () => (
41
+ <div className="y-background b-y">
42
+ <TextareaInput
43
+ name="feedBack"
44
+ label="What can we improve on?"
45
+ disabled
46
+ />
47
+ <FormDebugger />
48
+ </div>
49
+ )
@@ -0,0 +1,168 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import {
5
+ useLayoutEffect, useMemo, useCallback, useState,
6
+ } from 'react'
7
+
8
+ import PropTypes from 'prop-types'
9
+
10
+ import styleNames from '@pareto-engineering/bem'
11
+
12
+ import {
13
+ format, differenceInDays, formatDistance, formatRelative,
14
+ } from 'date-fns'
15
+
16
+ // Local Definitions
17
+
18
+ const baseClassName = styleNames.base
19
+
20
+ const componentClassName = 'timestamp'
21
+
22
+ /**
23
+ * This is the component description.
24
+ */
25
+ const Timestamp = ({
26
+ id,
27
+ className:userClassName,
28
+ style,
29
+ time,
30
+ prefix,
31
+ enabledFormats,
32
+ distanceMaxDays,
33
+ relativeMaxDays,
34
+ dateFormat,
35
+ locale,
36
+ // ...otherProps
37
+ as:Element,
38
+ }) => {
39
+ useLayoutEffect(() => {
40
+ import('./styles.scss')
41
+ }, [])
42
+
43
+ const [currentDisplay, setCurrentDisplay] = useState(enabledFormats[0])
44
+
45
+ const formatMap = useMemo(() => ({
46
+ unix :(unix) => Number(unix),
47
+ date :(unix) => format(new Date(unix), dateFormat),
48
+ distance:(unix) => ((!distanceMaxDays
49
+ || (differenceInDays(Date.now(), new Date(unix)) < distanceMaxDays))
50
+ ? formatDistance(new Date(unix), new Date(), { addSuffix: true, locale })
51
+ : format(new Date(unix), dateFormat)),
52
+ relative:(unix) => ((!relativeMaxDays
53
+ || (differenceInDays(Date.now(), new Date(unix)) < relativeMaxDays))
54
+ ? formatRelative(new Date(unix), new Date(), { locale })
55
+ : format(new Date(unix), dateFormat)),
56
+ }), [])
57
+
58
+ const onClick = useCallback((e) => {
59
+ e.persist()
60
+ // eslint-disable-next-line no-shadow
61
+ const currentIndex = enabledFormats.findIndex((e) => e === currentDisplay)
62
+ const nextIndex = (currentIndex + 1) % enabledFormats.length
63
+ setCurrentDisplay(enabledFormats[nextIndex])
64
+ }, [currentDisplay])
65
+
66
+ if (!Number(time)) return null
67
+
68
+ return (
69
+ <Element
70
+ id={id}
71
+ className={[
72
+
73
+ baseClassName,
74
+
75
+ componentClassName,
76
+ userClassName,
77
+ ]
78
+ .filter((e) => e)
79
+ .join(' ')}
80
+ style={style}
81
+ // {...otherProps}
82
+ onClick={(enabledFormats.length > 1) ? onClick : undefined}
83
+ >
84
+ { prefix && prefix }
85
+ { prefix && ' ' }
86
+ { formatMap[currentDisplay](Number(time)) }
87
+ </Element>
88
+ )
89
+ }
90
+
91
+ Timestamp.propTypes = {
92
+ /**
93
+ * The HTML id for this element
94
+ */
95
+ id:PropTypes.string,
96
+
97
+ /**
98
+ * The HTML class names for this element
99
+ */
100
+ className:PropTypes.string,
101
+
102
+ /**
103
+ * The React-written, css properties for this element.
104
+ */
105
+ style:PropTypes.objectOf(PropTypes.string),
106
+
107
+ /**
108
+ * The children JSX
109
+ */
110
+ prefix:PropTypes.node,
111
+
112
+ /**
113
+ * Which html tag to use
114
+ */
115
+ as:PropTypes.oneOfType([
116
+ PropTypes.string,
117
+ PropTypes.object,
118
+ ]),
119
+
120
+ /**
121
+ * Formats
122
+ */
123
+ enabledFormats:PropTypes.arrayOf(
124
+ PropTypes.oneOf([
125
+ 'unix',
126
+ 'date',
127
+ 'distance',
128
+ 'relative',
129
+ ]),
130
+ ),
131
+
132
+ /**
133
+ * How many days to display distance before reverting to unix display
134
+ */
135
+ distanceMaxDays:PropTypes.number,
136
+
137
+ /**
138
+ * How many days to display distance before reverting to unix display
139
+ */
140
+ relativeMaxDays:PropTypes.number,
141
+
142
+ /**
143
+ * Unix Format Read https://date-fns.org/v2.16.1/docs/format for options
144
+ */
145
+ dateFormat:PropTypes.string,
146
+
147
+ /**
148
+ * The time to display
149
+ */
150
+ time:PropTypes.oneOfType([
151
+ PropTypes.object,
152
+ PropTypes.number,
153
+ ]).isRequired,
154
+
155
+ /**
156
+ * A Date-DNS locale object. Will default to english.
157
+ */
158
+ locale:PropTypes.instanceOf(Object),
159
+ }
160
+
161
+ Timestamp.defaultProps = {
162
+ // someProp:false
163
+ as :'p',
164
+ dateFormat :'yyyy-MM-dd\'T\'HH:mm:ss.SSSxxx',
165
+ enabledFormats:['unix', 'date'],
166
+ }
167
+
168
+ export default Timestamp
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as Timestamp } from './Timestamp'
@@ -0,0 +1,7 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ // .#{bem.$base}.timestamp{
6
+
7
+ // }
package/src/ui/a/index.js CHANGED
@@ -22,3 +22,4 @@ export { CustomerStat } from './CustomerStat'
22
22
  export { Quote } from './Quote'
23
23
  export { ContentCard } from './ContentCard'
24
24
  export { DotInfo } from './DotInfo'
25
+ export { Timestamp } from './Timestamp'