@instructure/ui-checkbox 8.17.0 → 8.17.1-snapshot.17

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/LICENSE.md ADDED
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ ---
6
+
7
+ # The MIT License (MIT)
8
+
9
+ Copyright (c) 2015 Instructure, Inc.
10
+
11
+ **Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions.**
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _class2, _temp;
1
+ var _dec, _dec2, _dec3, _class, _class2, _temp;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -30,9 +30,8 @@ import keycode from 'keycode';
30
30
  import { FormFieldMessages } from '@instructure/ui-form-field';
31
31
  import { createChainedFunction } from '@instructure/ui-utils';
32
32
  import { logError as error } from '@instructure/console';
33
- import { uid } from '@instructure/uid';
34
33
  import { isActiveElement } from '@instructure/ui-dom-utils';
35
- import { omitProps } from '@instructure/ui-react-utils';
34
+ import { omitProps, withDeterministicId } from '@instructure/ui-react-utils';
36
35
  import { View } from '@instructure/ui-view';
37
36
  import { testable } from '@instructure/ui-testable';
38
37
  import { withStyle, jsx } from '@instructure/emotion';
@@ -48,7 +47,7 @@ tags: toggle, switch
48
47
  ---
49
48
  @tsProps
50
49
  **/
51
- let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Checkbox extends Component {
50
+ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, null), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Checkbox extends Component {
52
51
  constructor(props) {
53
52
  super(props);
54
53
  this._defaultId = void 0;
@@ -118,7 +117,13 @@ let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(
118
117
  hovered: false,
119
118
  checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : void 0
120
119
  };
121
- this._defaultId = uid('Checkbox');
120
+
121
+ if (typeof props.checked === 'undefined') {
122
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
123
+ this.state.checked = !!props.defaultChecked;
124
+ }
125
+
126
+ this._defaultId = props.deterministicId();
122
127
  }
123
128
 
124
129
  componentDidMount() {
@@ -256,6 +261,6 @@ let Checkbox = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec(
256
261
  indeterminate: false,
257
262
  readOnly: false,
258
263
  labelPlacement: 'end'
259
- }, _temp)) || _class) || _class);
264
+ }, _temp)) || _class) || _class) || _class);
260
265
  export default Checkbox;
261
266
  export { Checkbox, CheckboxFacade, ToggleFacade };
@@ -1,4 +1,4 @@
1
- var _dec, _class, _class2, _temp;
1
+ var _dec, _dec2, _class, _class2, _temp;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -25,8 +25,7 @@ var _dec, _class, _class2, _temp;
25
25
  */
26
26
  import React, { Children, Component } from 'react';
27
27
  import { FormFieldGroup } from '@instructure/ui-form-field';
28
- import { uid } from '@instructure/uid';
29
- import { matchComponentTypes, safeCloneElement, pickProps, omitProps } from '@instructure/ui-react-utils';
28
+ import { matchComponentTypes, safeCloneElement, pickProps, omitProps, withDeterministicId } from '@instructure/ui-react-utils';
30
29
  import { testable } from '@instructure/ui-testable';
31
30
  import { Checkbox } from '../Checkbox';
32
31
  import { propTypes, allowedProps } from './props';
@@ -37,7 +36,7 @@ category: components
37
36
  ---
38
37
  @tsProps
39
38
  **/
40
- let CheckboxGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class CheckboxGroup extends Component {
39
+ let CheckboxGroup = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class CheckboxGroup extends Component {
41
40
  constructor(props) {
42
41
  super(props);
43
42
  this._messagesId = void 0;
@@ -78,7 +77,7 @@ let CheckboxGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class C
78
77
  };
79
78
  }
80
79
 
81
- this._messagesId = uid('CheckboxGroup-messages');
80
+ this._messagesId = props.deterministicId();
82
81
  }
83
82
 
84
83
  get hasMessages() {
@@ -132,6 +131,6 @@ let CheckboxGroup = (_dec = testable(), _dec(_class = (_temp = _class2 = class C
132
131
  size: 'medium',
133
132
  layout: 'stacked',
134
133
  children: null
135
- }, _temp)) || _class);
134
+ }, _temp)) || _class) || _class);
136
135
  export default CheckboxGroup;
