@react-native-aria/switch 0.2.2 → 0.2.4-alpha.0
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/babel.config.js +3 -0
- package/lib/commonjs/useSwitch.js +6 -6
- package/lib/commonjs/useSwitch.js.map +1 -1
- package/lib/module/useSwitch.js +8 -8
- package/lib/module/useSwitch.js.map +1 -1
- package/lib/typescript/useSwitch.d.ts +4 -4
- package/package.json +3 -3
- package/scripts/bootstrap.js +24 -0
- package/src/useSwitch.ts +12 -13
- package/tsconfig.build.json +5 -0
package/babel.config.js
ADDED
@@ -37,12 +37,12 @@ function useSwitch(props, state, ref) {
|
|
37
37
|
} = state;
|
38
38
|
return {
|
39
39
|
inputProps: (0, _utils.mergeProps)(inputProps, {
|
40
|
-
|
41
|
-
checked: isSelected,
|
42
|
-
accessible: true,
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
'role': 'switch',
|
41
|
+
'checked': isSelected,
|
42
|
+
'accessible': true,
|
43
|
+
'aria-checked': isSelected,
|
44
|
+
'aria-disabled': props.isDisabled,
|
45
|
+
'aria-readonly': props.isReadOnly
|
46
46
|
})
|
47
47
|
};
|
48
48
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useSwitch.ts"],"names":["useSwitch","props","state","ref","inputProps","isSelected","
|
1
|
+
{"version":3,"sources":["useSwitch.ts"],"names":["useSwitch","props","state","ref","inputProps","isSelected","isDisabled","isReadOnly"],"mappings":";;;;;;;AAeA;;AAEA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIO;AACZ,MAAI;AAAEC,IAAAA;AAAF,MAAiB,uBAAUH,KAAV,EAAiBC,KAAjB,EAAwBC,GAAxB,CAArB;AACA,MAAI;AAAEE,IAAAA;AAAF,MAAiBH,KAArB;AAEA,SAAO;AACLE,IAAAA,UAAU,EAAE,uBAAWA,UAAX,EAAuB;AACjC,cAAQ,QADyB;AAEjC,iBAAWC,UAFsB;AAGjC,oBAAc,IAHmB;AAIjC,sBAAgBA,UAJiB;AAKjC,uBAAiBJ,KAAK,CAACK,UALU;AAMjC,uBAAiBL,KAAK,CAACM;AANU,KAAvB;AADP,GAAP;AAUD","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { AriaSwitchProps } from '@react-types/switch';\nimport type { RefObject } from 'react';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { useToggle } from '@react-native-aria/toggle';\nimport type { AccessibilityProps, AccessibilityRole } from 'react-native';\nimport { mergeProps } from '@react-aria/utils';\n\nexport interface SwitchAria {\n /** Props for the input element. */\n inputProps: any;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a switch component.\n * A switch is similar to a checkbox, but represents on/off values as opposed to selection.\n * @param props - Props for the switch.\n * @param state - State for the switch, as returned by `useToggleState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useSwitch(\n props: AriaSwitchProps & AccessibilityProps,\n state: ToggleState,\n ref: RefObject<HTMLInputElement>\n): SwitchAria {\n let { inputProps } = useToggle(props, state, ref);\n let { isSelected } = state;\n\n return {\n inputProps: mergeProps(inputProps, {\n 'role': 'switch' as AccessibilityRole,\n 'checked': isSelected,\n 'accessible': true,\n 'aria-checked': isSelected,\n 'aria-disabled': props.isDisabled,\n 'aria-readonly': props.isReadOnly,\n }),\n };\n}\n"]}
|
package/lib/module/useSwitch.js
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
10
10
|
* governing permissions and limitations under the License.
|
11
11
|
*/
|
12
|
-
import { useToggle } from
|
13
|
-
import { mergeProps } from
|
12
|
+
import { useToggle } from '@react-native-aria/toggle';
|
13
|
+
import { mergeProps } from '@react-aria/utils';
|
14
14
|
|
15
15
|
/**
|
16
16
|
* Provides the behavior and accessibility implementation for a switch component.
|
@@ -28,12 +28,12 @@ export function useSwitch(props, state, ref) {
|
|
28
28
|
} = state;
|
29
29
|
return {
|
30
30
|
inputProps: mergeProps(inputProps, {
|
31
|
-
|
32
|
-
checked: isSelected,
|
33
|
-
accessible: true,
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
'role': 'switch',
|
32
|
+
'checked': isSelected,
|
33
|
+
'accessible': true,
|
34
|
+
'aria-checked': isSelected,
|
35
|
+
'aria-disabled': props.isDisabled,
|
36
|
+
'aria-readonly': props.isReadOnly
|
37
37
|
})
|
38
38
|
};
|
39
39
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useSwitch.ts"],"names":["useToggle","mergeProps","useSwitch","props","state","ref","inputProps","isSelected","
|
1
|
+
{"version":3,"sources":["useSwitch.ts"],"names":["useToggle","mergeProps","useSwitch","props","state","ref","inputProps","isSelected","isDisabled","isReadOnly"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA,SAASA,SAAT,QAA0B,2BAA1B;AAEA,SAASC,UAAT,QAA2B,mBAA3B;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIO;AACZ,MAAI;AAAEC,IAAAA;AAAF,MAAiBN,SAAS,CAACG,KAAD,EAAQC,KAAR,EAAeC,GAAf,CAA9B;AACA,MAAI;AAAEE,IAAAA;AAAF,MAAiBH,KAArB;AAEA,SAAO;AACLE,IAAAA,UAAU,EAAEL,UAAU,CAACK,UAAD,EAAa;AACjC,cAAQ,QADyB;AAEjC,iBAAWC,UAFsB;AAGjC,oBAAc,IAHmB;AAIjC,sBAAgBA,UAJiB;AAKjC,uBAAiBJ,KAAK,CAACK,UALU;AAMjC,uBAAiBL,KAAK,CAACM;AANU,KAAb;AADjB,GAAP;AAUD","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { AriaSwitchProps } from '@react-types/switch';\nimport type { RefObject } from 'react';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { useToggle } from '@react-native-aria/toggle';\nimport type { AccessibilityProps, AccessibilityRole } from 'react-native';\nimport { mergeProps } from '@react-aria/utils';\n\nexport interface SwitchAria {\n /** Props for the input element. */\n inputProps: any;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a switch component.\n * A switch is similar to a checkbox, but represents on/off values as opposed to selection.\n * @param props - Props for the switch.\n * @param state - State for the switch, as returned by `useToggleState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useSwitch(\n props: AriaSwitchProps & AccessibilityProps,\n state: ToggleState,\n ref: RefObject<HTMLInputElement>\n): SwitchAria {\n let { inputProps } = useToggle(props, state, ref);\n let { isSelected } = state;\n\n return {\n inputProps: mergeProps(inputProps, {\n 'role': 'switch' as AccessibilityRole,\n 'checked': isSelected,\n 'accessible': true,\n 'aria-checked': isSelected,\n 'aria-disabled': props.isDisabled,\n 'aria-readonly': props.isReadOnly,\n }),\n };\n}\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type { AriaSwitchProps } from
|
2
|
-
import type { RefObject } from
|
3
|
-
import type { ToggleState } from
|
4
|
-
import type { AccessibilityProps } from
|
1
|
+
import type { AriaSwitchProps } from '@react-types/switch';
|
2
|
+
import type { RefObject } from 'react';
|
3
|
+
import type { ToggleState } from '@react-stately/toggle';
|
4
|
+
import type { AccessibilityProps } from 'react-native';
|
5
5
|
export interface SwitchAria {
|
6
6
|
/** Props for the input element. */
|
7
7
|
inputProps: any;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-aria/switch",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.4-alpha.0",
|
4
4
|
"description": "mono repo setup with bob",
|
5
5
|
"main": "lib/commonjs/index",
|
6
6
|
"module": "lib/module/index",
|
@@ -23,8 +23,8 @@
|
|
23
23
|
],
|
24
24
|
"dependencies": {
|
25
25
|
"@react-aria/switch": "^3.1.1",
|
26
|
-
"@react-aria/utils": "^3.
|
27
|
-
"@react-native-aria/toggle": "^0.2.
|
26
|
+
"@react-aria/utils": "^3.6.0",
|
27
|
+
"@react-native-aria/toggle": "^0.2.3",
|
28
28
|
"@react-stately/toggle": "^3.2.1",
|
29
29
|
"@react-types/switch": "^3.1.1"
|
30
30
|
},
|
@@ -0,0 +1,24 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
const child_process = require('child_process');
|
3
|
+
|
4
|
+
const root = path.resolve(__dirname, '..');
|
5
|
+
const args = process.argv.slice(2);
|
6
|
+
const options = {
|
7
|
+
cwd: process.cwd(),
|
8
|
+
env: process.env,
|
9
|
+
stdio: 'inherit',
|
10
|
+
encoding: 'utf-8',
|
11
|
+
};
|
12
|
+
|
13
|
+
let result;
|
14
|
+
|
15
|
+
if (process.cwd() !== root || args.length) {
|
16
|
+
// We're not in the root of the project, or additional arguments were passed
|
17
|
+
// In this case, forward the command to `yarn`
|
18
|
+
result = child_process.spawnSync('yarn', args, options);
|
19
|
+
} else {
|
20
|
+
// If `yarn` is run without arguments, perform bootstrap
|
21
|
+
result = child_process.spawnSync('yarn', ['bootstrap'], options);
|
22
|
+
}
|
23
|
+
|
24
|
+
process.exitCode = result.status;
|
package/src/useSwitch.ts
CHANGED
@@ -10,12 +10,12 @@
|
|
10
10
|
* governing permissions and limitations under the License.
|
11
11
|
*/
|
12
12
|
|
13
|
-
import type { AriaSwitchProps } from
|
14
|
-
import type { RefObject } from
|
15
|
-
import type { ToggleState } from
|
16
|
-
import { useToggle } from
|
17
|
-
import type { AccessibilityProps, AccessibilityRole } from
|
18
|
-
import { mergeProps } from
|
13
|
+
import type { AriaSwitchProps } from '@react-types/switch';
|
14
|
+
import type { RefObject } from 'react';
|
15
|
+
import type { ToggleState } from '@react-stately/toggle';
|
16
|
+
import { useToggle } from '@react-native-aria/toggle';
|
17
|
+
import type { AccessibilityProps, AccessibilityRole } from 'react-native';
|
18
|
+
import { mergeProps } from '@react-aria/utils';
|
19
19
|
|
20
20
|
export interface SwitchAria {
|
21
21
|
/** Props for the input element. */
|
@@ -39,13 +39,12 @@ export function useSwitch(
|
|
39
39
|
|
40
40
|
return {
|
41
41
|
inputProps: mergeProps(inputProps, {
|
42
|
-
|
43
|
-
checked: isSelected,
|
44
|
-
accessible: true,
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
},
|
42
|
+
'role': 'switch' as AccessibilityRole,
|
43
|
+
'checked': isSelected,
|
44
|
+
'accessible': true,
|
45
|
+
'aria-checked': isSelected,
|
46
|
+
'aria-disabled': props.isDisabled,
|
47
|
+
'aria-readonly': props.isReadOnly,
|
49
48
|
}),
|
50
49
|
};
|
51
50
|
}
|