@planningcenter/tapestry-react 2.9.2 → 2.10.0-rc.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/dist/cjs/Badge/Badge.js +19 -7
- package/dist/cjs/Badge/Status.js +52 -77
- package/dist/cjs/Button/Button.js +1 -1
- package/dist/cjs/Calendar/Day.js +5 -2
- package/dist/cjs/Combobox/ComboboxPopover.js +20 -6
- package/dist/cjs/Input/Inline.js +1 -1
- package/dist/cjs/Input/InputBox.js +1 -1
- package/dist/cjs/Menu/Item.js +47 -25
- package/dist/cjs/Modal/Modal.js +4 -3
- package/dist/cjs/NumberField/NumberField.js +112 -31
- package/dist/cjs/NumberField/NumberField.test.js +8 -2
- package/dist/cjs/Portal/Portal.js +2 -1
- package/dist/cjs/Progress/Progress.js +2 -2
- package/dist/cjs/Radio/Radio.js +12 -8
- package/dist/cjs/Toolbar/Toolbar.js +1 -0
- package/dist/cjs/Tooltip/Tooltip.js +4 -2
- package/dist/cjs/Wizard/Wizard.js +4 -4
- package/dist/cjs/system/utils.js +2 -0
- package/dist/esm/Badge/Badge.js +19 -7
- package/dist/esm/Badge/Status.js +52 -77
- package/dist/esm/Button/Button.js +1 -1
- package/dist/esm/Calendar/Day.js +5 -2
- package/dist/esm/Combobox/ComboboxPopover.js +20 -6
- package/dist/esm/Input/Inline.js +1 -1
- package/dist/esm/Input/InputBox.js +1 -1
- package/dist/esm/Menu/Item.js +47 -25
- package/dist/esm/Modal/Modal.js +4 -3
- package/dist/esm/NumberField/NumberField.js +112 -32
- package/dist/esm/NumberField/NumberField.test.js +8 -2
- package/dist/esm/Portal/Portal.js +2 -1
- package/dist/esm/Progress/Progress.js +2 -2
- package/dist/esm/Radio/Radio.js +12 -8
- package/dist/esm/Toolbar/Toolbar.js +2 -1
- package/dist/esm/Tooltip/Tooltip.js +4 -2
- package/dist/esm/Wizard/Wizard.js +4 -4
- package/dist/esm/system/utils.js +2 -0
- package/dist/types/Badge/Status.d.ts +27 -0
- package/dist/types/Button/Button.d.ts +4 -2
- package/dist/types/Modal/Modal.d.ts +23 -0
- package/dist/types/NumberField/NumberField.d.ts +89 -0
- package/dist/types/Progress/Progress.d.ts +12 -0
- package/dist/types/Radio/Radio.d.ts +44 -0
- package/dist/types/Wizard/Wizard.d.ts +63 -0
- package/package.json +3 -1
- package/src/Badge/Badge.js +8 -0
- package/src/Badge/Status.tsx +90 -0
- package/src/Button/Button.tsx +2 -2
- package/src/Calendar/Day.js +11 -0
- package/src/Combobox/ComboboxPopover.js +30 -0
- package/src/Input/Inline.js +1 -1
- package/src/Input/InputBox.js +1 -1
- package/src/Menu/Item.js +15 -0
- package/src/Modal/{Modal.js → Modal.tsx} +8 -9
- package/src/NumberField/NumberField.mdx +13 -0
- package/src/NumberField/NumberField.test.tsx +38 -11
- package/src/NumberField/{NumberField.js → NumberField.tsx} +124 -48
- package/src/Portal/Portal.tsx +1 -0
- package/src/Progress/{Progress.js → Progress.tsx} +3 -4
- package/src/Radio/{Radio.js → Radio.tsx} +21 -15
- package/src/Toolbar/Toolbar.js +1 -0
- package/src/Tooltip/Tooltip.js +8 -1
- package/src/Wizard/{Wizard.js → Wizard.tsx} +42 -35
- package/src/system/utils.js +2 -0
- package/src/Badge/Status.js +0 -101
package/src/Tooltip/Tooltip.js
CHANGED
|
@@ -84,6 +84,12 @@ export type Props = {
|
|
|
84
84
|
*/
|
|
85
85
|
popoverProps?: object,
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Set a specific z-index for Tooltip. (defaults to `9999`)
|
|
89
|
+
* This option can be helpful in adjusting elements that overlap visually.
|
|
90
|
+
*/
|
|
91
|
+
zIndex: number,
|
|
92
|
+
|
|
87
93
|
/**
|
|
88
94
|
* Passes props to [Popover](/popover)'s `anchorElement`.
|
|
89
95
|
*/
|
|
@@ -118,6 +124,7 @@ function Tooltip(props: Props, ref) {
|
|
|
118
124
|
title,
|
|
119
125
|
triggerOnFocus = true,
|
|
120
126
|
triggerOnHover = true,
|
|
127
|
+
zIndex = 9999,
|
|
121
128
|
...childProps
|
|
122
129
|
} = useThemeProps('tooltip', props)
|
|
123
130
|
|
|
@@ -251,7 +258,7 @@ function Tooltip(props: Props, ref) {
|
|
|
251
258
|
radius={2}
|
|
252
259
|
backgroundColor="grey-9"
|
|
253
260
|
color="rgba(255,255,255,0.94)"
|
|
254
|
-
zIndex={
|
|
261
|
+
zIndex={zIndex}
|
|
255
262
|
{...popoverProps}
|
|
256
263
|
anchorElement={cloneElement(child, childProps)}
|
|
257
264
|
onMouseEnter={createOpenTimeout}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import React, { Children, useCallback, useReducer, useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import Button from '../Button'
|
|
@@ -8,72 +7,83 @@ import StackView from '../StackView'
|
|
|
8
7
|
import PagerView from '../PagerView'
|
|
9
8
|
import StepperProgress from '../StepperProgress'
|
|
10
9
|
import Text from '../Text'
|
|
10
|
+
import { ButtonProps } from '../Button/Button'
|
|
11
11
|
import { useThemeProps } from '../system'
|
|
12
12
|
|
|
13
13
|
import WizardContext from './WizardContext'
|
|
14
14
|
|
|
15
|
-
export type
|
|
15
|
+
export type Step = {
|
|
16
|
+
name: string
|
|
17
|
+
valid?: (payload: Record<string, any>) => boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type WizardProps = {
|
|
16
21
|
/**
|
|
17
22
|
* Pass props to the back button.
|
|
18
23
|
*/
|
|
19
|
-
backButtonProps
|
|
24
|
+
backButtonProps?: ButtonProps
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Pass props to all Button components in the footer.
|
|
23
28
|
*/
|
|
24
|
-
buttonProps
|
|
29
|
+
buttonProps?: ButtonProps
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* Pass props to the cancel button.
|
|
28
33
|
*/
|
|
29
|
-
cancelButtonProps
|
|
34
|
+
cancelButtonProps?: ButtonProps
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The content of the component.
|
|
38
|
+
*/
|
|
39
|
+
children: React.ReactNode
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
42
|
* Pass props to the Button components.
|
|
33
43
|
*/
|
|
34
|
-
footerProps
|
|
44
|
+
footerProps?: ButtonProps
|
|
35
45
|
|
|
36
46
|
/**
|
|
37
47
|
* The initial payload state.
|
|
38
48
|
*/
|
|
39
|
-
initialPayload
|
|
49
|
+
initialPayload?: Record<string, any>
|
|
40
50
|
|
|
41
51
|
/**
|
|
42
52
|
* Pass props to the next button.
|
|
43
53
|
*/
|
|
44
|
-
nextButtonProps
|
|
54
|
+
nextButtonProps?: ButtonProps
|
|
45
55
|
|
|
46
56
|
/**
|
|
47
57
|
* Determines what the next button title displays.
|
|
48
58
|
*/
|
|
49
|
-
nextButtonTitle
|
|
50
|
-
activeStepIndex: number
|
|
51
|
-
steps:
|
|
52
|
-
totalSteps: number
|
|
53
|
-
}) =>
|
|
59
|
+
nextButtonTitle?: (props: {
|
|
60
|
+
activeStepIndex: number
|
|
61
|
+
steps: Step[]
|
|
62
|
+
totalSteps: number
|
|
63
|
+
}) => string
|
|
54
64
|
|
|
55
65
|
/**
|
|
56
66
|
* Creates a cancel button for canceling a process from the first step.
|
|
57
67
|
*/
|
|
58
|
-
onCancel
|
|
68
|
+
onCancel?: () => void
|
|
59
69
|
|
|
60
70
|
/**
|
|
61
71
|
* Called when the `Done` button is pressed on the last view. Passes back the `payload` state
|
|
62
72
|
* as well as an option `complete` callback to revert the button spinner back to normal.
|
|
63
73
|
*/
|
|
64
|
-
onSubmit
|
|
74
|
+
onSubmit?: (payload: Record<string, any>, complete: () => void) => void
|
|
65
75
|
|
|
66
76
|
/**
|
|
67
77
|
* Provide a custom progress component to render in place of `StepperProgress`.
|
|
68
78
|
*/
|
|
69
|
-
renderProgress
|
|
70
|
-
activeStepIndex:
|
|
71
|
-
steps:
|
|
72
|
-
totalSteps: number
|
|
73
|
-
}) =>
|
|
79
|
+
renderProgress?: (props: {
|
|
80
|
+
activeStepIndex: number
|
|
81
|
+
steps: Step[]
|
|
82
|
+
totalSteps: number
|
|
83
|
+
}) => React.ReactNode
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
|
|
86
|
+
const Wizard = (props: WizardProps): JSX.Element => {
|
|
77
87
|
const {
|
|
78
88
|
autoFocus = true,
|
|
79
89
|
backButtonProps,
|
|
@@ -91,28 +101,25 @@ function Wizard(props: Props) {
|
|
|
91
101
|
...restProps
|
|
92
102
|
} = useThemeProps('wizard', props)
|
|
93
103
|
const [activeStepIndex, setActiveStepIndex] = useState(0)
|
|
94
|
-
const [steps, setSteps] = useState([])
|
|
104
|
+
const [steps, setSteps] = useState<Step[]>([])
|
|
95
105
|
const [sendingPayload, setSendingPayload] = useState(false)
|
|
96
106
|
const totalSteps = steps.length
|
|
97
107
|
const [payload, setPayload] = useReducer(
|
|
98
|
-
(prevState, updatedProperty) => ({
|
|
108
|
+
(prevState: Record<string, any>, updatedProperty: Record<string, any>) => ({
|
|
99
109
|
...prevState,
|
|
100
110
|
...updatedProperty,
|
|
101
111
|
}),
|
|
102
112
|
initialPayload
|
|
103
113
|
)
|
|
104
114
|
|
|
105
|
-
const addStep = useCallback(
|
|
106
|
-
(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
[steps]
|
|
115
|
-
)
|
|
115
|
+
const addStep = useCallback((step) => {
|
|
116
|
+
setSteps((steps) => [...steps, step])
|
|
117
|
+
return () => {
|
|
118
|
+
setSteps((steps) =>
|
|
119
|
+
steps.filter((previousStep) => previousStep.name !== step.name)
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
}, [])
|
|
116
123
|
|
|
117
124
|
const isCurrentStepValid = useCallback(
|
|
118
125
|
function () {
|
|
@@ -130,7 +137,7 @@ function Wizard(props: Props) {
|
|
|
130
137
|
setSendingPayload(true)
|
|
131
138
|
onSubmit(payload, complete)
|
|
132
139
|
}
|
|
133
|
-
}, [payload])
|
|
140
|
+
}, [onSubmit, payload])
|
|
134
141
|
|
|
135
142
|
return (
|
|
136
143
|
<WizardContext.Provider
|
package/src/system/utils.js
CHANGED
|
@@ -119,10 +119,12 @@ export function useThemeValue(path, defaultValue) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export function useThemeProps(path, props) {
|
|
122
|
+
// @ts-ignore error TS2554: Expected 2 arguments, but got 1
|
|
122
123
|
return { ...useThemeValue(path), ...props }
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
export function useBoxSize(size = 'md') {
|
|
127
|
+
// @ts-ignore error TS2554: Expected 2 arguments, but got 1
|
|
126
128
|
const boxSizes = useThemeValue('boxSizes')
|
|
127
129
|
const navigateSize = useCallback(
|
|
128
130
|
(amount) => {
|
package/src/Badge/Status.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import React, { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
import { getColor } from '../system'
|
|
5
|
-
import Icon from '../Icon'
|
|
6
|
-
|
|
7
|
-
import Badge from './Badge'
|
|
8
|
-
|
|
9
|
-
const statuses = {
|
|
10
|
-
error: {
|
|
11
|
-
color: 'error',
|
|
12
|
-
icon: 'general.x',
|
|
13
|
-
},
|
|
14
|
-
success: {
|
|
15
|
-
color: 'success',
|
|
16
|
-
icon: 'general.check',
|
|
17
|
-
},
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type StatusProps = {
|
|
21
|
-
/**
|
|
22
|
-
* Title of badge
|
|
23
|
-
*/
|
|
24
|
-
title: string,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The size of the badge
|
|
28
|
-
*/
|
|
29
|
-
size?: string,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The status of the badge, if nothing passed, nothing will be rendered.
|
|
33
|
-
*/
|
|
34
|
-
status?: 'error' | 'success',
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* When `true`, Sets a light background to use against darker backgrounds.
|
|
38
|
-
*/
|
|
39
|
-
light?: boolean,
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Called when the status should be set hidden
|
|
43
|
-
*/
|
|
44
|
-
onClearRequest: () => void,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Used to show a reaction to saving user data
|
|
49
|
-
*/
|
|
50
|
-
class Status extends Component<StatusProps> {
|
|
51
|
-
static defaultProps = {
|
|
52
|
-
title: '',
|
|
53
|
-
size: 'sm',
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
timeout = null
|
|
57
|
-
|
|
58
|
-
componentDidMount() {
|
|
59
|
-
this.requestClear()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
componentDidUpdate(lastProps) {
|
|
63
|
-
if (lastProps.status !== this.props.status) {
|
|
64
|
-
this.requestClear()
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
requestClear() {
|
|
69
|
-
if (this.timeout) {
|
|
70
|
-
clearTimeout(this.timeout)
|
|
71
|
-
}
|
|
72
|
-
this.timeout = setTimeout(this.props.onClearRequest, 1800)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
render() {
|
|
76
|
-
const { status, light, onClearRequest, ...props } = this.props
|
|
77
|
-
if (!status) {
|
|
78
|
-
return null
|
|
79
|
-
} else {
|
|
80
|
-
const { color, icon } = statuses[status]
|
|
81
|
-
return (
|
|
82
|
-
<Badge
|
|
83
|
-
paddingRight={1}
|
|
84
|
-
radius="pill"
|
|
85
|
-
renderLeft={<Icon name={icon} />}
|
|
86
|
-
color={
|
|
87
|
-
light
|
|
88
|
-
? { background: 'light', foreground: getColor(color) }
|
|
89
|
-
: getColor(color)
|
|
90
|
-
}
|
|
91
|
-
fontWeight={600}
|
|
92
|
-
{...props}
|
|
93
|
-
/>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
Status.displayName = 'Badge.Status'
|
|
100
|
-
|
|
101
|
-
export default Status
|