137
136
  export { CheckboxGroup };
@@ -32,12 +32,12 @@ var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFun
32
32
 
33
33
  var _console = require("@instructure/console");
34
34
 
35
- var _uid = require("@instructure/uid");
36
-
37
35
  var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
38
36
 
39
37
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
40
38
 
39
+ var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
40
+
41
41
  var _View = require("@instructure/ui-view/lib/View");
42
42
 
43
43
  var _testable = require("@instructure/ui-testable/lib/testable.js");
@@ -52,7 +52,7 @@ var _styles = _interopRequireDefault(require("./styles"));
52
52
 
53
53
  var _props = require("./props");
54
54
 
55
- var _dec, _dec2, _class, _class2, _temp;
55
+ var _dec, _dec2, _dec3, _class, _class2, _temp;
56
56
 
57
57
  /**
58
58
  ---
@@ -61,7 +61,7 @@ tags: toggle, switch
61
61
  ---
62
62
  @tsProps
63
63
  **/
64
- let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class Checkbox extends _react.Component {
64
+ let Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, null), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_temp = _class2 = class Checkbox extends _react.Component {
65
65
  constructor(props) {
66
66
  super(props);
67
67
  this._defaultId = void 0;
@@ -131,7 +131,13 @@ let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (
131
131
  hovered: false,
132
132
  checked: typeof props.checked === 'undefined' ? !!props.defaultChecked : void 0
133
133
  };
134
- this._defaultId = (0, _uid.uid)('Checkbox');
134
+
135
+ if (typeof props.checked === 'undefined') {
136
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
137
+ this.state.checked = !!props.defaultChecked;
138
+ }
139
+
140
+ this._defaultId = props.deterministicId();
135
141
  }
136
142
 
137
143
  componentDidMount() {
@@ -269,7 +275,7 @@ let Checkbox = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (
269
275
  indeterminate: false,
270
276
  readOnly: false,
271
277
  labelPlacement: 'end'
272
- }, _temp)) || _class) || _class);
278
+ }, _temp)) || _class) || _class) || _class);
273
279
  exports.Checkbox = Checkbox;
274
280
  var _default = Checkbox;
275
281
  exports.default = _default;
@@ -11,8 +11,6 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _FormFieldGroup = require("@instructure/ui-form-field/lib/FormFieldGroup");
13
13
 
14
- var _uid = require("@instructure/uid");
15
-
16
14
  var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
17
15
 
18
16
  var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
@@ -21,13 +19,15 @@ var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
21
19
 
22
20
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
23
21
 
22
+ var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
23
+
24
24
  var _testable = require("@instructure/ui-testable/lib/testable.js");
25
25
 
26
26
  var _Checkbox = require("../Checkbox");
27
27
 
28
28
  var _props = require("./props");
29
29
 
30
- var _dec, _class, _class2, _temp;
30
+ var _dec, _dec2, _class, _class2, _temp;
31
31
 
32
32
  /**
33
33
  ---
@@ -35,7 +35,7 @@ category: components
35
35
  ---
36
36
  @tsProps
37
37
  **/
38
- let CheckboxGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _class2 = class CheckboxGroup extends _react.Component {
38
+ let CheckboxGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class CheckboxGroup extends _react.Component {
39
39
  constructor(props) {
40
40
  super(props);
41
41
  this._messagesId = void 0;
@@ -76,7 +76,7 @@ let CheckboxGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _c
76
76
  };
77
77
  }
78
78
 
79
- this._messagesId = (0, _uid.uid)('CheckboxGroup-messages');
79
+ this._messagesId = props.deterministicId();
80
80
  }
81
81
 
82
82
  get hasMessages() {
@@ -130,7 +130,7 @@ let CheckboxGroup = (_dec = (0, _testable.testable)(), _dec(_class = (_temp = _c
130
130
  size: 'medium',
131
131
  layout: 'stacked',
132
132
  children: null
133
- }, _temp)) || _class);
133
+ }, _temp)) || _class) || _class);
134
134
  exports.CheckboxGroup = CheckboxGroup;
