@ilo-org/react 0.8.4 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @ilo-org/react
2
2
 
3
+ ## 0.8.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ee517d0f2]
8
+ - Updated dependencies [71002bcde]
9
+ - Updated dependencies [703bc66a6]
10
+ - Updated dependencies [ad52c6442]
11
+ - Updated dependencies [9be1cd23e]
12
+ - @ilo-org/styles@0.10.2
13
+ - @ilo-org/themes@0.6.0
14
+
15
+ ## 0.8.5
16
+
17
+ ### Patch Changes
18
+
19
+ - 39ff32a91: Fix appearance of Radio buttons in Firefox
20
+ - bab87cfac: Add min, max and step props to NumberPicker
21
+ - c964d78cc: Adds an `accept` property to the FileUpload component so that it's possible to limit the kinds of files users can upload by file extension.
22
+ - Updated dependencies [c3b0e6def]
23
+ - Updated dependencies [39ff32a91]
24
+ - Updated dependencies [0488bc66e]
25
+ - Updated dependencies [c86fa4f33]
26
+ - @ilo-org/styles@0.10.1
27
+ - @ilo-org/themes@0.5.1
28
+
3
29
  ## 0.8.4
4
30
 
5
31
  ### Patch Changes
@@ -20,7 +20,7 @@ function formatBytes(bytes, decimals = 2) {
20
20
  const i = Math.floor(Math.log(bytes) / Math.log(k));
21
21
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
22
22
  }
23
- const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, multiple, name, placeholder, required, }, ref) => {
23
+ const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, multiple, name, placeholder, required, accept, }, ref) => {
24
24
  const { prefix } = hooks_useGlobalSettings();
25
25
  const formControlCtx = components_FormControl_FormControl.useFormControl();
26
26
  const { ariaDescribedBy } = formControlCtx;
@@ -38,7 +38,7 @@ const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false,
38
38
  }
39
39
  };
40
40
  const inputId = id ? id : name;
41
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", Object.assign({ className: fileUploadClasses }, { children: jsxRuntime.jsxs("label", Object.assign({ className: inputClass }, { children: [placeholder, jsxRuntime.jsx("input", { ref: ref, id: inputId, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, multiple: multiple, placeholder: placeholder, required: required, type: "file", "data-label": placeholder, "aria-describedby": ariaDescribedBy })] })) })), uploadfiles && uploadfiles.length > 0 && (jsxRuntime.jsx("ul", Object.assign({ className: `${baseClass}--list` }, { children: [...uploadfiles].map((file, i) => (jsxRuntime.jsx("li", Object.assign({ className: `${baseClass}--list-item` }, { children: `${file.name} (${formatBytes(file.size)})` }), `${baseClass}--list-item-${i}`))) })))] }));
41
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", Object.assign({ className: fileUploadClasses }, { children: jsxRuntime.jsxs("label", Object.assign({ className: inputClass }, { children: [placeholder, jsxRuntime.jsx("input", { ref: ref, id: inputId, name: name, accept: accept, onChange: handleChange, onBlur: onBlur, disabled: disabled, multiple: multiple, placeholder: placeholder, required: required, type: "file", "data-label": placeholder, "aria-describedby": ariaDescribedBy })] })) })), uploadfiles && uploadfiles.length > 0 && (jsxRuntime.jsx("ul", Object.assign({ className: `${baseClass}--list` }, { children: [...uploadfiles].map((file, i) => (jsxRuntime.jsx("li", Object.assign({ className: `${baseClass}--list-item` }, { children: `${file.name} (${formatBytes(file.size)})` }), `${baseClass}--list-item-${i}`))) })))] }));
42
42
  });
43
43
  const LabelledFileUpload = require$$0.forwardRef((props, ref) => {
44
44
  const { style, inputStyle, className } = props, rest = tslib.__rest(props, ["style", "inputStyle", "className"]);
@@ -11,7 +11,7 @@ require('nanoid');
11
11
  require('../Tooltip/Tooltip.js');
12
12
  require('react-dom');
13
13
 
14
- const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, }, ref) => {
14
+ const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, max, min, step, }, ref) => {
15
15
  const { prefix } = hooks_useGlobalSettings();
16
16
  const formControlCtx = components_FormControl_FormControl.useFormControl();
17
17
  const { ariaDescribedBy } = formControlCtx;
@@ -26,7 +26,7 @@ const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false
26
26
  onChange(e);
27
27
  }
