@enact/ui 4.6.0 → 4.6.1
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 +15 -0
- package/FloatingLayer/package.json +3 -0
- package/IconButton/IconButton.js +7 -2
- package/RadioDecorator/RadioControllerDecorator.js +6 -0
- package/RadioDecorator/RadioDecorator.js +5 -0
- package/Scroller/UiScrollerBase.js +6 -0
- package/SlotItem/SlotItem.js +6 -2
- package/ToggleItem/ToggleItem.js +6 -2
- package/Touchable/Pinch.js +185 -0
- package/Touchable/Touch.js +34 -11
- package/Touchable/Touchable.js +63 -4
- package/Touchable/config.js +19 -2
- package/Touchable/tests/Touchable-specs.js +96 -6
- package/Touchable/useTouch.js +41 -32
- package/VirtualList/UiVirtualListBase.js +6 -0
- package/package.json +2 -2
- package/AnnounceDecorator/AnnounceDecorator.d.ts +0 -64
- package/BodyText/BodyText.d.ts +0 -66
- package/Button/Button.d.ts +0 -125
- package/Cancelable/Cancelable.d.ts +0 -64
- package/Changeable/Changeable.d.ts +0 -54
- package/ComponentOverride/ComponentOverride.d.ts +0 -52
- package/ForwardRef/ForwardRef.d.ts +0 -22
- package/GridListImageItem/GridListImageItem.d.ts +0 -85
- package/Group/Group.d.ts +0 -107
- package/Heading/Heading.d.ts +0 -90
- package/Icon/Icon.d.ts +0 -88
- package/IconButton/IconButton.d.ts +0 -115
- package/Image/Image.d.ts +0 -113
- package/ImageItem/ImageItem.d.ts +0 -83
- package/Item/Item.d.ts +0 -64
- package/LabeledIcon/LabeledIcon.d.ts +0 -130
- package/Layout/Layout.d.ts +0 -247
- package/Marquee/index.d.ts +0 -258
- package/Measurable/Measurable.d.ts +0 -26
- package/Media/Media.d.ts +0 -99
- package/Placeholder/index.d.ts +0 -53
- package/ProgressBar/ProgressBar.d.ts +0 -92
- package/RadioDecorator/RadioDecorator.d.ts +0 -35
- package/Repeater/Repeater.d.ts +0 -83
- package/Resizable/Resizable.d.ts +0 -31
- package/Routable/Routable.d.ts +0 -148
- package/Scrollable/Scrollable.d.ts +0 -0
- package/Scroller/Scroller.d.ts +0 -276
- package/Skinnable/Skinnable.d.ts +0 -94
- package/Slider/Slider.d.ts +0 -202
- package/SlotItem/SlotItem.d.ts +0 -118
- package/Slottable/Slottable.d.ts +0 -22
- package/Spinner/Spinner.d.ts +0 -95
- package/ToggleIcon/ToggleIcon.d.ts +0 -90
- package/ToggleItem/ToggleItem.d.ts +0 -134
- package/Toggleable/Toggleable.d.ts +0 -103
- package/Touchable/Touchable.d.ts +0 -175
- package/Transition/Transition.d.ts +0 -196
- package/ViewManager/ViewManager.d.ts +0 -191
- package/VirtualList/VirtualList.d.ts +0 -530
- package/index.d.ts +0 -0
- package/internal/IdProvider/IdProvider.d.ts +0 -0
- package/internal/Pure/Pure.d.ts +0 -0
- package/internal/localized-fonts/localized-fonts.d.ts +0 -53
- package/internal/selection/selection.d.ts +0 -0
- package/internal/validators/validators.d.ts +0 -0
- package/resolution/index.d.ts +0 -187
- package/useControlledState/useControlledState.d.ts +0 -0
- package/useScroll/useScroll.d.ts +0 -0
package/Routable/Routable.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// Type definitions for ui/Routable
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
6
|
-
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
7
|
-
|
|
8
|
-
export interface LinkBaseProps {}
|
|
9
|
-
/**
|
|
10
|
-
* A base component that is used to make a link.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export class LinkBase extends React.Component<
|
|
14
|
-
Merge<React.HTMLProps<HTMLElement>, LinkBaseProps>
|
|
15
|
-
> {}
|
|
16
|
-
|
|
17
|
-
export interface RoutableConfig extends Object {
|
|
18
|
-
/**
|
|
19
|
-
* The event to listen to for path changes.
|
|
20
|
-
*
|
|
21
|
-
* This defines the actual name of the
|
|
22
|
-
property.
|
|
23
|
-
*/
|
|
24
|
-
navigate: string;
|
|
25
|
-
}
|
|
26
|
-
export interface RoutableProps {
|
|
27
|
-
/**
|
|
28
|
-
* Path to the active panel.
|
|
29
|
-
*
|
|
30
|
-
* May either be a URI-style path ( `'/app/home/settings'` ) or an array
|
|
31
|
-
of strings ( `['app', 'home', 'settings']` ).
|
|
32
|
-
*/
|
|
33
|
-
path: string | string[];
|
|
34
|
-
/**
|
|
35
|
-
* Called when navigating.
|
|
36
|
-
*
|
|
37
|
-
* The event object is decorated to add `path` .
|
|
38
|
-
*
|
|
39
|
-
* _NOTE_ : The actual name of this property is configured in the HOC config.
|
|
40
|
-
*/
|
|
41
|
-
navigate?: Function;
|
|
42
|
-
}
|
|
43
|
-
export function Routable<P>(
|
|
44
|
-
config: RoutableConfig,
|
|
45
|
-
Component: React.ComponentType<P> | string
|
|
46
|
-
): React.ComponentType<P & RoutableProps>;
|
|
47
|
-
|
|
48
|
-
export function Routable<P>(
|
|
49
|
-
Component: React.ComponentType<P> | string
|
|
50
|
-
): React.ComponentType<P & RoutableProps>;
|
|
51
|
-
|
|
52
|
-
export interface LinkProps extends Merge<LinkBaseProps, LinkableProps> {
|
|
53
|
-
/**
|
|
54
|
-
* The `path` to navigate that matches the path of the container.
|
|
55
|
-
*/
|
|
56
|
-
path: string;
|
|
57
|
-
/**
|
|
58
|
-
* Applies a disabled style and the control becomes non-interactive.
|
|
59
|
-
*/
|
|
60
|
-
disabled?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A component that is used to make a link to navigate among components.
|
|
64
|
-
*
|
|
65
|
-
* In the following example, `Sample` would render `Main` with two Links for `About` and `FAQ` .
|
|
66
|
-
If `About` is clicked, the content of `About` would be displayed under `Main` .
|
|
67
|
-
*
|
|
68
|
-
* Example:
|
|
69
|
-
* ```
|
|
70
|
-
const Views = Routable({navigate: 'onNavigate'}, ({children}) => <div>{children}</div>);
|
|
71
|
-
|
|
72
|
-
const Main = () => (
|
|
73
|
-
<div>
|
|
74
|
-
<Link path="./about">About</Link>
|
|
75
|
-
<Link path="./faq">FAQ</Link>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const About = () => (<div>Greetings! We are Enact team.</div>);
|
|
80
|
-
|
|
81
|
-
const Faq = () => (<div>List of FAQ</div>);
|
|
82
|
-
|
|
83
|
-
const Sample = (props) => {
|
|
84
|
-
// use 'main' for the default path
|
|
85
|
-
const [path, nav] = useState('main');
|
|
86
|
-
// if onNavigate is called with a new path, update the state
|
|
87
|
-
const handleNavigate = useCallback((ev) => nav(ev.path), [nav]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Views {...props} path={path} onNavigate={handleNavigate}>
|
|
91
|
-
<Route path="main" component={Main}>
|
|
92
|
-
<Route path="about" component={About} />
|
|
93
|
-
<Route path="faq" component={Faq} />
|
|
94
|
-
</Route>
|
|
95
|
-
</Views>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
```
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
export class Link extends React.Component<
|
|
102
|
-
Merge<React.HTMLProps<HTMLElement>, LinkProps>
|
|
103
|
-
> {}
|
|
104
|
-
|
|
105
|
-
export interface RouteProps {
|
|
106
|
-
/**
|
|
107
|
-
* The component to render when the `path` for this Route matches the path of the
|
|
108
|
-
container.
|
|
109
|
-
*/
|
|
110
|
-
component: string | React.ComponentType;
|
|
111
|
-
/**
|
|
112
|
-
* The name of the path segment.
|
|
113
|
-
*/
|
|
114
|
-
path: string;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Used with to define the `path` segment and the
|
|
118
|
-
`component` to render.
|
|
119
|
-
*
|
|
120
|
-
* `Route` elements can be nested to build multiple level paths.
|
|
121
|
-
*
|
|
122
|
-
* In the below example, `Panels` would render `SettingsPanel` with breadcrumbs to
|
|
123
|
-
navigate `AppPanel` and `HomePanel` .
|
|
124
|
-
*
|
|
125
|
-
* Example:
|
|
126
|
-
* ```
|
|
127
|
-
<Panels path="/app/home/settings" onSelectBreadcrumb={this.handleNavigate}>
|
|
128
|
-
<Route path="app" component={AppPanel}>
|
|
129
|
-
<Route path="home" component={HomePanel}>
|
|
130
|
-
<Route path="settings" component={SettingsPanel} />
|
|
131
|
-
</Route>
|
|
132
|
-
</Route>
|
|
133
|
-
<Route path="admin" component={AdminPanel} />
|
|
134
|
-
<Route path="help" component={HelpPanel} />
|
|
135
|
-
</Panels>
|
|
136
|
-
```
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
export class Route extends React.Component<
|
|
140
|
-
Merge<React.HTMLProps<HTMLElement>, RouteProps>
|
|
141
|
-
> {}
|
|
142
|
-
|
|
143
|
-
export interface LinkableProps {}
|
|
144
|
-
export function Linkable<P>(
|
|
145
|
-
Component: React.ComponentType<P> | string
|
|
146
|
-
): React.ComponentType<P & LinkableProps>;
|
|
147
|
-
|
|
148
|
-
export default Routable;
|
|
File without changes
|
package/Scroller/Scroller.d.ts
DELETED
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
// Type definitions for ui/Scroller
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
6
|
-
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
7
|
-
|
|
8
|
-
export interface ScrollerBasicProps {
|
|
9
|
-
/**
|
|
10
|
-
* Direction of the scroller.
|
|
11
|
-
*
|
|
12
|
-
* Valid values are:
|
|
13
|
-
* * `'both'` ,
|
|
14
|
-
* * `'horizontal'` , and
|
|
15
|
-
* * `'vertical'` .
|
|
16
|
-
*/
|
|
17
|
-
direction?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* An unstyled base scroller component.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export class ScrollerBasic extends React.Component<
|
|
24
|
-
Merge<React.HTMLProps<HTMLElement>, ScrollerBasicProps>
|
|
25
|
-
> {}
|
|
26
|
-
|
|
27
|
-
export interface ScrollerBaseProps {
|
|
28
|
-
/**
|
|
29
|
-
* A callback function that receives a reference to the `scrollTo` feature.
|
|
30
|
-
*
|
|
31
|
-
* Once received, the `scrollTo` method can be called as an imperative interface.
|
|
32
|
-
*
|
|
33
|
-
* The `scrollTo` function accepts the following parameters:
|
|
34
|
-
* * {position: {x, y}} - Pixel value for x and/or y position
|
|
35
|
-
* * {align} - Where the scroll area should be aligned. Values are:
|
|
36
|
-
`'left'` , `'right'` , `'top'` , `'bottom'` ,
|
|
37
|
-
`'topleft'` , `'topright'` , `'bottomleft'` , and `'bottomright'` .
|
|
38
|
-
* * {node} - Node to scroll into view
|
|
39
|
-
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
40
|
-
animation occurs.
|
|
41
|
-
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
42
|
-
by `index` or `node` .
|
|
43
|
-
*
|
|
44
|
-
* Note: Only specify one of: `position` , `align` , `index` or `node`
|
|
45
|
-
*
|
|
46
|
-
* Example:
|
|
47
|
-
* ```
|
|
48
|
-
// If you set cbScrollTo prop like below;
|
|
49
|
-
cbScrollTo: (fn) => {this.scrollTo = fn;}
|
|
50
|
-
// You can simply call like below;
|
|
51
|
-
this.scrollTo({align: 'top'}); // scroll to the top
|
|
52
|
-
```
|
|
53
|
-
*/
|
|
54
|
-
cbScrollTo?: Function;
|
|
55
|
-
/**
|
|
56
|
-
* Direction of the scroller.
|
|
57
|
-
*
|
|
58
|
-
* Valid values are:
|
|
59
|
-
* * `'both'` ,
|
|
60
|
-
* * `'horizontal'` , and
|
|
61
|
-
* * `'vertical'` .
|
|
62
|
-
*/
|
|
63
|
-
direction?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Specifies how to show horizontal scrollbar.
|
|
66
|
-
*
|
|
67
|
-
* Valid values are:
|
|
68
|
-
* * `'auto'` ,
|
|
69
|
-
* * `'visible'` , and
|
|
70
|
-
* * `'hidden'` .
|
|
71
|
-
*/
|
|
72
|
-
horizontalScrollbar?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Prevents scroll by wheeling on the scroller.
|
|
75
|
-
*/
|
|
76
|
-
noScrollByWheel?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Called when scrolling.
|
|
79
|
-
*
|
|
80
|
-
* Passes `scrollLeft` and `scrollTop` .
|
|
81
|
-
It is not recommended to set this prop since it can cause performance degradation.
|
|
82
|
-
Use `onScrollStart` or `onScrollStop` instead.
|
|
83
|
-
*/
|
|
84
|
-
onScroll?: Function;
|
|
85
|
-
/**
|
|
86
|
-
* Called when scroll starts.
|
|
87
|
-
*
|
|
88
|
-
* Passes `scrollLeft` and `scrollTop` .
|
|
89
|
-
*
|
|
90
|
-
* Example:
|
|
91
|
-
* ```
|
|
92
|
-
onScrollStart = ({scrollLeft, scrollTop}) => {
|
|
93
|
-
// do something with scrollLeft and scrollTop
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
render = () => (
|
|
97
|
-
<Scroller
|
|
98
|
-
...
|
|
99
|
-
onScrollStart={this.onScrollStart}
|
|
100
|
-
...
|
|
101
|
-
/>
|
|
102
|
-
)
|
|
103
|
-
```
|
|
104
|
-
*/
|
|
105
|
-
onScrollStart?: Function;
|
|
106
|
-
/**
|
|
107
|
-
* Called when scroll stops.
|
|
108
|
-
*
|
|
109
|
-
* Passes `scrollLeft` and `scrollTop` .
|
|
110
|
-
*
|
|
111
|
-
* Example:
|
|
112
|
-
* ```
|
|
113
|
-
onScrollStop = ({scrollLeft, scrollTop}) => {
|
|
114
|
-
// do something with scrollLeft and scrollTop
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
render = () => (
|
|
118
|
-
<Scroller
|
|
119
|
-
...
|
|
120
|
-
onScrollStop={this.onScrollStop}
|
|
121
|
-
...
|
|
122
|
-
/>
|
|
123
|
-
)
|
|
124
|
-
```
|
|
125
|
-
*/
|
|
126
|
-
onScrollStop?: Function;
|
|
127
|
-
/**
|
|
128
|
-
* Specifies how to show vertical scrollbar.
|
|
129
|
-
*
|
|
130
|
-
* Valid values are:
|
|
131
|
-
* * `'auto'` ,
|
|
132
|
-
* * `'visible'` , and
|
|
133
|
-
* * `'hidden'` .
|
|
134
|
-
*/
|
|
135
|
-
verticalScrollbar?: string;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* An unstyled base scroller component.
|
|
139
|
-
*
|
|
140
|
-
* In most circumstances, you will want to use the Scrollable version.
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
export class ScrollerBase extends React.Component<
|
|
144
|
-
Merge<React.HTMLProps<HTMLElement>, ScrollerBaseProps>
|
|
145
|
-
> {}
|
|
146
|
-
|
|
147
|
-
export interface ScrollerProps extends ScrollerBasicProps {
|
|
148
|
-
/**
|
|
149
|
-
* A callback function that receives a reference to the `scrollTo` feature.
|
|
150
|
-
*
|
|
151
|
-
* Once received, the `scrollTo` method can be called as an imperative interface.
|
|
152
|
-
* * {position: {x, y}} - Pixel value for x and/or y position
|
|
153
|
-
* * {align} - Where the scroll area should be aligned. Values are:
|
|
154
|
-
`'left'` , `'right'` , `'top'` , `'bottom'` ,
|
|
155
|
-
`'topleft'` , `'topright'` , `'bottomleft'` , and `'bottomright'` .
|
|
156
|
-
* * {node} - Node to scroll into view
|
|
157
|
-
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
158
|
-
animation occurs.
|
|
159
|
-
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
160
|
-
by `node` .
|
|
161
|
-
*
|
|
162
|
-
* Note: Only specify one of: `position` , `align` , `node`
|
|
163
|
-
*
|
|
164
|
-
* Example:
|
|
165
|
-
* ```
|
|
166
|
-
// If you set cbScrollTo prop like below;
|
|
167
|
-
cbScrollTo: (fn) => {this.scrollTo = fn;}
|
|
168
|
-
// You can simply call like below;
|
|
169
|
-
this.scrollTo({align: 'top'}); // scroll to the top
|
|
170
|
-
```
|
|
171
|
-
*/
|
|
172
|
-
cbScrollTo?: Function;
|
|
173
|
-
/**
|
|
174
|
-
* Direction of the scroller.
|
|
175
|
-
*
|
|
176
|
-
* Valid values are:
|
|
177
|
-
* * `'both'` ,
|
|
178
|
-
* * `'horizontal'` , and
|
|
179
|
-
* * `'vertical'` .
|
|
180
|
-
*/
|
|
181
|
-
direction?: string;
|
|
182
|
-
/**
|
|
183
|
-
* Specifies how to show horizontal scrollbar.
|
|
184
|
-
*
|
|
185
|
-
* Valid values are:
|
|
186
|
-
* * `'auto'` ,
|
|
187
|
-
* * `'visible'` , and
|
|
188
|
-
* * `'hidden'` .
|
|
189
|
-
*/
|
|
190
|
-
horizontalScrollbar?: string;
|
|
191
|
-
/**
|
|
192
|
-
* Prevents scroll by wheeling on the scroller.
|
|
193
|
-
*/
|
|
194
|
-
noScrollByWheel?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Called when scrolling.
|
|
197
|
-
*
|
|
198
|
-
* Passes `scrollLeft` , `scrollTop` .
|
|
199
|
-
It is not recommended to set this prop since it can cause performance degradation.
|
|
200
|
-
Use `onScrollStart` or `onScrollStop` instead.
|
|
201
|
-
*/
|
|
202
|
-
onScroll?: Function;
|
|
203
|
-
/**
|
|
204
|
-
* Called when scroll starts.
|
|
205
|
-
*
|
|
206
|
-
* Passes `scrollLeft` and `scrollTop` .
|
|
207
|
-
*
|
|
208
|
-
* Example:
|
|
209
|
-
* ```
|
|
210
|
-
onScrollStart = ({scrollLeft, scrollTop}) => {
|
|
211
|
-
// do something with scrollLeft and scrollTop
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
render = () => (
|
|
215
|
-
<Scroller
|
|
216
|
-
...
|
|
217
|
-
onScrollStart={this.onScrollStart}
|
|
218
|
-
...
|
|
219
|
-
/>
|
|
220
|
-
)
|
|
221
|
-
```
|
|
222
|
-
*/
|
|
223
|
-
onScrollStart?: Function;
|
|
224
|
-
/**
|
|
225
|
-
* Called when scroll stops.
|
|
226
|
-
*
|
|
227
|
-
* Passes `scrollLeft` and `scrollTop` .
|
|
228
|
-
*
|
|
229
|
-
* Example:
|
|
230
|
-
* ```
|
|
231
|
-
onScrollStop = ({scrollLeft, scrollTop}) => {
|
|
232
|
-
// do something with scrollLeft and scrollTop
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
render = () => (
|
|
236
|
-
<Scroller
|
|
237
|
-
...
|
|
238
|
-
onScrollStop={this.onScrollStop}
|
|
239
|
-
...
|
|
240
|
-
/>
|
|
241
|
-
)
|
|
242
|
-
```
|
|
243
|
-
*/
|
|
244
|
-
onScrollStop?: Function;
|
|
245
|
-
/**
|
|
246
|
-
* Specifies how to scroll.
|
|
247
|
-
*
|
|
248
|
-
* Valid values are:
|
|
249
|
-
* * `'translate'` ,
|
|
250
|
-
* * `'native'` .
|
|
251
|
-
*/
|
|
252
|
-
scrollMode?: string;
|
|
253
|
-
/**
|
|
254
|
-
* Specifies how to show vertical scrollbar.
|
|
255
|
-
*
|
|
256
|
-
* Valid values are:
|
|
257
|
-
* * `'auto'` ,
|
|
258
|
-
* * `'visible'` , and
|
|
259
|
-
* * `'hidden'` .
|
|
260
|
-
*/
|
|
261
|
-
verticalScrollbar?: string;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* An unstyled scroller.
|
|
265
|
-
*
|
|
266
|
-
* Example:
|
|
267
|
-
* ```
|
|
268
|
-
<Scroller>Scroll me.</Scroller>
|
|
269
|
-
```
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
export class Scroller extends React.Component<
|
|
273
|
-
Merge<React.HTMLProps<HTMLElement>, ScrollerProps>
|
|
274
|
-
> {}
|
|
275
|
-
|
|
276
|
-
export default Scroller;
|
package/Skinnable/Skinnable.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Type definitions for ui/Skinnable
|
|
2
|
-
|
|
3
|
-
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
4
|
-
type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
5
|
-
|
|
6
|
-
export interface SkinnableConfig extends Object {
|
|
7
|
-
/**
|
|
8
|
-
* The prop in which to pass the skinVariants value to the wrapped component. The recommended
|
|
9
|
-
value is "skinVariants".
|
|
10
|
-
*
|
|
11
|
-
* If left unset, the skinVariant will not be passed to the wrapped component.
|
|
12
|
-
*/
|
|
13
|
-
variantsProp?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The prop in which to pass the effective skin to the wrapped component.
|
|
16
|
-
*
|
|
17
|
-
* If left unset, the current skin will not be passed to the wrapped component.
|
|
18
|
-
*/
|
|
19
|
-
prop?: string;
|
|
20
|
-
/**
|
|
21
|
-
* A hash mapping the available skin names to their CSS class name.
|
|
22
|
-
*
|
|
23
|
-
* The keys are accepted as the only valid values for the `skin` prop on the wrapped component.
|
|
24
|
-
*/
|
|
25
|
-
skins?: object;
|
|
26
|
-
/**
|
|
27
|
-
* Assign a default skin from the `skins` list.
|
|
28
|
-
*
|
|
29
|
-
* This will be used if the instantiator of the wrapped component provides no value to the
|
|
30
|
-
`skin` prop.
|
|
31
|
-
*/
|
|
32
|
-
defaultSkin?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Initial collection of applied variants
|
|
35
|
-
*
|
|
36
|
-
* This will be used if the instantiator of the wrapped component provides no value to the
|
|
37
|
-
`skinVariants` prop.
|
|
38
|
-
*/
|
|
39
|
-
defaultVariants?: string | string[];
|
|
40
|
-
/**
|
|
41
|
-
* A complete list of all supported variants.
|
|
42
|
-
*
|
|
43
|
-
* These will translate to CSS class names so should not conflict with any skin names.
|
|
44
|
-
CamelCase is recommended for the values.
|
|
45
|
-
*/
|
|
46
|
-
allowedVariants?: string[];
|
|
47
|
-
}
|
|
48
|
-
export interface SkinnableProps {
|
|
49
|
-
/**
|
|
50
|
-
* The name of the skin a component should use to render itself. Available skins are
|
|
51
|
-
defined in the "defaultConfig" for this HOC.
|
|
52
|
-
*/
|
|
53
|
-
skin?: string;
|
|
54
|
-
/**
|
|
55
|
-
* The variant(s) on a skin that a component should use when rendering. These will
|
|
56
|
-
typically alter the appearance of a skin's existing definition in a way that does not
|
|
57
|
-
override that skin's general styling.
|
|
58
|
-
*
|
|
59
|
-
* Multiple data types are supported by this prop, which afford different conveniences
|
|
60
|
-
and abilities. String and Array are effectively the same, supporting just additions
|
|
61
|
-
to the variants being applied to a component, and are much more convenient. Objects
|
|
62
|
-
may also be used, and have the ability to disable variants being passed by their
|
|
63
|
-
ancestors. Objects take the format of a basic hash, with variants as key names and
|
|
64
|
-
true/false Booleans as values, depicting their state. If a variant is excluded from
|
|
65
|
-
any version of data type used to set this prop, that variant will ignored, falling
|
|
66
|
-
back to the defaultVariant or parent variant, in that order.
|
|
67
|
-
*
|
|
68
|
-
* skinVariants examples:
|
|
69
|
-
* ```
|
|
70
|
-
// String
|
|
71
|
-
skinVariants="highContrast"
|
|
72
|
-
|
|
73
|
-
// Array
|
|
74
|
-
skinVariants={['highContrast']}
|
|
75
|
-
|
|
76
|
-
// Object
|
|
77
|
-
skinVariants={{
|
|
78
|
-
highContrast: true,
|
|
79
|
-
grayscale: false
|
|
80
|
-
}}
|
|
81
|
-
```
|
|
82
|
-
*/
|
|
83
|
-
skinVariants?: string | string[] | object;
|
|
84
|
-
}
|
|
85
|
-
export function Skinnable<P>(
|
|
86
|
-
config: SkinnableConfig,
|
|
87
|
-
Component: React.ComponentType<P> | string
|
|
88
|
-
): React.ComponentType<P & SkinnableProps>;
|
|
89
|
-
|
|
90
|
-
export function Skinnable<P>(
|
|
91
|
-
Component: React.ComponentType<P> | string
|
|
92
|
-
): React.ComponentType<P & SkinnableProps>;
|
|
93
|
-
|
|
94
|
-
export default Skinnable;
|