135
135
  var _default = CheckboxGroup;
136
136
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-checkbox",
3
- "version": "8.17.0",
3
+ "version": "8.17.1-snapshot.17+8e38d5a2e",
4
4
  "description": " styled HTML input type='checkbox' component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,28 +24,28 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.13.10",
27
- "@instructure/console": "8.17.0",
28
- "@instructure/emotion": "8.17.0",
29
- "@instructure/shared-types": "8.17.0",
30
- "@instructure/ui-dom-utils": "8.17.0",
31
- "@instructure/ui-form-field": "8.17.0",
32
- "@instructure/ui-icons": "8.17.0",
33
- "@instructure/ui-prop-types": "8.17.0",
34
- "@instructure/ui-react-utils": "8.17.0",
35
- "@instructure/ui-svg-images": "8.17.0",
36
- "@instructure/ui-testable": "8.17.0",
37
- "@instructure/ui-utils": "8.17.0",
38
- "@instructure/ui-view": "8.17.0",
39
- "@instructure/uid": "8.17.0",
27
+ "@instructure/console": "8.17.1-snapshot.17+8e38d5a2e",
28
+ "@instructure/emotion": "8.17.1-snapshot.17+8e38d5a2e",
29
+ "@instructure/shared-types": "8.17.1-snapshot.17+8e38d5a2e",
30
+ "@instructure/ui-dom-utils": "8.17.1-snapshot.17+8e38d5a2e",
31
+ "@instructure/ui-form-field": "8.17.1-snapshot.17+8e38d5a2e",
32
+ "@instructure/ui-icons": "8.17.1-snapshot.17+8e38d5a2e",
33
+ "@instructure/ui-prop-types": "8.17.1-snapshot.17+8e38d5a2e",
34
+ "@instructure/ui-react-utils": "8.17.1-snapshot.17+8e38d5a2e",
35
+ "@instructure/ui-svg-images": "8.17.1-snapshot.17+8e38d5a2e",
36
+ "@instructure/ui-testable": "8.17.1-snapshot.17+8e38d5a2e",
37
+ "@instructure/ui-utils": "8.17.1-snapshot.17+8e38d5a2e",
38
+ "@instructure/ui-view": "8.17.1-snapshot.17+8e38d5a2e",
39
+ "@instructure/uid": "8.17.1-snapshot.17+8e38d5a2e",
40
40
  "keycode": "^2",
41
41
  "prop-types": "^15"
42
42
  },
43
43
  "devDependencies": {
44
- "@instructure/ui-babel-preset": "8.17.0",
45
- "@instructure/ui-color-utils": "8.17.0",
46
- "@instructure/ui-test-locator": "8.17.0",
47
- "@instructure/ui-test-utils": "8.17.0",
48
- "@instructure/ui-themes": "8.17.0"
44
+ "@instructure/ui-babel-preset": "8.17.1-snapshot.17+8e38d5a2e",
45
+ "@instructure/ui-color-utils": "8.17.1-snapshot.17+8e38d5a2e",
46
+ "@instructure/ui-test-locator": "8.17.1-snapshot.17+8e38d5a2e",
47
+ "@instructure/ui-test-utils": "8.17.1-snapshot.17+8e38d5a2e",
48
+ "@instructure/ui-themes": "8.17.1-snapshot.17+8e38d5a2e"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": ">=16.8 <=17"
@@ -53,5 +53,6 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "sideEffects": false
56
+ "sideEffects": false,
57
+ "gitHead": "8e38d5a2e11e842eafa2fa270e47a261c6ebb626"
57
58
  }
@@ -29,9 +29,8 @@ import keycode from 'keycode'
29
29
  import { FormFieldMessages } from '@instructure/ui-form-field'
30
30
  import { createChainedFunction } from '@instructure/ui-utils'
31
31
  import { logError as error } from '@instructure/console'
32
- import { uid } from '@instructure/uid'
33
32
  import { isActiveElement } from '@instructure/ui-dom-utils'
34
- import { omitProps } from '@instructure/ui-react-utils'
33
+ import { omitProps, withDeterministicId } from '@instructure/ui-react-utils'
35
34
  import { View } from '@instructure/ui-view'