28
28
  };
29
- return (jsxRuntime.jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: "number", className: numberPickerClasses, pattern: "[0-9]*", inputMode: "numeric", "aria-describedby": ariaDescribedBy }));
29
+ return (jsxRuntime.jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: "number", className: numberPickerClasses, pattern: "[0-9]*", inputMode: "numeric", "aria-describedby": ariaDescribedBy, max: max, min: min, step: step }));
30
30
  });
31
31
  const LabelledNumberPicker = require$$0.forwardRef((props, ref) => {
32
32
  const { style, inputStyle, className } = props, rest = tslib.__rest(props, ["style", "inputStyle", "className"]);
@@ -31,11 +31,12 @@ const Radio = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error
31
31
  }
32
32
  };
33
33
  const baseClass = `${prefix}--radio`;
34
+ const controlClass = `${baseClass}--control`;
34
35
  const errorClass = `${baseClass}__error`;
35
36
  const RadioClasses = classNames(baseClass, {
36
37
  [errorClass]: error,
37
38
  });
38
- return (jsxRuntime.jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, required: required, type: "radio", className: RadioClasses, defaultChecked: defaultChecked, "aria-describedby": ariaDescribedBy, checked: checked, value: value }));
39
+ return (jsxRuntime.jsxs("div", Object.assign({ className: RadioClasses }, { children: [jsxRuntime.jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, required: required, type: "radio", defaultChecked: defaultChecked, "aria-describedby": ariaDescribedBy, checked: checked, value: value }), jsxRuntime.jsx("span", { className: controlClass })] })));
39
40
  });
40
41
  const LabelledRadio = require$$0.forwardRef((props, ref) => {
41
42
  const { style, inputStyle, className, labelPlacement = "end", labelSize = "small" } = props, rest = tslib.__rest(props, ["style", "inputStyle", "className", "labelPlacement", "labelSize"]);
@@ -18,7 +18,7 @@ function formatBytes(bytes, decimals = 2) {
18
18
  const i = Math.floor(Math.log(bytes) / Math.log(k));
19
19
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
20
20
  }
21
- const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, multiple, name, placeholder, required, }, ref) => {
21
+ const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, multiple, name, placeholder, required, accept, }, ref) => {
22
22
  const { prefix } = useGlobalSettings();
23
23
  const formControlCtx = useFormControl();
24
24
  const { ariaDescribedBy } = formControlCtx;
@@ -36,7 +36,7 @@ const FileUpload = require$$0.forwardRef(({ onChange, onBlur, disabled = false,
36
36
  }
37
37
  };
38
38
  const inputId = id ? id : name;
39
- return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: fileUploadClasses }, { children: jsxs("label", Object.assign({ className: inputClass }, { children: [placeholder, jsx("input", { ref: ref, id: inputId, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, multiple: multiple, placeholder: placeholder, required: required, type: "file", "data-label": placeholder, "aria-describedby": ariaDescribedBy })] })) })), uploadfiles && uploadfiles.length > 0 && (jsx("ul", Object.assign({ className: `${baseClass}--list` }, { children: [...uploadfiles].map((file, i) => (jsx("li", Object.assign({ className: `${baseClass}--list-item` }, { children: `${file.name} (${formatBytes(file.size)})` }), `${baseClass}--list-item-${i}`))) })))] }));
39
+ return (jsxs(Fragment, { children: [jsx("div", Object.assign({ className: fileUploadClasses }, { children: jsxs("label", Object.assign({ className: inputClass }, { children: [placeholder, jsx("input", { ref: ref, id: inputId, name: name, accept: accept, onChange: handleChange, onBlur: onBlur, disabled: disabled, multiple: multiple, placeholder: placeholder, required: required, type: "file", "data-label": placeholder, "aria-describedby": ariaDescribedBy })] })) })), uploadfiles && uploadfiles.length > 0 && (jsx("ul", Object.assign({ className: `${baseClass}--list` }, { children: [...uploadfiles].map((file, i) => (jsx("li", Object.assign({ className: `${baseClass}--list-item` }, { children: `${file.name} (${formatBytes(file.size)})` }), `${baseClass}--list-item-${i}`))) })))] }));
40
40
  });
