@pareto-engineering/design-system 2.0.0-alpha.57 → 2.0.0-alpha.59

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.
@@ -81,6 +81,12 @@ var FormInput = _ref => {
81
81
  }, otherProps));
82
82
  }
83
83
 
84
+ if (type === 'rating') {
85
+ return /*#__PURE__*/React.createElement(_fields.RatingsInput, _extends({
86
+ className: newClassName
87
+ }, otherProps));
88
+ }
89
+
84
90
  if (extraTypes !== null && extraTypes !== void 0 && extraTypes[type]) {
85
91
  var Component = extraTypes[type];
86
92
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -105,7 +111,7 @@ FormInput.propTypes = {
105
111
  /**
106
112
  * The HTML class names for this element
107
113
  */
108
- type: _propTypes.default.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'url', // to be removed
114
+ type: _propTypes.default.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'url', 'rating', // to be removed
109
115
  'extendedTypeInput']),
110
116
 
111
117
  /**
@@ -70,7 +70,7 @@ var ChoicesInput = _ref => {
70
70
  }, options.map(choice => /*#__PURE__*/React.createElement(_common.Choice, _extends({
71
71
  key: choice.value,
72
72
  name: name,
73
- id: "".concat(id, "-").concat(choice.value),
73
+ id: name,
74
74
  multiple: multiple,
75
75
  validate: validate,
76
76
  disabled: disabled
@@ -45,7 +45,8 @@ var TextareaInput = _ref => {
45
45
  description,
46
46
  disabled,
47
47
  placeholder,
48
- autoComplete // ...otherProps
48
+ autoComplete,
49
+ resize // ...otherProps
49
50
 
50
51
  } = _ref;
51
52
  (0, React.useLayoutEffect)(() => {
@@ -68,6 +69,9 @@ var TextareaInput = _ref => {
68
69
  id: textAreaId,
69
70
  className: "textarea"
70
71
  }, field, {
72
+ style: {
73
+ resize
74
+ },
71
75
  placeholder: placeholder,
72
76
  rows: rows,
73
77
  disabled: disabled,
@@ -153,12 +157,19 @@ TextareaInput.propTypes = {
153
157
  /**
154
158
  * The autoComplete value that the browser should watch for the input
155
159
  */
156
- autoComplete: _propTypes.default.string
160
+ autoComplete: _propTypes.default.string,
161
+
162
+ /**
163
+ * Whether to disable or allow only a certain method of resizing the area
164
+ * Textarea docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
165
+ */
166
+ resize: _propTypes.default.string
157
167
  };
158
168
  TextareaInput.defaultProps = {
159
169
  rows: 3,
160
170
  textAreaColor: 'background2',
161
- disabled: false
171
+ disabled: false,
172
+ resize: 'vertical'
162
173
  };
163
174
 
164
175
  var _default = /*#__PURE__*/(0, React.memo)(TextareaInput);
@@ -4,7 +4,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
4
4
  import * as React from 'react';
5
5
  import { memo, useLayoutEffect } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect } from "../fields"; // Local Definitions
7
+ import { TextInput, TextareaInput, ChoicesInput, SelectInput, QueryCombobox, QuerySelect, RatingsInput } from "../fields"; // Local Definitions
8
8
  // const baseClassName = styleNames.base
9
9
 
10
10
  const componentClassName = 'form-input';
@@ -59,6 +59,12 @@ const FormInput = ({
59
59
  }, otherProps));
60
60
  }
61
61
 
62
+ if (type === 'rating') {
63
+ return /*#__PURE__*/React.createElement(RatingsInput, _extends({
64
+ className: newClassName
65
+ }, otherProps));
66
+ }
67
+
62
68
  if (extraTypes !== null && extraTypes !== void 0 && extraTypes[type]) {
63
69
  const Component = extraTypes[type];
64
70
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -83,7 +89,7 @@ FormInput.propTypes = {
83
89
  /**
84
90
  * The HTML class names for this element
85
91
  */
86
- type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'url', // to be removed
92
+ type: PropTypes.oneOf(['text', 'email', 'password', 'number', 'date', 'datetime', 'month', 'tel', 'hidden', 'select', 'choices', 'textarea', 'query-combobox', 'url', 'rating', // to be removed
87
93
  'extendedTypeInput']),
88
94
 
89
95
  /**
@@ -49,7 +49,7 @@ const ChoicesInput = ({
49
49
  }, options.map(choice => /*#__PURE__*/React.createElement(Choice, _extends({
50
50
  key: choice.value,
51
51
  name: name,
52
- id: `${id}-${choice.value}`,
52
+ id: name,
53
53
  multiple: multiple,
54
54
  validate: validate,
55
55
  disabled: disabled
@@ -29,7 +29,8 @@ const TextareaInput = ({
29
29
  description,
30
30
  disabled,
31
31
  placeholder,
32
- autoComplete // ...otherProps
32
+ autoComplete,
33
+ resize // ...otherProps
33
34
 
34
35
  }) => {
35
36
  useLayoutEffect(() => {
@@ -52,6 +53,9 @@ const TextareaInput = ({
52
53
  id: textAreaId,
53
54
  className: "textarea"
54
55
  }, field, {
56
+ style: {
57
+ resize
58
+ },
55
59
  placeholder: placeholder,
56
60
  rows: rows,
57
61
  disabled: disabled,
@@ -137,11 +141,18 @@ TextareaInput.propTypes = {
137
141
  /**
138
142
  * The autoComplete value that the browser should watch for the input
139
143
  */
140
- autoComplete: PropTypes.string
144
+ autoComplete: PropTypes.string,
145
+
146
+ /**
147
+ * Whether to disable or allow only a certain method of resizing the area
148
+ * Textarea docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
149
+ */
150
+ resize: PropTypes.string
141
151
  };
142
152
  TextareaInput.defaultProps = {
143
153
  rows: 3,
144
154
  textAreaColor: 'background2',
145
- disabled: false
155
+ disabled: false,
156
+ resize: 'vertical'
146
157
  };
147
158
  export default /*#__PURE__*/memo(TextareaInput);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "2.0.0-alpha.57",
3
+ "version": "2.0.0-alpha.59",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -2950,7 +2950,7 @@ exports[`Storyshots a/Timestamp Distance Format 1`] = `
2950
2950
  className="base timestamp"
2951
2951
  onClick={[Function]}
2952
2952
  >
2953
- in about 1 month
2953
+ 9 days ago
2954
2954
  </p>
2955
2955
  `;
2956
2956
 
@@ -10587,6 +10587,11 @@ exports[`Storyshots f/FormInput Base 1`] = `
10587
10587
  onBlur={[Function]}
10588
10588
  onChange={[Function]}
10589
10589
  rows={3}
10590
+ style={
10591
+ Object {
10592
+ "resize": "vertical",
10593
+ }
10594
+ }
10590
10595
  />
10591
10596
  </div>
10592
10597
  <div
@@ -10779,6 +10784,11 @@ exports[`Storyshots f/FormInput Disabled Form Input 1`] = `
10779
10784
  onBlur={[Function]}
10780
10785
  onChange={[Function]}
10781
10786
  rows={3}
10787
+ style={
10788
+ Object {
10789
+ "resize": "vertical",
10790
+ }
10791
+ }
10782
10792
  />
10783
10793
  </div>
10784
10794
  <div
@@ -11285,6 +11295,175 @@ exports[`Storyshots f/FormInput With Query Combobox 1`] = `
11285
11295
  </form>
11286
11296
  `;
11287
11297
 
11298
+ exports[`Storyshots f/FormInput With Ratings Input 1`] = `
11299
+ <form
11300
+ action="#"
11301
+ onReset={[Function]}
11302
+ onSubmit={[Function]}
11303
+ >
11304
+ <div
11305
+ className="base text-input form-input y-background2"
11306
+ >
11307
+ <label
11308
+ className="base label v50 mb-v x-main2"
11309
+ htmlFor="firstName"
11310
+ >
11311
+ What's your first name ?
11312
+ </label>
11313
+ <input
11314
+ className="input"
11315
+ disabled={false}
11316
+ id="firstName"
11317
+ name="firstName"
11318
+ onBlur={[Function]}
11319
+ onChange={[Function]}
11320
+ type="text"
11321
+ value="Test"
11322
+ />
11323
+ </div>
11324
+ <div
11325
+ className="base ratings-input form-input"
11326
+ >
11327
+ <label
11328
+ className="base label input-label v50 mb-v x-main2"
11329
+ htmlFor="ratings"
11330
+ >
11331
+ Your Rating
11332
+ </label>
11333
+ <div
11334
+ className="stars"
11335
+ >
11336
+ <div
11337
+ className="base rating x-main1 y-background2"
11338
+ >
11339
+ <label
11340
+ htmlFor="ratings-1"
11341
+ onMouseEnter={[Function]}
11342
+ onMouseLeave={[Function]}
11343
+ >
11344
+ <span
11345
+ className="f-icons c-dark-y"
11346
+ >
11347
+ [
11348
+ </span>
11349
+ </label>
11350
+ <input
11351
+ id="ratings-1"
11352
+ name="ratings"
11353
+ onBlur={[Function]}
11354
+ onChange={[Function]}
11355
+ type="radio"
11356
+ value={1}
11357
+ />
11358
+ </div>
11359
+ <div
11360
+ className="base rating x-main1 y-background2"
11361
+ >
11362
+ <label
11363
+ htmlFor="ratings-2"
11364
+ onMouseEnter={[Function]}
11365
+ onMouseLeave={[Function]}
11366
+ >
11367
+ <span
11368
+ className="f-icons c-dark-y"
11369
+ >
11370
+ [
11371
+ </span>
11372
+ </label>
11373
+ <input
11374
+ id="ratings-2"
11375
+ name="ratings"
11376
+ onBlur={[Function]}
11377
+ onChange={[Function]}
11378
+ type="radio"
11379
+ value={2}
11380
+ />
11381
+ </div>
11382
+ <div
11383
+ className="base rating x-main1 y-background2"
11384
+ >
11385
+ <label
11386
+ htmlFor="ratings-3"
11387
+ onMouseEnter={[Function]}
11388
+ onMouseLeave={[Function]}
11389
+ >
11390
+ <span
11391
+ className="f-icons c-dark-y"
11392
+ >
11393
+ [
11394
+ </span>
11395
+ </label>
11396
+ <input
11397
+ id="ratings-3"
11398
+ name="ratings"
11399
+ onBlur={[Function]}
11400
+ onChange={[Function]}
11401
+ type="radio"
11402
+ value={3}
11403
+ />
11404
+ </div>
11405
+ <div
11406
+ className="base rating x-main1 y-background2"
11407
+ >
11408
+ <label
11409
+ htmlFor="ratings-4"
11410
+ onMouseEnter={[Function]}
11411
+ onMouseLeave={[Function]}
11412
+ >
11413
+ <span
11414
+ className="f-icons c-dark-y"
11415
+ >
11416
+ [
11417
+ </span>
11418
+ </label>
11419
+ <input
11420
+ id="ratings-4"
11421
+ name="ratings"
11422
+ onBlur={[Function]}
11423
+ onChange={[Function]}
11424
+ type="radio"
11425
+ value={4}
11426
+ />
11427
+ </div>
11428
+ <div
11429
+ className="base rating x-main1 y-background2"
11430
+ >
11431
+ <label
11432
+ htmlFor="ratings-5"
11433
+ onMouseEnter={[Function]}
11434
+ onMouseLeave={[Function]}
11435
+ >
11436
+ <span
11437
+ className="f-icons c-dark-y"
11438
+ >
11439
+ [
11440
+ </span>
11441
+ </label>
11442
+ <input
11443
+ id="ratings-5"
11444
+ name="ratings"
11445
+ onBlur={[Function]}
11446
+ onChange={[Function]}
11447
+ type="radio"
11448
+ value={5}
11449
+ />
11450
+ </div>
11451
+ </div>
11452
+ </div>
11453
+ <div
11454
+ className="debugger"
11455
+ >
11456
+ <button
11457
+ className="base button x-main2"
11458
+ onClick={[Function]}
11459
+ type="button"
11460
+ >
11461
+ Open FormDebugger
11462
+ </button>
11463
+ </div>
11464
+ </form>
11465
+ `;
11466
+
11288
11467
  exports[`Storyshots f/common/Description Base 1`] = `
11289
11468
  <form
11290
11469
  action="#"
@@ -13842,6 +14021,55 @@ exports[`Storyshots f/fields/TextareaInput Base 1`] = `
13842
14021
  onBlur={[Function]}
13843
14022
  onChange={[Function]}
13844
14023
  rows={3}
14024
+ style={
14025
+ Object {
14026
+ "resize": "vertical",
14027
+ }
14028
+ }
14029
+ value=""
14030
+ />
14031
+ </div>
14032
+ <div
14033
+ className="debugger"
14034
+ >
14035
+ <button
14036
+ className="base button x-main2"
14037
+ onClick={[Function]}
14038
+ type="button"
14039
+ >
14040
+ Open FormDebugger
14041
+ </button>
14042
+ </div>
14043
+ </form>
14044
+ `;
14045
+
14046
+ exports[`Storyshots f/fields/TextareaInput Disable Resize 1`] = `
14047
+ <form
14048
+ action="#"
14049
+ onReset={[Function]}
14050
+ onSubmit={[Function]}
14051
+ >
14052
+ <div
14053
+ className="base text-area-input y-background2"
14054
+ >
14055
+ <label
14056
+ className="base label v50 mb-v x-main2"
14057
+ htmlFor="feedback"
14058
+ >
14059
+ What can we improve on?
14060
+ </label>
14061
+ <textarea
14062
+ className="textarea"
14063
+ disabled={false}
14064
+ name="feedback"
14065
+ onBlur={[Function]}
14066
+ onChange={[Function]}
14067
+ rows={3}
14068
+ style={
14069
+ Object {
14070
+ "resize": "none",
14071
+ }
14072
+ }
13845
14073
  value=""
13846
14074
  />
13847
14075
  </div>
@@ -13881,6 +14109,55 @@ exports[`Storyshots f/fields/TextareaInput Disabled 1`] = `
13881
14109
  onBlur={[Function]}
13882
14110
  onChange={[Function]}
13883
14111
  rows={3}
14112
+ style={
14113
+ Object {
14114
+ "resize": "vertical",
14115
+ }
14116
+ }
14117
+ value=""
14118
+ />
14119
+ </div>
14120
+ <div
14121
+ className="debugger"
14122
+ >
14123
+ <button
14124
+ className="base button x-main2"
14125
+ onClick={[Function]}
14126
+ type="button"
14127
+ >
14128
+ Open FormDebugger
14129
+ </button>
14130
+ </div>
14131
+ </form>
14132
+ `;
14133
+
14134
+ exports[`Storyshots f/fields/TextareaInput Horizontal Resize 1`] = `
14135
+ <form
14136
+ action="#"
14137
+ onReset={[Function]}
14138
+ onSubmit={[Function]}
14139
+ >
14140
+ <div
14141
+ className="base text-area-input y-background2"
14142
+ >
14143
+ <label
14144
+ className="base label v50 mb-v x-main2"
14145
+ htmlFor="feedback"
14146
+ >
14147
+ What can we improve on?
14148
+ </label>
14149
+ <textarea
14150
+ className="textarea"
14151
+ disabled={false}
14152
+ name="feedback"
14153
+ onBlur={[Function]}
14154
+ onChange={[Function]}
14155
+ rows={3}
14156
+ style={
14157
+ Object {
14158
+ "resize": "horizontal",
14159
+ }
14160
+ }
13884
14161
  value=""
13885
14162
  />
13886
14163
  </div>
@@ -13921,6 +14198,11 @@ exports[`Storyshots f/fields/TextareaInput Placeholder 1`] = `
13921
14198
  onChange={[Function]}
13922
14199
  placeholder="Type your feedback here..."
13923
14200
  rows={3}
14201
+ style={
14202
+ Object {
14203
+ "resize": "vertical",
14204
+ }
14205
+ }
13924
14206
  value=""
13925
14207
  />
13926
14208
  </div>
@@ -13960,6 +14242,55 @@ exports[`Storyshots f/fields/TextareaInput Validation 1`] = `
13960
14242
  onBlur={[Function]}
13961
14243
  onChange={[Function]}
13962
14244
  rows={3}
14245
+ style={
14246
+ Object {
14247
+ "resize": "vertical",
14248
+ }
14249
+ }
14250
+ value=""
14251
+ />
14252
+ </div>
14253
+ <div
14254
+ className="debugger"
14255
+ >
14256
+ <button
14257
+ className="base button x-main2"
14258
+ onClick={[Function]}
14259
+ type="button"
14260
+ >
14261
+ Open FormDebugger
14262
+ </button>
14263
+ </div>
14264
+ </form>
14265
+ `;
14266
+
14267
+ exports[`Storyshots f/fields/TextareaInput Vertical Resize 1`] = `
14268
+ <form
14269
+ action="#"
14270
+ onReset={[Function]}
14271
+ onSubmit={[Function]}
14272
+ >
14273
+ <div
14274
+ className="base text-area-input y-background2"
14275
+ >
14276
+ <label
14277
+ className="base label v50 mb-v x-main2"
14278
+ htmlFor="feedback"
14279
+ >
14280
+ What can we improve on?
14281
+ </label>
14282
+ <textarea
14283
+ className="textarea"
14284
+ disabled={false}
14285
+ name="feedback"
14286
+ onBlur={[Function]}
14287
+ onChange={[Function]}
14288
+ rows={3}
14289
+ style={
14290
+ Object {
14291
+ "resize": "vertical",
14292
+ }
14293
+ }
13963
14294
  value=""
13964
14295
  />
13965
14296
  </div>
@@ -332,6 +332,32 @@ export const WithPrefetchedQuerySelect = () => {
332
332
  )
333
333
  }
334
334
 
335
+ export const WithRatingsInput = () => {
336
+ const inputMap = [
337
+ {
338
+ type :'text',
339
+ name :'firstName',
340
+ label:"What's your first name ?",
341
+ },
342
+ {
343
+ type :'rating',
344
+ ratingCount:5,
345
+ name :'ratings',
346
+ label :'Your Rating',
347
+ },
348
+ ]
349
+
350
+ return (
351
+ <>
352
+ {
353
+ inputMap.map((input) => <FormInput {...input} key={input.name} />)
354
+ }
355
+ <FormDebugger />
356
+
357
+ </>
358
+ )
359
+ }
360
+
335
361
  export const ExtensibleFormInput = () => {
336
362
  const ExtendedTextInput = (props) => (
337
363
  <TextInput
@@ -73,3 +73,21 @@ Disabled.args = {
73
73
  ...Base.args,
74
74
  disabled:true,
75
75
  }
76
+
77
+ export const VerticalResize = Template.bind({})
78
+ VerticalResize.args = {
79
+ ...Base.args,
80
+ resize:'vertical',
81
+ }
82
+
83
+ export const HorizontalResize = Template.bind({})
84
+ HorizontalResize.args = {
85
+ ...Base.args,
86
+ resize:'horizontal',
87
+ }
88
+
89
+ export const DisableResize = Template.bind({})
90
+ DisableResize.args = {
91
+ ...Base.args,
92
+ resize:'none',
93
+ }
@@ -12,6 +12,7 @@ import {
12
12
  SelectInput,
13
13
  QueryCombobox,
14
14
  QuerySelect,
15
+ RatingsInput,
15
16
  } from '../fields'
16
17
 
17
18
  // Local Definitions
@@ -84,6 +85,15 @@ const FormInput = ({
84
85
  />
85
86
  )
86
87
  }
88
+
89
+ if (type === 'rating') {
90
+ return (
91
+ <RatingsInput
92
+ className={newClassName}
93
+ {...otherProps}
94
+ />
95
+ )
96
+ }
87
97
  if (extraTypes?.[type]) {
88
98
  const Component = extraTypes[type]
89
99
  return (
@@ -128,6 +138,7 @@ FormInput.propTypes = {
128
138
  'textarea',
129
139
  'query-combobox',
130
140
  'url',
141
+ 'rating',
131
142
  // to be removed
132
143
  'extendedTypeInput',
133
144
  ]),
@@ -72,7 +72,7 @@ const ChoicesInput = ({
72
72
  <Choice
73
73
  key={choice.value}
74
74
  name={name}
75
- id={`${id}-${choice.value}`}
75
+ id={name}
76
76
  multiple={multiple}
77
77
  validate={validate}
78
78
  disabled={disabled}
@@ -36,6 +36,7 @@ const TextareaInput = ({
36
36
  disabled,
37
37
  placeholder,
38
38
  autoComplete,
39
+ resize,
39
40
  // ...otherProps
40
41
  }) => {
41
42
  useLayoutEffect(() => {
@@ -73,6 +74,7 @@ const TextareaInput = ({
73
74
  id={textAreaId}
74
75
  className="textarea"
75
76
  {...field}
77
+ style={{ resize }}
76
78
  placeholder={placeholder}
77
79
  rows={rows}
78
80
  disabled={disabled}
@@ -160,12 +162,19 @@ TextareaInput.propTypes = {
160
162
  * The autoComplete value that the browser should watch for the input
161
163
  */
162
164
  autoComplete:PropTypes.string,
165
+
166
+ /**
167
+ * Whether to disable or allow only a certain method of resizing the area
168
+ * Textarea docs - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
169
+ */
170
+ resize:PropTypes.string,
163
171
  }
164
172
 
165
173
  TextareaInput.defaultProps = {
166
174
  rows :3,
167
175
  textAreaColor:'background2',
168
176
  disabled :false,
177
+ resize :'vertical',
169
178
  }
170
179
 
171
180
  export default memo(TextareaInput)