36
35
  import { testable } from '@instructure/ui-testable'
37
36
 
@@ -58,6 +57,7 @@ tags: toggle, switch
58
57
  @tsProps
59
58
  **/
60
59
 
60
+ @withDeterministicId()
61
61
  @withStyle(generateStyle, null)
62
62
  @testable()
63
63
  class Checkbox extends Component<CheckboxProps, CheckboxState> {
@@ -87,7 +87,12 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
87
87
  : undefined
88
88
  }
89
89
 
90
- this._defaultId = uid('Checkbox')
90
+ if (typeof props.checked === 'undefined') {
91
+ // @ts-expect-error ts-migrate(2339) FIXME: Property 'checked' does not exist on type 'Readonl... Remove this comment to see the full error message
92
+ this.state.checked = !!props.defaultChecked
93
+ }
94
+
95
+ this._defaultId = props.deterministicId!()
91
96
  }
92
97
  private readonly _defaultId: string
93
98
  private _input: HTMLInputElement | null = null
@@ -35,6 +35,7 @@ import type {
35
35
  ToggleFacadeTheme
36
36
  } from '@instructure/shared-types'
37
37
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
38
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
38
39
 
39
40
  type CheckboxOwnProps = {
40
41
  label: React.ReactNode
@@ -86,7 +87,7 @@ type AllowedPropKeys = Readonly<Array<PropKeys>>
86
87
 
87
88
  type CheckboxProps = CheckboxOwnProps &
88
89
  WithStyleProps<CheckboxFacadeTheme | ToggleFacadeTheme, CheckboxStyle> &
89
- OtherHTMLAttributes<CheckboxOwnProps>
90
+ OtherHTMLAttributes<CheckboxOwnProps> & WithDeterministicIdProps
90
91
 
91
92
  type CheckboxStyle = ComponentStyle<'checkbox' | 'input' | 'control'>
92
93
 
@@ -25,12 +25,12 @@
25
25
  import React, { Children, Component } from 'react'
26
26
 
27
27
  import { FormFieldGroup } from '@instructure/ui-form-field'
28
- import { uid } from '@instructure/uid'
29
28
  import {
30
29
  matchComponentTypes,
31
30
  safeCloneElement,
32
31
  pickProps,
33
- omitProps
32
+ omitProps,
33
+ withDeterministicId
34
34
  } from '@instructure/ui-react-utils'
35
35
  import { testable } from '@instructure/ui-testable'
36
36
 
@@ -49,6 +49,8 @@ category: components
49
49
  ---
50
50
  @tsProps
51
51
  **/
52
+
53
+ @withDeterministicId()
52
54
  @testable()
53
55
  class CheckboxGroup extends Component<CheckboxGroupProps, CheckboxGroupState> {
54
56
  static readonly componentId = 'CheckboxGroup'
@@ -72,7 +74,7 @@ class CheckboxGroup extends Component<CheckboxGroupProps, CheckboxGroupState> {
72
74
  }
73
75
  }
74
76
 
75
- this._messagesId = uid('CheckboxGroup-messages')
77
+ this._messagesId = props.deterministicId!()
76
78
  }
77
79
  private readonly _messagesId: string
78
80
  ref: Element | null = null
@@ -33,6 +33,7 @@ import {
33
33
 
34
34
  import type { FormMessage } from '@instructure/ui-form-field'
35
35
  import type { PropValidators } from '@instructure/shared-types'
36
+ import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
36
37
 
37
38
  import { Checkbox } from '../Checkbox'
38
39
  import type { CheckboxProps } from '../Checkbox/props'
@@ -57,7 +58,7 @@ type PropKeys = keyof CheckboxGroupOwnProps
57
58
 
58
59
  type AllowedPropKeys = Readonly<Array<PropKeys>>
59
60
 
60
- type CheckboxGroupProps = CheckboxGroupOwnProps
61
+ type CheckboxGroupProps = CheckboxGroupOwnProps & WithDeterministicIdProps
61
62
 
62
63
  const propTypes: PropValidators<PropKeys> = {
63
64
  name: PropTypes.string.isRequired,