41
41
  const LabelledFileUpload = require$$0.forwardRef((props, ref) => {
42
42
  const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
@@ -9,7 +9,7 @@ import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
10
  import 'react-dom';
11
11
 
12
- const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, }, ref) => {
12
+ const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, max, min, step, }, ref) => {
13
13
  const { prefix } = useGlobalSettings();
14
14
  const formControlCtx = useFormControl();
15
15
  const { ariaDescribedBy } = formControlCtx;
@@ -24,7 +24,7 @@ const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false
24
24
  onChange(e);
25
25
  }
26
26
  };
27
- return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: "number", className: numberPickerClasses, pattern: "[0-9]*", inputMode: "numeric", "aria-describedby": ariaDescribedBy }));
27
+ return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, placeholder: placeholder, required: required, type: "number", className: numberPickerClasses, pattern: "[0-9]*", inputMode: "numeric", "aria-describedby": ariaDescribedBy, max: max, min: min, step: step }));
28
28
  });
29
29
  const LabelledNumberPicker = require$$0.forwardRef((props, ref) => {
30
30
  const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
@@ -1,5 +1,5 @@
1
1
  import { __rest } from 'tslib';
2
- import { jsx } from 'react/jsx-runtime';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import require$$0, { useEffect } from 'react';
4
4
  import classNames from 'classnames';
5
5
  import useGlobalSettings from '../../hooks/useGlobalSettings.js';
@@ -29,11 +29,12 @@ const Radio = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error
29
29
  }
30
30
  };
31
31
  const baseClass = `${prefix}--radio`;
32
+ const controlClass = `${baseClass}--control`;
32
33
  const errorClass = `${baseClass}__error`;
33
34
  const RadioClasses = classNames(baseClass, {
34
35
  [errorClass]: error,
35
36
  });
36
- return (jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, required: required, type: "radio", className: RadioClasses, defaultChecked: defaultChecked, "aria-describedby": ariaDescribedBy, checked: checked, value: value }));
37
+ return (jsxs("div", Object.assign({ className: RadioClasses }, { children: [jsx("input", { ref: ref, id: id ? id : name, name: name, onChange: handleChange, onBlur: onBlur, disabled: disabled, required: required, type: "radio", defaultChecked: defaultChecked, "aria-describedby": ariaDescribedBy, checked: checked, value: value }), jsx("span", { className: controlClass })] })));
37
38
  });
