@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.
Files changed (64) hide show
  1. package/dist/cjs/Badge/Badge.js +19 -7
  2. package/dist/cjs/Badge/Status.js +52 -77
  3. package/dist/cjs/Button/Button.js +1 -1
  4. package/dist/cjs/Calendar/Day.js +5 -2
  5. package/dist/cjs/Combobox/ComboboxPopover.js +20 -6
  6. package/dist/cjs/Input/Inline.js +1 -1
  7. package/dist/cjs/Input/InputBox.js +1 -1
  8. package/dist/cjs/Menu/Item.js +47 -25
  9. package/dist/cjs/Modal/Modal.js +4 -3
  10. package/dist/cjs/NumberField/NumberField.js +112 -31
  11. package/dist/cjs/NumberField/NumberField.test.js +8 -2
  12. package/dist/cjs/Portal/Portal.js +2 -1
  13. package/dist/cjs/Progress/Progress.js +2 -2
  14. package/dist/cjs/Radio/Radio.js +12 -8
  15. package/dist/cjs/Toolbar/Toolbar.js +1 -0
  16. package/dist/cjs/Tooltip/Tooltip.js +4 -2
  17. package/dist/cjs/Wizard/Wizard.js +4 -4
  18. package/dist/cjs/system/utils.js +2 -0
  19. package/dist/esm/Badge/Badge.js +19 -7
  20. package/dist/esm/Badge/Status.js +52 -77
  21. package/dist/esm/Button/Button.js +1 -1
  22. package/dist/esm/Calendar/Day.js +5 -2
  23. package/dist/esm/Combobox/ComboboxPopover.js +20 -6
  24. package/dist/esm/Input/Inline.js +1 -1
  25. package/dist/esm/Input/InputBox.js +1 -1
  26. package/dist/esm/Menu/Item.js +47 -25
  27. package/dist/esm/Modal/Modal.js +4 -3
  28. package/dist/esm/NumberField/NumberField.js +112 -32
  29. package/dist/esm/NumberField/NumberField.test.js +8 -2
  30. package/dist/esm/Portal/Portal.js +2 -1
  31. package/dist/esm/Progress/Progress.js +2 -2
  32. package/dist/esm/Radio/Radio.js +12 -8
  33. package/dist/esm/Toolbar/Toolbar.js +2 -1
  34. package/dist/esm/Tooltip/Tooltip.js +4 -2
  35. package/dist/esm/Wizard/Wizard.js +4 -4
  36. package/dist/esm/system/utils.js +2 -0
  37. package/dist/types/Badge/Status.d.ts +27 -0
  38. package/dist/types/Button/Button.d.ts +4 -2
  39. package/dist/types/Modal/Modal.d.ts +23 -0
  40. package/dist/types/NumberField/NumberField.d.ts +89 -0
  41. package/dist/types/Progress/Progress.d.ts +12 -0
  42. package/dist/types/Radio/Radio.d.ts +44 -0
  43. package/dist/types/Wizard/Wizard.d.ts +63 -0
  44. package/package.json +3 -1
  45. package/src/Badge/Badge.js +8 -0
  46. package/src/Badge/Status.tsx +90 -0
  47. package/src/Button/Button.tsx +2 -2
  48. package/src/Calendar/Day.js +11 -0
  49. package/src/Combobox/ComboboxPopover.js +30 -0
  50. package/src/Input/Inline.js +1 -1
  51. package/src/Input/InputBox.js +1 -1
  52. package/src/Menu/Item.js +15 -0
  53. package/src/Modal/{Modal.js → Modal.tsx} +8 -9
  54. package/src/NumberField/NumberField.mdx +13 -0
  55. package/src/NumberField/NumberField.test.tsx +38 -11
  56. package/src/NumberField/{NumberField.js → NumberField.tsx} +124 -48
  57. package/src/Portal/Portal.tsx +1 -0
  58. package/src/Progress/{Progress.js → Progress.tsx} +3 -4
  59. package/src/Radio/{Radio.js → Radio.tsx} +21 -15
  60. package/src/Toolbar/Toolbar.js +1 -0
  61. package/src/Tooltip/Tooltip.js +8 -1
  62. package/src/Wizard/{Wizard.js → Wizard.tsx} +42 -35
  63. package/src/system/utils.js +2 -0
  64. package/src/Badge/Status.js +0 -101
@@ -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={9999}
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 Props = {
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: Object,
24
+ backButtonProps?: ButtonProps
20
25
 
21
26
  /**
22
27
  * Pass props to all Button components in the footer.
23
28
  */
24
- buttonProps: Object,
29
+ buttonProps?: ButtonProps
25
30
 
26
31
  /**
27
32
  * Pass props to the cancel button.
28
33
  */
29
- cancelButtonProps: Object,
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: Object,
44
+ footerProps?: ButtonProps
35
45
 
36
46
  /**
37
47
  * The initial payload state.
38
48
  */
39
- initialPayload: Object,
49
+ initialPayload?: Record<string, any>
40
50
 
41
51
  /**
42
52
  * Pass props to the next button.
43
53
  */
44
- nextButtonProps: Object,
54
+ nextButtonProps?: ButtonProps
45
55
 
46
56
  /**
47
57
  * Determines what the next button title displays.
48
58
  */
49
- nextButtonTitle: (props: {
50
- activeStepIndex: number,
51
- steps: Array<string>,
52
- totalSteps: number,
53
- }) => null,
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: Function,
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: (payload: Object, complete: () => null) => null,
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: (props: {
70
- activeStepIndex: Number,
71
- steps: Array<string>,
72
- totalSteps: number,
73
- }) => null,
79
+ renderProgress?: (props: {
80
+ activeStepIndex: number
81
+ steps: Step[]
82
+ totalSteps: number
83
+ }) => React.ReactNode
74
84
  }
75
85
 
76
- function Wizard(props: Props) {
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
- (step) => {
107
- setSteps((steps) => [...steps, step])
108
- return () => {
109
- setSteps((steps) =>
110
- steps.filter((previousStep) => previousStep.name !== step.name)
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
@@ -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) => {
@@ -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