react-input-material 0.0.352 → 0.0.356
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/components/Dummy.d.ts +9 -5
- package/components/Dummy.tsx +11 -6
- package/components/FileInput.d.ts +3 -2
- package/components/FileInput.js +1 -1
- package/components/FileInput.module.css +12 -24
- package/components/FileInput.styles.css +3 -3
- package/components/FileInput.tsx +239 -203
- package/components/GenericAnimate.d.ts +3 -0
- package/components/GenericAnimate.module.css +0 -1
- package/components/GenericAnimate.tsx +17 -10
- package/components/GenericInput.d.ts +26 -2
- package/components/GenericInput.js +1 -1
- package/components/GenericInput.module.css +32 -45
- package/components/GenericInput.styles.css +1 -1
- package/components/GenericInput.tsx +471 -348
- package/components/Inputs.d.ts +3 -3
- package/components/Inputs.js +1 -1
- package/components/Inputs.module.css +10 -9
- package/components/Inputs.styles.css +2 -2
- package/components/Inputs.tsx +20 -21
- package/components/Interval.d.ts +4 -6
- package/components/Interval.js +1 -1
- package/components/Interval.module.css +16 -15
- package/components/Interval.styles.css +2 -2
- package/components/Interval.tsx +7 -13
- package/components/RequireableCheckbox.d.ts +10 -3
- package/components/RequireableCheckbox.js +1 -1
- package/components/RequireableCheckbox.module.css +4 -4
- package/components/RequireableCheckbox.styles.css +1 -1
- package/components/RequireableCheckbox.tsx +66 -51
- package/components/WrapConfigurations.d.ts +13 -0
- package/components/WrapConfigurations.tsx +17 -5
- package/components/WrapStrict.d.ts +6 -0
- package/components/WrapStrict.tsx +7 -0
- package/components/WrapThemeProvider.d.ts +7 -5
- package/components/WrapThemeProvider.tsx +8 -5
- package/components/WrapTooltip.d.ts +4 -2
- package/components/WrapTooltip.tsx +14 -6
- package/helper.d.ts +39 -9
- package/helper.js +1 -1
- package/index.js +1 -1
- package/index.styles.css +10 -10
- package/package.json +36 -28
- package/readme.md +38 -2
- package/type.d.ts +42 -42
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
// region imports
|
|
20
20
|
import Tools from 'clientnode'
|
|
21
|
-
import {FirstParameter} from 'clientnode/type'
|
|
22
21
|
import {
|
|
23
22
|
FocusEvent as ReactFocusEvent,
|
|
24
23
|
forwardRef,
|
|
@@ -27,7 +26,6 @@ import {
|
|
|
27
26
|
MouseEvent as ReactMouseEvent,
|
|
28
27
|
MutableRefObject,
|
|
29
28
|
ReactElement,
|
|
30
|
-
RefCallback,
|
|
31
29
|
SyntheticEvent,
|
|
32
30
|
useImperativeHandle,
|
|
33
31
|
useRef,
|
|
@@ -56,10 +54,8 @@ import {
|
|
|
56
54
|
} from '../helper'
|
|
57
55
|
import {
|
|
58
56
|
CheckboxAdapter as Adapter,
|
|
59
|
-
CheckboxModel as Model,
|
|
60
57
|
CheckboxProperties as Properties,
|
|
61
58
|
CheckboxProps as Props,
|
|
62
|
-
CheckboxState as State,
|
|
63
59
|
defaultModelState,
|
|
64
60
|
DefaultCheckboxProperties as DefaultProperties,
|
|
65
61
|
defaultCheckboxProperties as defaultProperties,
|
|
@@ -70,6 +66,13 @@ import {
|
|
|
70
66
|
} from '../type'
|
|
71
67
|
// endregion
|
|
72
68
|
// region helper
|
|
69
|
+
/**
|
|
70
|
+
* Derives validation state from provided properties and state.
|
|
71
|
+
* @param properties - Current component properties.
|
|
72
|
+
* @param currentState - Current component state.
|
|
73
|
+
*
|
|
74
|
+
* @returns Whether component is in an aggregated valid or invalid state.
|
|
75
|
+
*/
|
|
73
76
|
export function determineValidationState(
|
|
74
77
|
properties:DefaultProperties, currentState:Partial<ModelState>
|
|
75
78
|
):boolean {
|
|
@@ -86,7 +89,6 @@ export function determineValidationState(
|
|
|
86
89
|
// endregion
|
|
87
90
|
/**
|
|
88
91
|
* Validateable checkbox wrapper component.
|
|
89
|
-
*
|
|
90
92
|
* @property static:displayName - Descriptive name for component to show in web
|
|
91
93
|
* developer tools.
|
|
92
94
|
*
|
|
@@ -102,12 +104,12 @@ export function determineValidationState(
|
|
|
102
104
|
* 4. All state changes except selection changes trigger an "onChange" event
|
|
103
105
|
* which delivers the consolidated properties object (with latest
|
|
104
106
|
* modifications included).
|
|
105
|
-
*
|
|
106
107
|
* @property static:displayName - Descriptive name for component to show in web
|
|
107
108
|
* developer tools.
|
|
108
109
|
*
|
|
109
110
|
* @param props - Given components properties.
|
|
110
111
|
* @param reference - Reference object to forward internal state.
|
|
112
|
+
*
|
|
111
113
|
* @returns React elements.
|
|
112
114
|
*/
|
|
113
115
|
export const RequireableCheckboxInner = function(
|
|
@@ -117,12 +119,14 @@ export const RequireableCheckboxInner = function(
|
|
|
117
119
|
/**
|
|
118
120
|
* Calculate external properties (a set of all configurable properties).
|
|
119
121
|
* @param properties - Properties to merge.
|
|
122
|
+
*
|
|
120
123
|
* @returns External properties object.
|
|
121
124
|
*/
|
|
122
125
|
const getConsolidatedProperties = (properties:Props):Properties => {
|
|
123
|
-
let result:DefaultProperties =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
let result:DefaultProperties =
|
|
127
|
+
mapPropertiesIntoModel<Props, DefaultProperties>(
|
|
128
|
+
properties, RequireableCheckbox.defaultProperties.model
|
|
129
|
+
)
|
|
126
130
|
|
|
127
131
|
determineValidationState(result, result.model.state)
|
|
128
132
|
|
|
@@ -137,12 +141,13 @@ export const RequireableCheckboxInner = function(
|
|
|
137
141
|
/**
|
|
138
142
|
* Triggered on blur events.
|
|
139
143
|
* @param event - Event object.
|
|
144
|
+
*
|
|
140
145
|
* @returns Nothing.
|
|
141
146
|
*/
|
|
142
147
|
const onBlur = (event:SyntheticEvent):void => setValueState((
|
|
143
148
|
oldValueState:ValueState
|
|
144
149
|
):ValueState => {
|
|
145
|
-
let changed
|
|
150
|
+
let changed = false
|
|
146
151
|
|
|
147
152
|
if (oldValueState.modelState.focused) {
|
|
148
153
|
properties.focused = false
|
|
@@ -179,6 +184,7 @@ export const RequireableCheckboxInner = function(
|
|
|
179
184
|
* Triggered on any change events. Consolidates properties object and
|
|
180
185
|
* triggers given on change callbacks.
|
|
181
186
|
* @param event - Potential event object.
|
|
187
|
+
*
|
|
182
188
|
* @returns Nothing.
|
|
183
189
|
*/
|
|
184
190
|
const onChange = (event?:SyntheticEvent):void => {
|
|
@@ -201,6 +207,7 @@ export const RequireableCheckboxInner = function(
|
|
|
201
207
|
/**
|
|
202
208
|
* Triggered when ever the value changes.
|
|
203
209
|
* @param event - Event object.
|
|
210
|
+
*
|
|
204
211
|
* @returns Nothing.
|
|
205
212
|
*/
|
|
206
213
|
const onChangeValue = (event:SyntheticEvent):void => {
|
|
@@ -215,7 +222,7 @@ export const RequireableCheckboxInner = function(
|
|
|
215
222
|
if (oldValueState.value === properties.value)
|
|
216
223
|
return oldValueState
|
|
217
224
|
|
|
218
|
-
let stateChanged
|
|
225
|
+
let stateChanged = false
|
|
219
226
|
|
|
220
227
|
const result:ValueState =
|
|
221
228
|
{...oldValueState, value: properties.value as boolean|null}
|
|
@@ -259,6 +266,7 @@ export const RequireableCheckboxInner = function(
|
|
|
259
266
|
/**
|
|
260
267
|
* Triggered on click events.
|
|
261
268
|
* @param event - Mouse event object.
|
|
269
|
+
*
|
|
262
270
|
* @returns Nothing.
|
|
263
271
|
*/
|
|
264
272
|
const onClick = (event:ReactMouseEvent):void => {
|
|
@@ -271,6 +279,7 @@ export const RequireableCheckboxInner = function(
|
|
|
271
279
|
/**
|
|
272
280
|
* Triggered on focus events.
|
|
273
281
|
* @param event - Focus event object.
|
|
282
|
+
*
|
|
274
283
|
* @returns Nothing.
|
|
275
284
|
*/
|
|
276
285
|
const onFocus = (event:ReactFocusEvent):void => {
|
|
@@ -283,11 +292,12 @@ export const RequireableCheckboxInner = function(
|
|
|
283
292
|
/**
|
|
284
293
|
* Triggers on start interacting with the input.
|
|
285
294
|
* @param event - Event object which triggered interaction.
|
|
295
|
+
*
|
|
286
296
|
* @returns Nothing.
|
|
287
297
|
*/
|
|
288
298
|
const onTouch = (event:ReactFocusEvent|ReactMouseEvent):void =>
|
|
289
299
|
setValueState((oldValueState:ValueState):ValueState => {
|
|
290
|
-
let changedState
|
|
300
|
+
let changedState = false
|
|
291
301
|
|
|
292
302
|
if (!oldValueState.modelState.focused) {
|
|
293
303
|
properties.focused = true
|
|
@@ -335,7 +345,7 @@ export const RequireableCheckboxInner = function(
|
|
|
335
345
|
|
|
336
346
|
const initialValue:boolean|null = determineInitialValue<boolean>(
|
|
337
347
|
givenProps,
|
|
338
|
-
RequireableCheckbox.defaultProperties.model
|
|
348
|
+
RequireableCheckbox.defaultProperties.model.default,
|
|
339
349
|
givenProps.checked
|
|
340
350
|
)
|
|
341
351
|
/*
|
|
@@ -386,6 +396,7 @@ export const RequireableCheckboxInner = function(
|
|
|
386
396
|
setValueState =
|
|
387
397
|
wrapStateSetter<ValueState>(setValueState, currentValueState)
|
|
388
398
|
// endregion
|
|
399
|
+
// region export references
|
|
389
400
|
useImperativeHandle(
|
|
390
401
|
reference,
|
|
391
402
|
():Adapter & {
|
|
@@ -411,45 +422,48 @@ export const RequireableCheckboxInner = function(
|
|
|
411
422
|
strict={RequireableCheckbox.strict}
|
|
412
423
|
themeConfiguration={properties.themeConfiguration}
|
|
413
424
|
tooltip={properties.tooltip}
|
|
414
|
-
><div
|
|
415
|
-
className={[styles['requireable-checkbox']]
|
|
416
|
-
.concat(properties.className ?? [])
|
|
417
|
-
.join(' ')
|
|
418
|
-
}
|
|
419
|
-
style={properties.styles}
|
|
420
425
|
>
|
|
421
|
-
<
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
id={properties.id || properties.name}
|
|
426
|
-
indeterminate={properties.value === null}
|
|
427
|
-
inputRef={inputReference}
|
|
428
|
-
label={(
|
|
429
|
-
properties.invalid &&
|
|
430
|
-
(
|
|
431
|
-
properties.showInitialValidationState ||
|
|
432
|
-
/*
|
|
433
|
-
Material inputs show their validation state at least
|
|
434
|
-
after a blur event so we synchronize error appearances.
|
|
435
|
-
*/
|
|
436
|
-
properties.visited
|
|
437
|
-
)
|
|
438
|
-
) ?
|
|
439
|
-
<Theme use="error">
|
|
440
|
-
{properties.description || properties.name}
|
|
441
|
-
</Theme> :
|
|
442
|
-
properties.description || properties.name
|
|
426
|
+
<div
|
|
427
|
+
className={[styles['requireable-checkbox']]
|
|
428
|
+
.concat(properties.className ?? [])
|
|
429
|
+
.join(' ')
|
|
443
430
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
431
|
+
style={properties.styles}
|
|
432
|
+
>
|
|
433
|
+
<Checkbox
|
|
434
|
+
checked={Boolean(properties.value)}
|
|
435
|
+
disabled={properties.disabled}
|
|
436
|
+
foundationRef={foundationRef}
|
|
437
|
+
id={properties.id || properties.name}
|
|
438
|
+
indeterminate={properties.value === null}
|
|
439
|
+
inputRef={inputReference}
|
|
440
|
+
label={(
|
|
441
|
+
properties.invalid &&
|
|
442
|
+
(
|
|
443
|
+
properties.showInitialValidationState ||
|
|
444
|
+
/*
|
|
445
|
+
Material inputs show their validation state at
|
|
446
|
+
least after a blur event so we synchronize error
|
|
447
|
+
appearances.
|
|
448
|
+
*/
|
|
449
|
+
properties.visited
|
|
450
|
+
)
|
|
451
|
+
) ?
|
|
452
|
+
<Theme use="error">
|
|
453
|
+
{properties.description || properties.name}
|
|
454
|
+
</Theme> :
|
|
455
|
+
properties.description || properties.name
|
|
456
|
+
}
|
|
457
|
+
name={properties.name}
|
|
458
|
+
onBlur={onBlur}
|
|
459
|
+
onChange={onChangeValue}
|
|
460
|
+
onClick={onClick}
|
|
461
|
+
onFocus={onFocus}
|
|
462
|
+
ripple={properties.ripple}
|
|
463
|
+
value={`${properties.value as unknown as string}`}
|
|
464
|
+
/>
|
|
465
|
+
</div>
|
|
466
|
+
</WrapConfigurations>
|
|
453
467
|
// endregion
|
|
454
468
|
} as ForwardRefRenderFunction<Adapter, Props>
|
|
455
469
|
// NOTE: This is useful in react dev tools.
|
|
@@ -458,13 +472,14 @@ RequireableCheckboxInner.displayName = 'RequireableCheckbox'
|
|
|
458
472
|
* Wrapping web component compatible react component.
|
|
459
473
|
* @property static:defaultModelState - Initial model state.
|
|
460
474
|
* @property static:defaultProperties - Initial property configuration.
|
|
461
|
-
* @property static:propTypes - Triggers reacts runtime property value checks
|
|
475
|
+
* @property static:propTypes - Triggers reacts runtime property value checks.
|
|
462
476
|
* @property static:strict - Indicates whether we should wrap render output in
|
|
463
477
|
* reacts strict component.
|
|
464
478
|
* @property static:wrapped - Wrapped component.
|
|
465
479
|
*
|
|
466
480
|
* @param props - Given components properties.
|
|
467
481
|
* @param reference - Reference object to forward internal state.
|
|
482
|
+
*
|
|
468
483
|
* @returns React elements.
|
|
469
484
|
*/
|
|
470
485
|
export const RequireableCheckbox:CheckboxComponent =
|
|
@@ -5,6 +5,7 @@ import { ConfigurationProperties } from '../type';
|
|
|
5
5
|
/**
|
|
6
6
|
* Wraps a theme provider, strict wrapper and tooltip to given element if
|
|
7
7
|
* corresponding configurations are provided.
|
|
8
|
+
* @param properties - Component provided properties.
|
|
8
9
|
* @param properties.children - Component or string to wrap.
|
|
9
10
|
* @param properties.strict - Indicates whether to render in strict mode.
|
|
10
11
|
* @param properties.themeConfiguration - Optional theme configurations.
|
|
@@ -12,11 +13,23 @@ import { ConfigurationProperties } from '../type';
|
|
|
12
13
|
* @param properties.wrap - Instead of injecting a div tag, wrap a child
|
|
13
14
|
* component by merging the theme styles directly onto it. Useful when you
|
|
14
15
|
* don't want to mess with layout.
|
|
16
|
+
*
|
|
15
17
|
* @returns Wrapped content.
|
|
16
18
|
*/
|
|
17
19
|
export declare const WrapConfigurations: FunctionComponent<ConfigurationProperties & {
|
|
18
20
|
children: ReactElement;
|
|
19
21
|
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Component factory to dynamically create a wrapped component.
|
|
24
|
+
* @param WrappedComponent - Component to wrap.
|
|
25
|
+
* @param options - Options configure wrapping.
|
|
26
|
+
* @param options.withReference - Indicates whether to add a mutable reference
|
|
27
|
+
* to wrapping component.
|
|
28
|
+
* @param options.withThemeWrapper - Indicates whether all theme configurations
|
|
29
|
+
* should be provided.
|
|
30
|
+
*
|
|
31
|
+
* @returns Created wrapped component.
|
|
32
|
+
*/
|
|
20
33
|
export declare function createWrapConfigurationsComponent<Type extends AnyFunction = AnyFunction, Reference = unknown>(WrappedComponent: Type, options?: {
|
|
21
34
|
withReference?: boolean | null;
|
|
22
35
|
withThemeWrapper?: boolean;
|
|
@@ -19,24 +19,24 @@
|
|
|
19
19
|
// region imports
|
|
20
20
|
import {AnyFunction, FirstParameter} from 'clientnode/type'
|
|
21
21
|
import {
|
|
22
|
-
ComponentType,
|
|
23
22
|
forwardRef,
|
|
24
23
|
ForwardRefRenderFunction,
|
|
25
24
|
FunctionComponent,
|
|
26
25
|
MutableRefObject,
|
|
27
26
|
ReactElement
|
|
28
27
|
} from 'react'
|
|
29
|
-
import {Theme
|
|
28
|
+
import {Theme} from '@rmwc/theme'
|
|
30
29
|
import {ThemePropT} from '@rmwc/types'
|
|
31
30
|
|
|
32
31
|
import {WrapStrict} from './WrapStrict'
|
|
33
32
|
import {WrapThemeProvider} from './WrapThemeProvider'
|
|
34
33
|
import {WrapTooltip} from './WrapTooltip'
|
|
35
|
-
import {ConfigurationProperties
|
|
36
|
-
//
|
|
34
|
+
import {ConfigurationProperties} from '../type'
|
|
35
|
+
// endregion
|
|
37
36
|
/**
|
|
38
37
|
* Wraps a theme provider, strict wrapper and tooltip to given element if
|
|
39
38
|
* corresponding configurations are provided.
|
|
39
|
+
* @param properties - Component provided properties.
|
|
40
40
|
* @param properties.children - Component or string to wrap.
|
|
41
41
|
* @param properties.strict - Indicates whether to render in strict mode.
|
|
42
42
|
* @param properties.themeConfiguration - Optional theme configurations.
|
|
@@ -44,6 +44,7 @@ import {ConfigurationProperties, Properties} from '../type'
|
|
|
44
44
|
* @param properties.wrap - Instead of injecting a div tag, wrap a child
|
|
45
45
|
* component by merging the theme styles directly onto it. Useful when you
|
|
46
46
|
* don't want to mess with layout.
|
|
47
|
+
*
|
|
47
48
|
* @returns Wrapped content.
|
|
48
49
|
*/
|
|
49
50
|
export const WrapConfigurations:FunctionComponent<
|
|
@@ -56,7 +57,17 @@ export const WrapConfigurations:FunctionComponent<
|
|
|
56
57
|
</WrapThemeProvider>
|
|
57
58
|
</WrapTooltip>
|
|
58
59
|
</WrapStrict>
|
|
59
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Component factory to dynamically create a wrapped component.
|
|
62
|
+
* @param WrappedComponent - Component to wrap.
|
|
63
|
+
* @param options - Options configure wrapping.
|
|
64
|
+
* @param options.withReference - Indicates whether to add a mutable reference
|
|
65
|
+
* to wrapping component.
|
|
66
|
+
* @param options.withThemeWrapper - Indicates whether all theme configurations
|
|
67
|
+
* should be provided.
|
|
68
|
+
*
|
|
69
|
+
* @returns Created wrapped component.
|
|
70
|
+
*/
|
|
60
71
|
export function createWrapConfigurationsComponent<
|
|
61
72
|
Type extends AnyFunction = AnyFunction, Reference = unknown
|
|
62
73
|
>(
|
|
@@ -91,6 +102,7 @@ export function createWrapConfigurationsComponent<
|
|
|
91
102
|
}
|
|
92
103
|
</WrapConfigurations>
|
|
93
104
|
}
|
|
105
|
+
|
|
94
106
|
return options.withReference ?
|
|
95
107
|
forwardRef(component as ForwardRefRenderFunction<typeof component>) :
|
|
96
108
|
component
|
|
@@ -2,6 +2,12 @@ import { FunctionComponent } from 'react';
|
|
|
2
2
|
import { Renderable } from '../type';
|
|
3
3
|
/**
|
|
4
4
|
* Generic strict wrapper component.
|
|
5
|
+
* @param properties - Provided component properties.
|
|
6
|
+
* @param properties.children - Components to wrap.
|
|
7
|
+
* @param properties.strict - Indicates whether to wrap with strict indicating
|
|
8
|
+
* component.
|
|
9
|
+
*
|
|
10
|
+
* @returns React component.
|
|
5
11
|
*/
|
|
6
12
|
export declare const WrapStrict: FunctionComponent<{
|
|
7
13
|
children: Renderable;
|
|
@@ -23,12 +23,19 @@ import {Renderable} from '../type'
|
|
|
23
23
|
// endregion
|
|
24
24
|
/**
|
|
25
25
|
* Generic strict wrapper component.
|
|
26
|
+
* @param properties - Provided component properties.
|
|
27
|
+
* @param properties.children - Components to wrap.
|
|
28
|
+
* @param properties.strict - Indicates whether to wrap with strict indicating
|
|
29
|
+
* component.
|
|
30
|
+
*
|
|
31
|
+
* @returns React component.
|
|
26
32
|
*/
|
|
27
33
|
export const WrapStrict:FunctionComponent<{
|
|
28
34
|
children:Renderable
|
|
29
35
|
strict:boolean
|
|
30
36
|
}> = ({children, strict}):ReactElement =>
|
|
31
37
|
strict ? <StrictMode>{children}</StrictMode> : <>{children}</>
|
|
38
|
+
|
|
32
39
|
export default WrapStrict
|
|
33
40
|
// region vim modline
|
|
34
41
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
@@ -2,11 +2,13 @@ import { FunctionComponent, ReactElement } from 'react';
|
|
|
2
2
|
import { ThemeProviderProps } from '@rmwc/theme';
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a theme provider to given element if a configuration is provided.
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* @param properties - Component provided properties.
|
|
6
|
+
* @param properties.children - Component or string to wrap.
|
|
7
|
+
* @param properties.configuration - Potential theme provider configuration.
|
|
8
|
+
* @param properties.wrap - Instead of injecting a div tag, wrap a child
|
|
9
|
+
* component by merging the theme styles directly onto it. Useful when you
|
|
10
|
+
* don't want to mess with layout.
|
|
11
|
+
*
|
|
10
12
|
* @returns Wrapped content.
|
|
11
13
|
*/
|
|
12
14
|
export declare const WrapThemeProvider: FunctionComponent<{
|
|
@@ -22,11 +22,13 @@ import {ThemeProvider, ThemeProviderProps} from '@rmwc/theme'
|
|
|
22
22
|
// endregion
|
|
23
23
|
/**
|
|
24
24
|
* Wraps a theme provider to given element if a configuration is provided.
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* @param properties - Component provided properties.
|
|
26
|
+
* @param properties.children - Component or string to wrap.
|
|
27
|
+
* @param properties.configuration - Potential theme provider configuration.
|
|
28
|
+
* @param properties.wrap - Instead of injecting a div tag, wrap a child
|
|
29
|
+
* component by merging the theme styles directly onto it. Useful when you
|
|
30
|
+
* don't want to mess with layout.
|
|
31
|
+
*
|
|
30
32
|
* @returns Wrapped content.
|
|
31
33
|
*/
|
|
32
34
|
export const WrapThemeProvider:FunctionComponent<{
|
|
@@ -38,6 +40,7 @@ export const WrapThemeProvider:FunctionComponent<{
|
|
|
38
40
|
{children}
|
|
39
41
|
</ThemeProvider> :
|
|
40
42
|
children
|
|
43
|
+
|
|
41
44
|
export default WrapThemeProvider
|
|
42
45
|
// region vim modline
|
|
43
46
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
|
@@ -3,8 +3,10 @@ import { Properties } from '../type';
|
|
|
3
3
|
/**
|
|
4
4
|
* Wraps given component with a tooltip component with given tooltip
|
|
5
5
|
* configuration.
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
6
|
+
* @param properties - Component provided properties.
|
|
7
|
+
* @param properties.children - Component or string to wrap.
|
|
8
|
+
* @param properties.options - Tooltip options.
|
|
9
|
+
*
|
|
8
10
|
* @returns Wrapped given content.
|
|
9
11
|
*/
|
|
10
12
|
export declare const WrapTooltip: FunctionComponent<{
|
|
@@ -26,8 +26,10 @@ import {Properties} from '../type'
|
|
|
26
26
|
/**
|
|
27
27
|
* Wraps given component with a tooltip component with given tooltip
|
|
28
28
|
* configuration.
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
29
|
+
* @param properties - Component provided properties.
|
|
30
|
+
* @param properties.children - Component or string to wrap.
|
|
31
|
+
* @param properties.options - Tooltip options.
|
|
32
|
+
*
|
|
31
33
|
* @returns Wrapped given content.
|
|
32
34
|
*/
|
|
33
35
|
export const WrapTooltip:FunctionComponent<{
|
|
@@ -37,7 +39,10 @@ export const WrapTooltip:FunctionComponent<{
|
|
|
37
39
|
if (typeof options === 'string')
|
|
38
40
|
return <Tooltip
|
|
39
41
|
content={<Typography use="caption">{options}</Typography>}
|
|
40
|
-
|
|
42
|
+
>
|
|
43
|
+
<div className="generic-tooltip">{children}</div>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
|
|
41
46
|
if (options !== null && typeof options === 'object') {
|
|
42
47
|
if (typeof options.content === 'string')
|
|
43
48
|
options = {
|
|
@@ -46,12 +51,15 @@ export const WrapTooltip:FunctionComponent<{
|
|
|
46
51
|
{options.content}
|
|
47
52
|
</Typography>
|
|
48
53
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
|
|
55
|
+
return <Tooltip {...options}>
|
|
56
|
+
<div className="generic-tooltip">{children}</div>
|
|
57
|
+
</Tooltip>
|
|
52
58
|
}
|
|
59
|
+
|
|
53
60
|
return <>{children}</>
|
|
54
61
|
}
|
|
62
|
+
|
|
55
63
|
export default WrapTooltip
|
|
56
64
|
// region vim modline
|
|
57
65
|
// vim: set tabstop=4 shiftwidth=4 expandtab:
|
package/helper.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { BaseProperties, BaseProps, DefaultBaseProperties, DefaultInputPropertie
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates a mocked a state setter. Useful to dynamically convert a component
|
|
8
8
|
* from uncontrolled to controlled.
|
|
9
|
-
*
|
|
10
9
|
* @param value - Parameter for state setter.
|
|
11
10
|
*
|
|
12
11
|
* @returns Nothing.
|
|
@@ -17,6 +16,7 @@ export declare const createDummyStateSetter: <Type = unknown>(value: Type) => Re
|
|
|
17
16
|
* properties.
|
|
18
17
|
* @param properties - To consolidate.
|
|
19
18
|
* @param state - To search values in.
|
|
19
|
+
*
|
|
20
20
|
* @returns Consolidated properties.
|
|
21
21
|
*/
|
|
22
22
|
export declare const deriveMissingPropertiesFromState: <Properties extends BaseProps = BaseProps, State extends ValueState<unknown, ModelState> = ValueState<unknown, ModelState>>(properties: Properties, state: State) => Properties;
|
|
@@ -24,17 +24,15 @@ export declare const deriveMissingPropertiesFromState: <Properties extends BaseP
|
|
|
24
24
|
* Creates a hybrid a state setter wich only triggers when model state changes
|
|
25
25
|
* occur. Useful to dynamically convert a component from uncontrolled to
|
|
26
26
|
* controlled while model state should be uncontrolled either.
|
|
27
|
-
*
|
|
28
27
|
* @param setValueState - Value setter to wrap.
|
|
29
28
|
* @param currentValueState - Last known value state to provide to setter when
|
|
30
29
|
* called.
|
|
31
30
|
*
|
|
32
31
|
* @returns Wrapped given method.
|
|
33
32
|
*/
|
|
34
|
-
export declare const wrapStateSetter: <Type = any>(setValueState: (
|
|
33
|
+
export declare const wrapStateSetter: <Type = any>(setValueState: (_value: Type | ((_value: Type) => Type)) => void, currentValueState: Type) => ReturnType<typeof useState>[1];
|
|
35
34
|
/**
|
|
36
35
|
* Triggered when a value state changes like validation or focusing.
|
|
37
|
-
*
|
|
38
36
|
* @param properties - Properties to search in.
|
|
39
37
|
* @param name - Event callback name to search for in given properties.
|
|
40
38
|
* @param synchronous - Indicates whether to trigger callback immediately or
|
|
@@ -50,6 +48,7 @@ export declare const triggerCallbackIfExists: <P extends Omit<BaseProperties, "m
|
|
|
50
48
|
/**
|
|
51
49
|
* Translate known symbols in a copied and return properties object.
|
|
52
50
|
* @param properties - Object to translate.
|
|
51
|
+
*
|
|
53
52
|
* @returns Transformed properties.
|
|
54
53
|
*/
|
|
55
54
|
export declare const translateKnownSymbols: <Type = any>(properties: Mapping<typeof NullSymbol | typeof UndefinedSymbol | Type>) => Mapping<Type>;
|
|
@@ -58,6 +57,7 @@ export declare const translateKnownSymbols: <Type = any>(properties: Mapping<typ
|
|
|
58
57
|
* @param properties - Components properties.
|
|
59
58
|
* @param defaultValue - Internal fallback value.
|
|
60
59
|
* @param alternateValue - Alternate value to respect.
|
|
60
|
+
*
|
|
61
61
|
* @returns Determined value.
|
|
62
62
|
*/
|
|
63
63
|
export declare const determineInitialValue: <Type = any>(properties: BaseProps, defaultValue?: Type | null | undefined, alternateValue?: Type | null | undefined) => Type | null;
|
|
@@ -67,6 +67,7 @@ export declare const determineInitialValue: <Type = any>(properties: BaseProps,
|
|
|
67
67
|
* @param currentState - Current validation state.
|
|
68
68
|
* @param validators - Mapping from validation state key to corresponding
|
|
69
69
|
* validator function.
|
|
70
|
+
*
|
|
70
71
|
* @returns A boolean indicating if validation state has changed.
|
|
71
72
|
*/
|
|
72
73
|
export declare const determineValidationState: <P extends DefaultBaseProperties = DefaultBaseProperties, MS extends Partial<ModelState> = Partial<ModelState>>(properties: P, currentState: MS, validators?: Mapping<() => boolean>) => boolean;
|
|
@@ -76,37 +77,67 @@ export declare const determineValidationState: <P extends DefaultBaseProperties
|
|
|
76
77
|
* properties.
|
|
77
78
|
* @param properties - Properties to merge.
|
|
78
79
|
* @param defaultModel - Default model to merge.
|
|
80
|
+
*
|
|
79
81
|
* @returns Merged properties.
|
|
80
82
|
*/
|
|
81
83
|
export declare const mapPropertiesIntoModel: <P extends BaseProps = BaseProps, DP extends DefaultBaseProperties = DefaultBaseProperties>(properties: P, defaultModel: DP["model"]) => DP;
|
|
82
84
|
/**
|
|
83
85
|
* Calculate external properties (a set of all configurable properties).
|
|
84
86
|
* @param properties - Properties to merge.
|
|
87
|
+
*
|
|
85
88
|
* @returns External properties object.
|
|
86
89
|
*/
|
|
87
90
|
export declare const getConsolidatedProperties: <P extends BaseProps, R extends BaseProperties>(properties: P) => R;
|
|
91
|
+
/**
|
|
92
|
+
* Determine normalized labels and values for selection and auto-complete
|
|
93
|
+
* components.
|
|
94
|
+
* @param selection - Selection component property configuration.
|
|
95
|
+
*
|
|
96
|
+
* @returns Normalized sorted listed of labels and values.
|
|
97
|
+
*/
|
|
88
98
|
export declare function getLabelAndValues(selection?: SelectProps['options'] | Array<{
|
|
89
99
|
label?: string;
|
|
90
100
|
value: unknown;
|
|
91
101
|
}>): [Array<string>, Array<unknown>];
|
|
102
|
+
/**
|
|
103
|
+
* Determine representation for given value while respecting existing labels.
|
|
104
|
+
* @param value - To represent.
|
|
105
|
+
* @param selection - Selection component property configuration.
|
|
106
|
+
*
|
|
107
|
+
* @returns Determined representation.
|
|
108
|
+
*/
|
|
92
109
|
export declare function getRepresentationFromValueSelection(value: unknown, selection?: SelectProps['options'] | Array<{
|
|
93
110
|
label?: string;
|
|
94
111
|
value: unknown;
|
|
95
112
|
}>): null | string;
|
|
113
|
+
/**
|
|
114
|
+
* Determine value from provided representation (for example user inputs).
|
|
115
|
+
* @param label - To search a value for.
|
|
116
|
+
* @param selection - Selection component property configuration.
|
|
117
|
+
*
|
|
118
|
+
* @returns Determined value.
|
|
119
|
+
*/
|
|
96
120
|
export declare function getValueFromSelection<T>(label: string, selection: SelectProps['options'] | Array<{
|
|
97
121
|
label?: string;
|
|
98
122
|
value: unknown;
|
|
99
123
|
}>): null | T;
|
|
100
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Normalize given selection.
|
|
126
|
+
* @param selection - Selection component property configuration.
|
|
127
|
+
* @param labels - Additional labels to take into account (for example provided
|
|
128
|
+
* via a content management system).
|
|
129
|
+
*
|
|
130
|
+
* @returns Determined normalized selection configuration.
|
|
131
|
+
*/
|
|
132
|
+
export declare function normalizeSelection(selection?: (Array<[string, string]> | SelectProps['options'] | Array<{
|
|
101
133
|
label?: string;
|
|
102
134
|
value: unknown;
|
|
103
|
-
}
|
|
135
|
+
}>), labels?: Array<string> | Mapping): SelectProps['options'] | Array<{
|
|
104
136
|
label?: string;
|
|
105
137
|
value: unknown;
|
|
106
138
|
}> | undefined;
|
|
107
139
|
/**
|
|
108
140
|
* Applies configured value transformations.
|
|
109
|
-
*
|
|
110
141
|
* @param configuration - Input configuration.
|
|
111
142
|
* @param value - Value to transform.
|
|
112
143
|
* @param transformer - To apply to given value.
|
|
@@ -116,7 +147,6 @@ export declare function normalizeSelection(selection?: Array<[string, string]> |
|
|
|
116
147
|
export declare const parseValue: <T = unknown, P extends DefaultInputProperties<T> = DefaultInputProperties<T>, InputType = T>(configuration: P, value: InputType | null, transformer: InputDataTransformation) => T | null;
|
|
117
148
|
/**
|
|
118
149
|
* Represents configured value as string.
|
|
119
|
-
*
|
|
120
150
|
* @param configuration - Input configuration.
|
|
121
151
|
* @param value - To represent.
|
|
122
152
|
* @param transformer - To apply to given value.
|
|
@@ -127,7 +157,6 @@ export declare const parseValue: <T = unknown, P extends DefaultInputProperties<
|
|
|
127
157
|
export declare function formatValue<T = unknown, P extends DefaultInputProperties<T> = DefaultInputProperties<T>>(configuration: P, value: null | T, transformer: InputDataTransformation, final?: boolean): string;
|
|
128
158
|
/**
|
|
129
159
|
* Determines initial value representation as string.
|
|
130
|
-
*
|
|
131
160
|
* @param properties - Components properties.
|
|
132
161
|
* @param defaultProperties - Components default properties.
|
|
133
162
|
* @param value - Current value to represent.
|
|
@@ -145,6 +174,7 @@ export declare function determineInitialRepresentation<T = unknown, P extends De
|
|
|
145
174
|
* using previous constant complex object within a render function.
|
|
146
175
|
* @param value - Value to memorize.
|
|
147
176
|
* @param dependencies - Optional dependencies when to update given value.
|
|
177
|
+
*
|
|
148
178
|
* @returns Given cached value.
|
|
149
179
|
*/
|
|
150
180
|
export declare const useMemorizedValue: <T = unknown>(value: T, ...dependencies: Array<unknown>) => T;
|