38
39
  const LabelledRadio = require$$0.forwardRef((props, ref) => {
39
40
  const { style, inputStyle, className, labelPlacement = "end", labelSize = "small" } = props, rest = __rest(props, ["style", "inputStyle", "className", "labelPlacement", "labelSize"]);
@@ -5,6 +5,10 @@ export interface FileUploadProps extends FormFieldProps<HTMLInputElement> {
5
5
  * The placeholder for the input
6
6
  */
7
7
  placeholder?: string;
8
+ /**
9
+ * The accept attribute for the input
10
+ */
11
+ accept?: string;
8
12
  /**
9
13
  * Can the user upload more than one file?
10
14
  */
@@ -5,5 +5,17 @@ export interface NumberPickerProps extends FormFieldProps<HTMLInputElement> {
5
5
  * The placeholder text when the input is empty.
6
6
  */
7
7
  placeholder?: string;
8
+ /**
9
+ * The minimum value of the input.
10
+ */
11
+ min?: number;
12
+ /**
13
+ * The maximum value of the input.
14
+ * */
15
+ max?: number;
16
+ /**
17
+ * The step value of the input.
18
+ * */
19
+ step?: number;
8
20
  }
9
21
  export type LabelledNumberPickerProps = LabelledFormFieldProps<NumberPickerProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/react",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "React components for the ILO's Design System",
5
5
  "keywords": [
6
6
  "ui_patterns",
@@ -76,8 +76,8 @@
76
76
  "@ilo-org/brand-assets": "0.2.0",
77
77
  "@ilo-org/fonts": "0.1.0",
78
78
  "@ilo-org/icons-react": "0.0.21",
79
- "@ilo-org/styles": "0.10.0",
80
- "@ilo-org/themes": "0.5.0",
79
+ "@ilo-org/styles": "0.10.2",
80
+ "@ilo-org/themes": "0.6.0",
81
81
  "@ilo-org/utils": "0.0.11"
82
82
  },
83
83
  "devDependencies": {
@@ -7,6 +7,11 @@ export interface FileUploadProps extends FormFieldProps<HTMLInputElement> {
7
7
  */
8
8
  placeholder?: string;
9
9
 
10
+ /**
11
+ * The accept attribute for the input
12
+ */
13
+ accept?: string;
14
+
10
15
  /**
11
16
  * Can the user upload more than one file?
12
17
  */
@@ -15,6 +15,7 @@ function formatBytes(bytes: number, decimals = 2) {
15
15
 
16
16
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
17
17
  }
18
+
18
19
  const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(
19
20
  (
20
21
  {
@@ -27,6 +28,7 @@ const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(
27
28
  name,
28
29
  placeholder,
29
30
  required,
31
+ accept,
30
32
  },
31
33
  ref
32
34
  ) => {
@@ -62,6 +64,7 @@ const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(
62
64
  ref={ref}
63
65
  id={inputId}
64
66
  name={name}
67
+ accept={accept}
65
68
  onChange={handleChange}
66
69
  onBlur={onBlur}
67
70
  disabled={disabled}
@@ -5,6 +5,21 @@ export interface NumberPickerProps extends FormFieldProps<HTMLInputElement> {
5
5
  * The placeholder text when the input is empty.
6
6
  */
7
7
  placeholder?: string;
8
+
9
+ /**
10
+ * The minimum value of the input.
11
+ */
12
+ min?: number;
13
+
14
+ /**
15
+ * The maximum value of the input.
16
+ * */
17
+ max?: number;
18
+
19
+ /**
20
+ * The step value of the input.
21
+ * */
22
+ step?: number;
8
23
  }
9
24
 
10
25
  export type LabelledNumberPickerProps =
@@ -18,6 +18,9 @@ const NumberPicker = React.forwardRef<HTMLInputElement, NumberPickerProps>(
18
18
  name,
19
19
  placeholder,
20
20
  required,
21
+ max,
22
+ min,
23
+ step,
21
24
  },
22
25
  ref
23
26
  ) => {
@@ -55,6 +58,9 @@ const NumberPicker = React.forwardRef<HTMLInputElement, NumberPickerProps>(
55
58
  pattern="[0-9]*"
56
59
  inputMode="numeric"
57
60
  aria-describedby={ariaDescribedBy}
61
+ max={max}
62
+ min={min}
63
+ step={step}
58
64
  />
59
65
  );
60
66
  }
@@ -43,6 +43,7 @@ const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
43
43
  };
44
44
 
45
45
  const baseClass = `${prefix}--radio`;
46
+ const controlClass = `${baseClass}--control`;
46
47
  const errorClass = `${baseClass}__error`;
47
48
 
48
49
  const RadioClasses = classNames(baseClass, {
@@ -50,21 +51,23 @@ const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
50
51
  });
51
52
 
52
53
  return (
53
- <input
54
- ref={ref}
55
- id={id ? id : name}
56
- name={name}
57
- onChange={handleChange}
58
- onBlur={onBlur}
59
- disabled={disabled}
60
- required={required}
61
- type="radio"
62
- className={RadioClasses}
63
- defaultChecked={defaultChecked}
64
- aria-describedby={ariaDescribedBy}
65
- checked={checked}
66
- value={value}
67
- />
54
+ <div className={RadioClasses}>
55
+ <input
56
+ ref={ref}
57
+ id={id ? id : name}
58
+ name={name}
59
+ onChange={handleChange}
60
+ onBlur={onBlur}
61
+ disabled={disabled}
62
+ required={required}
63
+ type="radio"
64
+ defaultChecked={defaultChecked}
65
+ aria-describedby={ariaDescribedBy}
66
+ checked={checked}
67
+ value={value}
68
+ />
69
+ <span className={controlClass}></span>
70
+ </div>
68
71
  );
69
72
  }
70
73
  );