react-stately 0.3.0 → 3.0.0-nightly-4980928d3-240906
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/README.md +45 -139
- package/dist/import.mjs +35 -0
- package/dist/main.js +65 -0
- package/dist/module.js +35 -0
- package/dist/types.d.ts +56 -0
- package/package.json +52 -45
- package/.eslintrc +0 -9
- package/LICENSE +0 -177
- package/dist/connected.js +0 -73
- package/dist/index.js +0 -45
- package/dist/provider.js +0 -117
- package/dist/stately.js +0 -70
- package/dist/withStately.js +0 -66
package/README.md
CHANGED
|
@@ -1,153 +1,59 @@
|
|
|
1
|
-
# react-stately
|
|
1
|
+
# [React Stately](https://react-spectrum.adobe.com/react-stately/index.html)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A library of React Hooks that provides cross-platform state management for your design system.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
Stately
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[Ramda](http://ramdajs.com/) lens. This helps you be declarative about which
|
|
12
|
-
parts of the global state your components rely upon.
|
|
7
|
+
* 🏠 **Foundational** – React Stately provides the foundation and core logic for your component library. It handles state management for common components through an easy-to-use interface.
|
|
8
|
+
* 📱 **Cross-platform** – React Stately only provides state management, with no assumptions about the DOM or other view systems.
|
|
9
|
+
* ⚓️ **Powered by React Hooks** – React Stately is implemented as a library of React Hooks, which allows you to adapt them to your needs through composition.
|
|
10
|
+
* 🎨 **Design agnostic** – React Stately doesn’t make any assumptions about your design. It provides state management that’s intrinsic to the functionality of the component.
|
|
13
11
|
|
|
14
|
-
##
|
|
12
|
+
## Getting started
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
* [Ramda Lens asciinema cast](https://asciinema.org/a/qlP2CvsQzThnjlUPUqTBfDcNj)
|
|
14
|
+
The easiest way to start building a component library with React Stately is by following our [getting started](https://react-spectrum.adobe.com/react-stately/getting-started.html) guide. It walks through all of the steps needed to install the hooks from npm, and create your first component.
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
### Example
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
set the initial state with a prop on the `Stately` component, which is
|
|
23
|
-
equivalent to setting the state in the constructor of a React stateful class
|
|
24
|
-
component. Then, provide the `Stately` component with a render prop, which
|
|
25
|
-
gives you access to the local state and the `setState` method, which work
|
|
26
|
-
exactly the same as `this.state` and `this.setState` in a React stateful class
|
|
27
|
-
component.
|
|
18
|
+
Here is a very basic example of using React Aria.
|
|
28
19
|
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
initialState={{ isAsleep: true }}
|
|
32
|
-
render={(state, setState) => (
|
|
33
|
-
<button onClick={() => setState({ isAsleep: false })}>
|
|
34
|
-
{state.isAsleep ? 'zzz... (click to wake me)' : 'good morning'}
|
|
35
|
-
</button>
|
|
36
|
-
)}
|
|
37
|
-
/>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
This example renders a button that initially renders a sleeping message. When
|
|
41
|
-
clicked, the button displays a "good morning" message. To manage the state of
|
|
42
|
-
whether the button is "asleep," we use an `isAsleep` boolean value, which starts
|
|
43
|
-
with an initial value of `true` in the initialState. When the user clicks the
|
|
44
|
-
button, we use the setState method to update the `isAsleep` value to `false`.
|
|
45
|
-
Since we use this state to control which message is displayed inside the button,
|
|
46
|
-
clicking the button will change the displayed message.
|
|
47
|
-
|
|
48
|
-
Note that you may provide a function to `setState` to base it off the previous
|
|
49
|
-
state, which works exactly as it does in React. If you needed to, you could
|
|
50
|
-
provide a callback as the second argument to `setState` as well, which is also
|
|
51
|
-
the same as in React. Generally, you should assume any `setState` in Stately
|
|
52
|
-
works similarly to React's `this.setState` method. There is one caveat to this
|
|
53
|
-
when managing global state, which is explained below.
|
|
20
|
+
```jsx
|
|
21
|
+
import {useRadioGroupState} from '@react-stately/radio';
|
|
54
22
|
|
|
55
|
-
|
|
23
|
+
function RadioGroup(props) {
|
|
24
|
+
let state = useRadioGroupState(props);
|
|
56
25
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
lens={R.lensProp('counter')}
|
|
75
|
-
render={(state, setState) => (
|
|
76
|
-
<button
|
|
77
|
-
onClick={() => {
|
|
78
|
-
setState(({ value: oldValue }) => ({ value: oldValue + 1 }))
|
|
79
|
-
}}
|
|
80
|
-
>
|
|
81
|
-
Increment the value
|
|
82
|
-
</button>
|
|
83
|
-
)}
|
|
84
|
-
/>
|
|
85
|
-
<ConnectedStately
|
|
86
|
-
lens={R.lensProp('authentication')}
|
|
87
|
-
render={(state, setState) => (
|
|
88
|
-
<div>
|
|
89
|
-
<button
|
|
90
|
-
onClick={() => {
|
|
91
|
-
setState(({ isLoggedIn: wasLoggedIn }) => ({
|
|
92
|
-
isLoggedIn: !wasLoggedIn
|
|
93
|
-
}))
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
96
|
-
{state.isLoggedIn ? 'Log out' : 'Log in'}
|
|
97
|
-
</button>
|
|
98
|
-
<ConnectedStately
|
|
99
|
-
lens={R.lensProp('counter')}
|
|
100
|
-
render={state => (
|
|
101
|
-
<span>We can access the counter here too: {state.value}</span>
|
|
102
|
-
)}
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<label>
|
|
29
|
+
<input
|
|
30
|
+
type="radio"
|
|
31
|
+
name={state.name}
|
|
32
|
+
checked={state.selectedValue === 'dogs'}
|
|
33
|
+
onChange={() => state.setSelectedValue('dogs')}
|
|
34
|
+
/>
|
|
35
|
+
Dogs
|
|
36
|
+
</label>
|
|
37
|
+
<label>
|
|
38
|
+
<input
|
|
39
|
+
type="radio"
|
|
40
|
+
name={state.name}
|
|
41
|
+
checked={state.selectedValue === 'cats'}
|
|
42
|
+
onChange={() => state.setSelectedValue('cats')}
|
|
103
43
|
/>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
44
|
+
Cats
|
|
45
|
+
</label>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
<RadioGroup
|
|
51
|
+
defaultValue="dogs"
|
|
52
|
+
onChange={(value) => alert(`Selected ${value}`)}
|
|
53
|
+
/>
|
|
108
54
|
```
|
|
109
55
|
|
|
110
|
-
|
|
111
|
-
information and a counter value. It works very similarly to the local state
|
|
112
|
-
example, except we provide the initial state in the provider and access it
|
|
113
|
-
using the `ConnectedStately` component. We have a counter button at the top
|
|
114
|
-
which accesses the global state under the `counter` key to increment the value
|
|
115
|
-
when the button is pressed. Below that, there's an authentication button which
|
|
116
|
-
is scoped under the global `auth` key. This allows you to click to log in and
|
|
117
|
-
out, changing the text of the button. But also, inside the component managing
|
|
118
|
-
the authentication button, we also display the value of the counter using a
|
|
119
|
-
nested `ConnectedStately` component.
|
|
120
|
-
|
|
121
|
-
If you need to access multiple parts of the global state, you should use nested
|
|
122
|
-
`ConnectedStately` components with different Ramda lenses, one for each scope
|
|
123
|
-
in the global state to which you need access. Note that we do this above to
|
|
124
|
-
access the counter value inside the authentication section. If you find
|
|
125
|
-
yourself doing this a lot, maybe it's important to re-evaluate the structure of
|
|
126
|
-
the global state to place similar information together. This should lead to
|
|
127
|
-
cleaner global state management code, which is one of the goals of Stately.
|
|
128
|
-
|
|
129
|
-
Notice how using lenses allows us to separate the concerns of authentication and
|
|
130
|
-
the counter. This helps you to build global state management solutions that play
|
|
131
|
-
together nicely. There's no guessing about which part of the state each piece of
|
|
132
|
-
the application manages. Even when we do things like accessing various parts of
|
|
133
|
-
the state in the same piece of the application, we still get the same
|
|
134
|
-
declarative nature. This is one of the major strong points of using Stately over
|
|
135
|
-
a normal Javascript global.
|
|
136
|
-
|
|
137
|
-
## License
|
|
138
|
-
|
|
139
|
-
Copyright 2018 Christian Howe
|
|
140
|
-
|
|
141
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
142
|
-
you may not use this file except in compliance with the License.
|
|
143
|
-
You may obtain a copy of the License at
|
|
144
|
-
|
|
145
|
-
<http://www.apache.org/licenses/LICENSE-2.0>
|
|
146
|
-
|
|
147
|
-
Unless required by applicable law or agreed to in writing, software
|
|
148
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
149
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
150
|
-
See the License for the specific language governing permissions and
|
|
151
|
-
limitations under the License.
|
|
56
|
+
## Learn more
|
|
152
57
|
|
|
153
|
-
|
|
58
|
+
React Stately is part of a family of libraries that help you build adaptive, accessible, and robust user experiences.
|
|
59
|
+
Learn more about [React Spectrum](https://react-spectrum.adobe.com/react-spectrum/index.html) and [React Aria](https://react-spectrum.adobe.com/react-aria/index.html) on [our website](https://react-spectrum.adobe.com/index.html).
|
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export {useCalendarState, useRangeCalendarState} from '@react-stately/calendar';
|
|
15
|
+
export {useCheckboxGroupState} from '@react-stately/checkbox';
|
|
16
|
+
export {useComboBoxState} from '@react-stately/combobox';
|
|
17
|
+
export {useDateFieldState, useDatePickerState, useDateRangePickerState, useTimeFieldState} from '@react-stately/datepicker';
|
|
18
|
+
export {useDraggableCollectionState, useDroppableCollectionState} from '@react-stately/dnd';
|
|
19
|
+
export {Item, Section, useCollection} from '@react-stately/collections';
|
|
20
|
+
export {useAsyncList, useListData, useTreeData} from '@react-stately/data';
|
|
21
|
+
export {useListState, useSingleSelectListState} from '@react-stately/list';
|
|
22
|
+
export {useMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';
|
|
23
|
+
export {useNumberFieldState} from '@react-stately/numberfield';
|
|
24
|
+
export {useOverlayTriggerState} from '@react-stately/overlays';
|
|
25
|
+
export {useRadioGroupState} from '@react-stately/radio';
|
|
26
|
+
export {useSearchFieldState} from '@react-stately/searchfield';
|
|
27
|
+
export {useSelectState} from '@react-stately/select';
|
|
28
|
+
export {useSliderState} from '@react-stately/slider';
|
|
29
|
+
export {useMultipleSelectionState} from '@react-stately/selection';
|
|
30
|
+
export {useTableState, TableHeader, TableBody, Column, Row, Cell, useTableColumnResizeState} from '@react-stately/table';
|
|
31
|
+
export {useTabListState} from '@react-stately/tabs';
|
|
32
|
+
export {useToggleState} from '@react-stately/toggle';
|
|
33
|
+
export {useTooltipTriggerState} from '@react-stately/tooltip';
|
|
34
|
+
export {useTreeState} from '@react-stately/tree';
|
|
35
|
+
export {FormValidationContext} from '@react-stately/form';
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useTreeState = exports.useTreeData = exports.useTooltipTriggerState = exports.useToggleState = exports.useTimeFieldState = exports.useTableState = exports.useTableColumnResizeState = exports.useTabListState = exports.useSubmenuTriggerState = exports.useSliderState = exports.useSingleSelectListState = exports.useSelectState = exports.useSearchFieldState = exports.useRangeCalendarState = exports.useRadioGroupState = exports.useOverlayTriggerState = exports.useNumberFieldState = exports.useMultipleSelectionState = exports.useMenuTriggerState = exports.useListState = exports.useListData = exports.useDroppableCollectionState = exports.useDraggableCollectionState = exports.useDateRangePickerState = exports.useDatePickerState = exports.useDateFieldState = exports.useComboBoxState = exports.useCollection = exports.useCheckboxGroupState = exports.useCalendarState = exports.useAsyncList = exports.TableHeader = exports.TableBody = exports.Section = exports.Row = exports.Item = exports.FormValidationContext = exports.Column = exports.Cell = void 0;
|
|
5
|
+
var _calendar = require("@react-stately/calendar");
|
|
6
|
+
exports.useCalendarState = _calendar.useCalendarState;
|
|
7
|
+
exports.useRangeCalendarState = _calendar.useRangeCalendarState;
|
|
8
|
+
var _checkbox = require("@react-stately/checkbox");
|
|
9
|
+
exports.useCheckboxGroupState = _checkbox.useCheckboxGroupState;
|
|
10
|
+
var _combobox = require("@react-stately/combobox");
|
|
11
|
+
exports.useComboBoxState = _combobox.useComboBoxState;
|
|
12
|
+
var _datepicker = require("@react-stately/datepicker");
|
|
13
|
+
exports.useDateFieldState = _datepicker.useDateFieldState;
|
|
14
|
+
exports.useDatePickerState = _datepicker.useDatePickerState;
|
|
15
|
+
exports.useDateRangePickerState = _datepicker.useDateRangePickerState;
|
|
16
|
+
exports.useTimeFieldState = _datepicker.useTimeFieldState;
|
|
17
|
+
var _dnd = require("@react-stately/dnd");
|
|
18
|
+
exports.useDraggableCollectionState = _dnd.useDraggableCollectionState;
|
|
19
|
+
exports.useDroppableCollectionState = _dnd.useDroppableCollectionState;
|
|
20
|
+
var _collections = require("@react-stately/collections");
|
|
21
|
+
exports.Item = _collections.Item;
|
|
22
|
+
exports.Section = _collections.Section;
|
|
23
|
+
exports.useCollection = _collections.useCollection;
|
|
24
|
+
var _data = require("@react-stately/data");
|
|
25
|
+
exports.useAsyncList = _data.useAsyncList;
|
|
26
|
+
exports.useListData = _data.useListData;
|
|
27
|
+
exports.useTreeData = _data.useTreeData;
|
|
28
|
+
var _list = require("@react-stately/list");
|
|
29
|
+
exports.useListState = _list.useListState;
|
|
30
|
+
exports.useSingleSelectListState = _list.useSingleSelectListState;
|
|
31
|
+
var _menu = require("@react-stately/menu");
|
|
32
|
+
exports.useMenuTriggerState = _menu.useMenuTriggerState;
|
|
33
|
+
exports.useSubmenuTriggerState = _menu.useSubmenuTriggerState;
|
|
34
|
+
var _numberfield = require("@react-stately/numberfield");
|
|
35
|
+
exports.useNumberFieldState = _numberfield.useNumberFieldState;
|
|
36
|
+
var _overlays = require("@react-stately/overlays");
|
|
37
|
+
exports.useOverlayTriggerState = _overlays.useOverlayTriggerState;
|
|
38
|
+
var _radio = require("@react-stately/radio");
|
|
39
|
+
exports.useRadioGroupState = _radio.useRadioGroupState;
|
|
40
|
+
var _searchfield = require("@react-stately/searchfield");
|
|
41
|
+
exports.useSearchFieldState = _searchfield.useSearchFieldState;
|
|
42
|
+
var _select = require("@react-stately/select");
|
|
43
|
+
exports.useSelectState = _select.useSelectState;
|
|
44
|
+
var _slider = require("@react-stately/slider");
|
|
45
|
+
exports.useSliderState = _slider.useSliderState;
|
|
46
|
+
var _selection = require("@react-stately/selection");
|
|
47
|
+
exports.useMultipleSelectionState = _selection.useMultipleSelectionState;
|
|
48
|
+
var _table = require("@react-stately/table");
|
|
49
|
+
exports.useTableState = _table.useTableState;
|
|
50
|
+
exports.TableHeader = _table.TableHeader;
|
|
51
|
+
exports.TableBody = _table.TableBody;
|
|
52
|
+
exports.Column = _table.Column;
|
|
53
|
+
exports.Row = _table.Row;
|
|
54
|
+
exports.Cell = _table.Cell;
|
|
55
|
+
exports.useTableColumnResizeState = _table.useTableColumnResizeState;
|
|
56
|
+
var _tabs = require("@react-stately/tabs");
|
|
57
|
+
exports.useTabListState = _tabs.useTabListState;
|
|
58
|
+
var _toggle = require("@react-stately/toggle");
|
|
59
|
+
exports.useToggleState = _toggle.useToggleState;
|
|
60
|
+
var _tooltip = require("@react-stately/tooltip");
|
|
61
|
+
exports.useTooltipTriggerState = _tooltip.useTooltipTriggerState;
|
|
62
|
+
var _tree = require("@react-stately/tree");
|
|
63
|
+
exports.useTreeState = _tree.useTreeState;
|
|
64
|
+
var _form = require("@react-stately/form");
|
|
65
|
+
exports.FormValidationContext = _form.FormValidationContext;
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export {useCalendarState, useRangeCalendarState} from '@react-stately/calendar';
|
|
15
|
+
export {useCheckboxGroupState} from '@react-stately/checkbox';
|
|
16
|
+
export {useComboBoxState} from '@react-stately/combobox';
|
|
17
|
+
export {useDateFieldState, useDatePickerState, useDateRangePickerState, useTimeFieldState} from '@react-stately/datepicker';
|
|
18
|
+
export {useDraggableCollectionState, useDroppableCollectionState} from '@react-stately/dnd';
|
|
19
|
+
export {Item, Section, useCollection} from '@react-stately/collections';
|
|
20
|
+
export {useAsyncList, useListData, useTreeData} from '@react-stately/data';
|
|
21
|
+
export {useListState, useSingleSelectListState} from '@react-stately/list';
|
|
22
|
+
export {useMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';
|
|
23
|
+
export {useNumberFieldState} from '@react-stately/numberfield';
|
|
24
|
+
export {useOverlayTriggerState} from '@react-stately/overlays';
|
|
25
|
+
export {useRadioGroupState} from '@react-stately/radio';
|
|
26
|
+
export {useSearchFieldState} from '@react-stately/searchfield';
|
|
27
|
+
export {useSelectState} from '@react-stately/select';
|
|
28
|
+
export {useSliderState} from '@react-stately/slider';
|
|
29
|
+
export {useMultipleSelectionState} from '@react-stately/selection';
|
|
30
|
+
export {useTableState, TableHeader, TableBody, Column, Row, Cell, useTableColumnResizeState} from '@react-stately/table';
|
|
31
|
+
export {useTabListState} from '@react-stately/tabs';
|
|
32
|
+
export {useToggleState} from '@react-stately/toggle';
|
|
33
|
+
export {useTooltipTriggerState} from '@react-stately/tooltip';
|
|
34
|
+
export {useTreeState} from '@react-stately/tree';
|
|
35
|
+
export {FormValidationContext} from '@react-stately/form';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type {CalendarState, CalendarStateOptions, RangeCalendarState, RangeCalendarStateOptions} from '@react-stately/calendar';
|
|
14
|
+
export type {CheckboxGroupProps, CheckboxGroupState} from '@react-stately/checkbox';
|
|
15
|
+
export type {ComboBoxState, ComboBoxStateOptions} from '@react-stately/combobox';
|
|
16
|
+
export type {DateFieldState, DateFieldStateOptions, DatePickerState, DatePickerStateOptions, DateRangePickerState, DateRangePickerStateOptions, DateSegment, SegmentType as DateSegmentType, TimeFieldStateOptions, TimeFieldState} from '@react-stately/datepicker';
|
|
17
|
+
export type {DraggableCollectionStateOptions, DraggableCollectionState, DroppableCollectionStateOptions, DroppableCollectionState} from '@react-stately/dnd';
|
|
18
|
+
export type {AsyncListData, AsyncListOptions, ListData, ListOptions, TreeData, TreeOptions} from '@react-stately/data';
|
|
19
|
+
export type {ListProps, ListState, SingleSelectListProps, SingleSelectListState} from '@react-stately/list';
|
|
20
|
+
export type {MenuTriggerProps, MenuTriggerState, RootMenuTriggerState, SubmenuTriggerState, SubmenuTriggerProps} from '@react-stately/menu';
|
|
21
|
+
export type {OverlayTriggerProps, OverlayTriggerState} from '@react-stately/overlays';
|
|
22
|
+
export type {RadioGroupProps, RadioGroupState} from '@react-stately/radio';
|
|
23
|
+
export type {SearchFieldProps, SearchFieldState} from '@react-stately/searchfield';
|
|
24
|
+
export type {SelectProps, SelectState, SelectStateOptions} from '@react-stately/select';
|
|
25
|
+
export type {SliderState, SliderStateOptions} from '@react-stately/slider';
|
|
26
|
+
export type {MultipleSelectionManager, MultipleSelectionState, SingleSelectionState} from '@react-stately/selection';
|
|
27
|
+
export type {NumberFieldState, NumberFieldStateOptions} from '@react-stately/numberfield';
|
|
28
|
+
export type {TableState, TableStateProps, TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps, TableColumnResizeState, TableColumnResizeStateProps} from '@react-stately/table';
|
|
29
|
+
export type {TabListProps, TabListState} from '@react-stately/tabs';
|
|
30
|
+
export type {ToggleProps, ToggleState} from '@react-stately/toggle';
|
|
31
|
+
export type {TooltipTriggerProps, TooltipTriggerState} from '@react-stately/tooltip';
|
|
32
|
+
export type {TreeProps, TreeState} from '@react-stately/tree';
|
|
33
|
+
export type {ItemProps, Key, SectionProps, Collection, Node, Orientation, DisabledBehavior, Selection, SelectionBehavior, SelectionMode, SortDescriptor, SortDirection, ValidationState} from '@react-types/shared';
|
|
34
|
+
|
|
35
|
+
export {useCalendarState, useRangeCalendarState} from '@react-stately/calendar';
|
|
36
|
+
export {useCheckboxGroupState} from '@react-stately/checkbox';
|
|
37
|
+
export {useComboBoxState} from '@react-stately/combobox';
|
|
38
|
+
export {useDateFieldState, useDatePickerState, useDateRangePickerState, useTimeFieldState} from '@react-stately/datepicker';
|
|
39
|
+
export {useDraggableCollectionState, useDroppableCollectionState} from '@react-stately/dnd';
|
|
40
|
+
export {Item, Section, useCollection} from '@react-stately/collections';
|
|
41
|
+
export {useAsyncList, useListData, useTreeData} from '@react-stately/data';
|
|
42
|
+
export {useListState, useSingleSelectListState} from '@react-stately/list';
|
|
43
|
+
export {useMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';
|
|
44
|
+
export {useNumberFieldState} from '@react-stately/numberfield';
|
|
45
|
+
export {useOverlayTriggerState} from '@react-stately/overlays';
|
|
46
|
+
export {useRadioGroupState} from '@react-stately/radio';
|
|
47
|
+
export {useSearchFieldState} from '@react-stately/searchfield';
|
|
48
|
+
export {useSelectState} from '@react-stately/select';
|
|
49
|
+
export {useSliderState} from '@react-stately/slider';
|
|
50
|
+
export {useMultipleSelectionState} from '@react-stately/selection';
|
|
51
|
+
export {useTableState, TableHeader, TableBody, Column, Row, Cell, useTableColumnResizeState} from '@react-stately/table';
|
|
52
|
+
export {useTabListState} from '@react-stately/tabs';
|
|
53
|
+
export {useToggleState} from '@react-stately/toggle';
|
|
54
|
+
export {useTooltipTriggerState} from '@react-stately/tooltip';
|
|
55
|
+
export {useTreeState} from '@react-stately/tree';
|
|
56
|
+
export {FormValidationContext} from '@react-stately/form';
|
package/package.json
CHANGED
|
@@ -1,55 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-stately",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"repository": "https://github.com/cjhowe7/react-stately",
|
|
7
|
-
"author": "Christian Howe",
|
|
3
|
+
"version": "3.0.0-nightly-4980928d3-240906",
|
|
4
|
+
"description": "Spectrum UI components in React",
|
|
8
5
|
"license": "Apache-2.0",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/types.d.ts",
|
|
14
|
+
"source": "src/index.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"scripts": {
|
|
20
|
+
"prepublishOnly": "mkdir -p dist; cp src/index.ts dist/types.d.ts; grep -v '^export type' src/index.ts > dist/module.js; babel --root-mode upward src/index.ts -o dist/main.js"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/adobe/react-spectrum"
|
|
25
|
+
},
|
|
9
26
|
"dependencies": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
27
|
+
"@react-stately/calendar": "^3.0.0-nightly-4980928d3-240906",
|
|
28
|
+
"@react-stately/checkbox": "^3.0.0-nightly-4980928d3-240906",
|
|
29
|
+
"@react-stately/collections": "^3.0.0-nightly-4980928d3-240906",
|
|
30
|
+
"@react-stately/combobox": "^3.0.0-nightly-4980928d3-240906",
|
|
31
|
+
"@react-stately/data": "^3.0.0-nightly-4980928d3-240906",
|
|
32
|
+
"@react-stately/datepicker": "^3.0.0-nightly-4980928d3-240906",
|
|
33
|
+
"@react-stately/dnd": "^3.0.0-nightly-4980928d3-240906",
|
|
34
|
+
"@react-stately/form": "^3.0.0-nightly-4980928d3-240906",
|
|
35
|
+
"@react-stately/list": "^3.0.0-nightly-4980928d3-240906",
|
|
36
|
+
"@react-stately/menu": "^3.0.0-nightly-4980928d3-240906",
|
|
37
|
+
"@react-stately/numberfield": "^3.0.0-nightly-4980928d3-240906",
|
|
38
|
+
"@react-stately/overlays": "^3.0.0-nightly-4980928d3-240906",
|
|
39
|
+
"@react-stately/radio": "^3.0.0-nightly-4980928d3-240906",
|
|
40
|
+
"@react-stately/searchfield": "^3.0.0-nightly-4980928d3-240906",
|
|
41
|
+
"@react-stately/select": "^3.0.0-nightly-4980928d3-240906",
|
|
42
|
+
"@react-stately/selection": "^3.0.0-nightly-4980928d3-240906",
|
|
43
|
+
"@react-stately/slider": "^3.0.0-nightly-4980928d3-240906",
|
|
44
|
+
"@react-stately/table": "^3.0.0-nightly-4980928d3-240906",
|
|
45
|
+
"@react-stately/tabs": "^3.0.0-nightly-4980928d3-240906",
|
|
46
|
+
"@react-stately/toggle": "^3.0.0-nightly-4980928d3-240906",
|
|
47
|
+
"@react-stately/tooltip": "^3.0.0-nightly-4980928d3-240906",
|
|
48
|
+
"@react-stately/tree": "^3.0.0-nightly-4980928d3-240906",
|
|
49
|
+
"@react-types/shared": "^3.0.0-nightly-4980928d3-240906"
|
|
12
50
|
},
|
|
13
51
|
"peerDependencies": {
|
|
14
|
-
"
|
|
15
|
-
"react": "^16.2.0"
|
|
52
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
16
53
|
},
|
|
17
54
|
"devDependencies": {
|
|
18
|
-
"babel
|
|
19
|
-
"babel
|
|
20
|
-
"babel-eslint": "^8.2.1",
|
|
21
|
-
"babel-jest": "^22.0.6",
|
|
22
|
-
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
23
|
-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
24
|
-
"babel-preset-env": "^1.6.1",
|
|
25
|
-
"babel-preset-react": "^6.24.1",
|
|
26
|
-
"enzyme": "^3.3.0",
|
|
27
|
-
"enzyme-adapter-react-16": "^1.1.1",
|
|
28
|
-
"eslint": "^4.15.0",
|
|
29
|
-
"eslint-config-standard": "^11.0.0-beta.0",
|
|
30
|
-
"eslint-plugin-import": "^2.8.0",
|
|
31
|
-
"eslint-plugin-jest": "^21.6.2",
|
|
32
|
-
"eslint-plugin-node": "^5.2.1",
|
|
33
|
-
"eslint-plugin-promise": "^3.6.0",
|
|
34
|
-
"eslint-plugin-react": "^7.5.1",
|
|
35
|
-
"eslint-plugin-standard": "^3.0.1",
|
|
36
|
-
"jest": "^22.0.6",
|
|
37
|
-
"jest-enzyme": "^4.0.2",
|
|
38
|
-
"prettier": "^1.10.2",
|
|
39
|
-
"prettier-eslint": "^8.7.4",
|
|
40
|
-
"ramda": "^0.25.0",
|
|
41
|
-
"react": "^16.2.0",
|
|
42
|
-
"react-dom": "^16.2.0",
|
|
43
|
-
"regenerator-runtime": "^0.11.1",
|
|
44
|
-
"rimraf": "^2.6.2"
|
|
55
|
+
"@babel/cli": "^7.24.1",
|
|
56
|
+
"@babel/core": "^7.24.3"
|
|
45
57
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"build": "babel src -d dist",
|
|
49
|
-
"clean": "rimraf dist",
|
|
50
|
-
"deploy": "yarn clean && yarn build && yarn publish"
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
51
60
|
},
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
61
|
+
"stableVersion": "3.32.2"
|
|
62
|
+
}
|
package/.eslintrc
DELETED
package/LICENSE
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
package/dist/connected.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _propTypes = require('prop-types');
|
|
8
|
-
|
|
9
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
10
|
-
|
|
11
|
-
var _ramda = require('ramda');
|
|
12
|
-
|
|
13
|
-
var R = _interopRequireWildcard(_ramda);
|
|
14
|
-
|
|
15
|
-
var _provider = require('./provider');
|
|
16
|
-
|
|
17
|
-
var _provider2 = _interopRequireDefault(_provider);
|
|
18
|
-
|
|
19
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /*
|
|
24
|
-
* Copyright 2018 Christian Howe
|
|
25
|
-
*
|
|
26
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27
|
-
* you may not use this file except in compliance with the License.
|
|
28
|
-
* You may obtain a copy of the License at
|
|
29
|
-
*
|
|
30
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
-
*
|
|
32
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
-
* See the License for the specific language governing permissions and
|
|
36
|
-
* limitations under the License.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
var ConnectedStately = function ConnectedStately(_ref, _ref2) {
|
|
40
|
-
var render = _ref.render,
|
|
41
|
-
lens = _ref.lens;
|
|
42
|
-
var _ref2$StatelyProvider = _ref2[_provider2.default.contextName],
|
|
43
|
-
state = _ref2$StatelyProvider.state,
|
|
44
|
-
update = _ref2$StatelyProvider.update;
|
|
45
|
-
return (
|
|
46
|
-
// Call the render prop with the state and a function that acts like setState,
|
|
47
|
-
// using the lens to scope the state
|
|
48
|
-
render(R.view(lens, state), function (updater, callback) {
|
|
49
|
-
// Use the lens to update the selected piece of the previous state
|
|
50
|
-
var lensUpdater = function lensUpdater(prevState, props) {
|
|
51
|
-
return R.over(lens, function (selectedPrevState) {
|
|
52
|
-
return R.merge(selectedPrevState,
|
|
53
|
-
// If the updater is a function, then call it with the previous
|
|
54
|
-
// state and provider props to get an object to merge into the
|
|
55
|
-
// previous state. If the updater is not a function, it's an object
|
|
56
|
-
// to merge into the previous state, so return it directly
|
|
57
|
-
typeof updater === 'function' ? updater(selectedPrevState, props) : updater);
|
|
58
|
-
}, prevState);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return update(lensUpdater, callback);
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
ConnectedStately.propTypes = {
|
|
67
|
-
render: _propTypes2.default.func.isRequired,
|
|
68
|
-
lens: _propTypes2.default.func.isRequired
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
ConnectedStately.contextTypes = _defineProperty({}, _provider2.default.contextName, _propTypes2.default.object.isRequired);
|
|
72
|
-
|
|
73
|
-
exports.default = ConnectedStately;
|
package/dist/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.withStately = exports.ConnectedStately = exports.StatelyProvider = exports.Stately = undefined;
|
|
7
|
-
|
|
8
|
-
var _stately = require('./stately');
|
|
9
|
-
|
|
10
|
-
var _stately2 = _interopRequireDefault(_stately);
|
|
11
|
-
|
|
12
|
-
var _provider = require('./provider');
|
|
13
|
-
|
|
14
|
-
var _provider2 = _interopRequireDefault(_provider);
|
|
15
|
-
|
|
16
|
-
var _connected = require('./connected');
|
|
17
|
-
|
|
18
|
-
var _connected2 = _interopRequireDefault(_connected);
|
|
19
|
-
|
|
20
|
-
var _withStately = require('./withStately');
|
|
21
|
-
|
|
22
|
-
var _withStately2 = _interopRequireDefault(_withStately);
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* Copyright 2018 Christian Howe
|
|
28
|
-
*
|
|
29
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
-
* you may not use this file except in compliance with the License.
|
|
31
|
-
* You may obtain a copy of the License at
|
|
32
|
-
*
|
|
33
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
-
*
|
|
35
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
36
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
-
* See the License for the specific language governing permissions and
|
|
39
|
-
* limitations under the License.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
exports.Stately = _stately2.default;
|
|
43
|
-
exports.StatelyProvider = _provider2.default;
|
|
44
|
-
exports.ConnectedStately = _connected2.default;
|
|
45
|
-
exports.withStately = _withStately2.default;
|
package/dist/provider.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _class, _temp;
|
|
8
|
-
|
|
9
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
10
|
-
|
|
11
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
12
|
-
|
|
13
|
-
var _react = require('react');
|
|
14
|
-
|
|
15
|
-
var _react2 = _interopRequireDefault(_react);
|
|
16
|
-
|
|
17
|
-
var _propTypes = require('prop-types');
|
|
18
|
-
|
|
19
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
20
|
-
|
|
21
|
-
var _stately = require('./stately');
|
|
22
|
-
|
|
23
|
-
var _stately2 = _interopRequireDefault(_stately);
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
-
|
|
29
|
-
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
30
|
-
|
|
31
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
32
|
-
|
|
33
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
34
|
-
|
|
35
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
|
|
36
|
-
* Copyright 2018 Christian Howe
|
|
37
|
-
*
|
|
38
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
39
|
-
* you may not use this file except in compliance with the License.
|
|
40
|
-
* You may obtain a copy of the License at
|
|
41
|
-
*
|
|
42
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
-
*
|
|
44
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
45
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
46
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
47
|
-
* See the License for the specific language governing permissions and
|
|
48
|
-
* limitations under the License.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
var StatelyProvider = function (_Component) {
|
|
52
|
-
_inherits(StatelyProvider, _Component);
|
|
53
|
-
|
|
54
|
-
function StatelyProvider() {
|
|
55
|
-
_classCallCheck(this, StatelyProvider);
|
|
56
|
-
|
|
57
|
-
return _possibleConstructorReturn(this, (StatelyProvider.__proto__ || Object.getPrototypeOf(StatelyProvider)).apply(this, arguments));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_createClass(StatelyProvider, [{
|
|
61
|
-
key: 'render',
|
|
62
|
-
value: function render() {
|
|
63
|
-
var _props = this.props,
|
|
64
|
-
children = _props.children,
|
|
65
|
-
rest = _objectWithoutProperties(_props, ['children']);
|
|
66
|
-
|
|
67
|
-
return _react2.default.createElement(_stately2.default, _extends({}, rest, {
|
|
68
|
-
render: function render(state, update) {
|
|
69
|
-
return _react2.default.createElement(
|
|
70
|
-
StatelyProvider.Renderer,
|
|
71
|
-
{ state: state, update: update },
|
|
72
|
-
children
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
}]);
|
|
78
|
-
|
|
79
|
-
return StatelyProvider;
|
|
80
|
-
}(_react.Component);
|
|
81
|
-
|
|
82
|
-
StatelyProvider.contextName = '__CONNECTED_STATELY_DATA__';
|
|
83
|
-
StatelyProvider.propTypes = {
|
|
84
|
-
children: _propTypes2.default.node
|
|
85
|
-
};
|
|
86
|
-
StatelyProvider.Renderer = (_temp = _class = function (_Component2) {
|
|
87
|
-
_inherits(StatelyProviderRenderer, _Component2);
|
|
88
|
-
|
|
89
|
-
function StatelyProviderRenderer() {
|
|
90
|
-
_classCallCheck(this, StatelyProviderRenderer);
|
|
91
|
-
|
|
92
|
-
return _possibleConstructorReturn(this, (StatelyProviderRenderer.__proto__ || Object.getPrototypeOf(StatelyProviderRenderer)).apply(this, arguments));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_createClass(StatelyProviderRenderer, [{
|
|
96
|
-
key: 'getChildContext',
|
|
97
|
-
value: function getChildContext() {
|
|
98
|
-
var _props2 = this.props,
|
|
99
|
-
state = _props2.state,
|
|
100
|
-
update = _props2.update;
|
|
101
|
-
|
|
102
|
-
return _defineProperty({}, StatelyProvider.contextName, { state: state, update: update });
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: 'render',
|
|
106
|
-
value: function render() {
|
|
107
|
-
return this.props.children;
|
|
108
|
-
}
|
|
109
|
-
}]);
|
|
110
|
-
|
|
111
|
-
return StatelyProviderRenderer;
|
|
112
|
-
}(_react.Component), _class.propTypes = {
|
|
113
|
-
children: _propTypes2.default.node,
|
|
114
|
-
state: _propTypes2.default.object.isRequired,
|
|
115
|
-
update: _propTypes2.default.func.isRequired
|
|
116
|
-
}, _class.childContextTypes = _defineProperty({}, StatelyProvider.contextName, _propTypes2.default.object.isRequired), _temp);
|
|
117
|
-
exports.default = StatelyProvider;
|
package/dist/stately.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
8
|
-
|
|
9
|
-
var _react = require('react');
|
|
10
|
-
|
|
11
|
-
var _propTypes = require('prop-types');
|
|
12
|
-
|
|
13
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
-
|
|
19
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
20
|
-
|
|
21
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /*
|
|
22
|
-
* Copyright 2018 Christian Howe
|
|
23
|
-
*
|
|
24
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
25
|
-
* you may not use this file except in compliance with the License.
|
|
26
|
-
* You may obtain a copy of the License at
|
|
27
|
-
*
|
|
28
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
-
*
|
|
30
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
31
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
32
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
33
|
-
* See the License for the specific language governing permissions and
|
|
34
|
-
* limitations under the License.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
var Stately = function (_Component) {
|
|
38
|
-
_inherits(Stately, _Component);
|
|
39
|
-
|
|
40
|
-
function Stately(props) {
|
|
41
|
-
_classCallCheck(this, Stately);
|
|
42
|
-
|
|
43
|
-
var _this = _possibleConstructorReturn(this, (Stately.__proto__ || Object.getPrototypeOf(Stately)).call(this, props));
|
|
44
|
-
|
|
45
|
-
_this.update = function () {
|
|
46
|
-
_this.setState.apply(_this, arguments);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
_this.state = props.initialState;
|
|
50
|
-
return _this;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// this is pure, undistilled evil concentrated into an enjoyable function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_createClass(Stately, [{
|
|
57
|
-
key: 'render',
|
|
58
|
-
value: function render() {
|
|
59
|
-
return this.props.render(this.state, this.update);
|
|
60
|
-
}
|
|
61
|
-
}]);
|
|
62
|
-
|
|
63
|
-
return Stately;
|
|
64
|
-
}(_react.Component);
|
|
65
|
-
|
|
66
|
-
Stately.propTypes = {
|
|
67
|
-
initialState: _propTypes2.default.object.isRequired,
|
|
68
|
-
render: _propTypes2.default.func.isRequired
|
|
69
|
-
};
|
|
70
|
-
exports.default = Stately;
|
package/dist/withStately.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
8
|
-
|
|
9
|
-
var _react = require('react');
|
|
10
|
-
|
|
11
|
-
var _react2 = _interopRequireDefault(_react);
|
|
12
|
-
|
|
13
|
-
var _hoistNonReactStatics = require('hoist-non-react-statics');
|
|
14
|
-
|
|
15
|
-
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
|
|
16
|
-
|
|
17
|
-
var _propTypes = require('prop-types');
|
|
18
|
-
|
|
19
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
20
|
-
|
|
21
|
-
var _connected = require('./connected');
|
|
22
|
-
|
|
23
|
-
var _connected2 = _interopRequireDefault(_connected);
|
|
24
|
-
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
|
|
27
|
-
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /*
|
|
28
|
-
* Copyright 2018 Christian Howe
|
|
29
|
-
*
|
|
30
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
31
|
-
* you may not use this file except in compliance with the License.
|
|
32
|
-
* You may obtain a copy of the License at
|
|
33
|
-
*
|
|
34
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
-
*
|
|
36
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
37
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
-
* See the License for the specific language governing permissions and
|
|
40
|
-
* limitations under the License.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
var withStately = function withStately(props) {
|
|
44
|
-
return function (Component) {
|
|
45
|
-
var Wrapper = function Wrapper(_ref) {
|
|
46
|
-
var innerRef = _ref.innerRef,
|
|
47
|
-
rest = _objectWithoutProperties(_ref, ['innerRef']);
|
|
48
|
-
|
|
49
|
-
return _react2.default.createElement(_connected2.default, _extends({}, props, {
|
|
50
|
-
render: function render(update, state) {
|
|
51
|
-
return _react2.default.createElement(Component, _extends({ update: update, state: state }, rest));
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
Wrapper.displayName = 'WithStately(' + (Component.displayName || Component.name) + ')';
|
|
57
|
-
Wrapper.WrappedComponent = Component;
|
|
58
|
-
Wrapper.propTypes = {
|
|
59
|
-
innerRef: _propTypes2.default.func
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return (0, _hoistNonReactStatics2.default)(Wrapper, Component);
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
exports.default = withStately;
|