playbook_ui 14.17.0.pre.alpha.PLAY1597tiptapupgrade7304 → 14.17.0.pre.alpha.PLAY1823maskedsanitizedtextinput7271
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +45 -19
- data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_copy_button/docs/index.js +1 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.md +1 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.md +1 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md +1 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md +1 -3
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +1 -1
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +13 -5
- data/app/pb_kits/playbook/pb_text_input/inputMask.ts +8 -1
- data/dist/chunks/{_typeahead-CHd0V9EL.js → _typeahead-CtCqFlTG.js} +2 -2
- data/dist/chunks/_weekday_stacked-DSsdjRl5.js +45 -0
- data/dist/chunks/{lib-BV_AF_eh.js → lib-BGzBzFZX.js} +3 -3
- data/dist/chunks/{pb_form_validation-nsvkJU2J.js → pb_form_validation-BvNy9Bd6.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -19
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -9
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook.jsx +0 -54
- data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook.md +0 -3
- data/app/pb_kits/playbook/pb_copy_button/usePBCopy.ts +0 -45
- data/dist/chunks/_weekday_stacked-BatiLk3-.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42cd5c9388b082daa6b0db3409a51e6d2b1ba19825ad83b85dc833f41e2da10c
|
4
|
+
data.tar.gz: 169bf49e86981071c953ffcac2af91413489268b07e1fc471a53e3f9d3046afe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abfd264ef4d34b866f2d4b85caf5bc1c84badf343773cad2c9515b9d25a706573e354d5bf236d4083d5fa7c01f47f576aa74c744c814e146bc1d56770230df6
|
7
|
+
data.tar.gz: 2d232c4fd5162bff68cb13cb1190a5a24ce95ff842f3928ab2b5edc9ef29bc82293c08fb55cbf0cea40ac4049395b9e6d5671a1589c19d2c27164f6aed7369d3
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
import React, { useState } from 'react'
|
2
3
|
import classnames from 'classnames'
|
3
4
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
4
5
|
import { globalProps } from '../utilities/globalProps'
|
@@ -6,19 +7,16 @@ import { globalProps } from '../utilities/globalProps'
|
|
6
7
|
import Button from '../pb_button/_button'
|
7
8
|
import Tooltip from '../pb_tooltip/_tooltip'
|
8
9
|
|
9
|
-
import usePBCopy from './usePBCopy'
|
10
|
-
|
11
10
|
type CopyButtonProps = {
|
12
|
-
aria?: { [key: string]: string }
|
13
|
-
className?: string
|
14
|
-
data?: { [key: string]: string }
|
15
|
-
id?: string
|
16
|
-
from?: string
|
17
|
-
text?: string
|
18
|
-
tooltipPlacement?:
|
19
|
-
tooltipText?: string
|
20
|
-
value?: string
|
21
|
-
timeout?: number
|
11
|
+
aria?: { [key: string]: string },
|
12
|
+
className?: string,
|
13
|
+
data?: { [key: string]: string },
|
14
|
+
id?: string,
|
15
|
+
from?: string,
|
16
|
+
text?: string,
|
17
|
+
tooltipPlacement?: "top" | "right" | "bottom" | "left",
|
18
|
+
tooltipText?: string,
|
19
|
+
value?: string,
|
22
20
|
}
|
23
21
|
|
24
22
|
const CopyButton = (props: CopyButtonProps) => {
|
@@ -29,34 +27,62 @@ const CopyButton = (props: CopyButtonProps) => {
|
|
29
27
|
from = '',
|
30
28
|
id,
|
31
29
|
text= 'Copy',
|
32
|
-
timeout = 1000,
|
33
30
|
tooltipPlacement= 'bottom',
|
34
31
|
tooltipText = 'Copied!',
|
35
32
|
value = '',
|
36
33
|
} = props
|
37
34
|
|
38
|
-
const [copied,
|
35
|
+
const [copied, setCopied] = useState(false)
|
39
36
|
|
40
37
|
const ariaProps = buildAriaProps(aria)
|
41
38
|
const dataProps = buildDataProps(data)
|
42
39
|
const classes = classnames(buildCss('pb_copy_button_kit'), globalProps(props), className)
|
43
40
|
|
41
|
+
const copy = () => {
|
42
|
+
if (!from && !value) {
|
43
|
+
return
|
44
|
+
}
|
45
|
+
|
46
|
+
if (value) {
|
47
|
+
navigator.clipboard.writeText(value)
|
48
|
+
} else if (from) {
|
49
|
+
const copyElement = document.getElementById(from);
|
50
|
+
let copyText = copyElement?.innerText
|
51
|
+
|
52
|
+
if (copyElement instanceof HTMLTextAreaElement || copyElement instanceof HTMLInputElement) {
|
53
|
+
copyText = copyElement.value;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (copyText) {
|
57
|
+
navigator.clipboard.writeText(copyText)
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
setCopied(true)
|
62
|
+
|
63
|
+
setTimeout(() => {
|
64
|
+
setCopied(false)
|
65
|
+
}, 1000);
|
66
|
+
}
|
67
|
+
|
44
68
|
return (
|
45
|
-
<div
|
69
|
+
<div
|
70
|
+
{...ariaProps}
|
46
71
|
{...dataProps}
|
47
72
|
className={classes}
|
48
73
|
id={id}
|
49
74
|
>
|
50
|
-
<Tooltip
|
75
|
+
<Tooltip
|
51
76
|
forceOpenTooltip={copied}
|
52
77
|
placement={tooltipPlacement}
|
53
78
|
showTooltip={false}
|
54
79
|
text={tooltipText}
|
55
80
|
>
|
56
|
-
<Button
|
81
|
+
<Button
|
82
|
+
icon='copy'
|
57
83
|
onClick={copy}
|
58
84
|
>
|
59
|
-
{text}
|
85
|
+
{ text }
|
60
86
|
</Button>
|
61
87
|
</Tooltip>
|
62
88
|
</div>
|
@@ -1,3 +1,2 @@
|
|
1
1
|
export { default as CopyButtonDefault } from './_copy_button_default.jsx'
|
2
|
-
export { default as CopyButtonFrom } from './_copy_button_from.jsx'
|
3
|
-
export { default as CopyButtonHook } from './_copy_button_hook.jsx'
|
2
|
+
export { default as CopyButtonFrom } from './_copy_button_from.jsx'
|
@@ -1,5 +1,3 @@
|
|
1
1
|
The `collapsibleContent` can display any content, including nested Table Rows.
|
2
2
|
|
3
|
-
Additionally, the `collapsibleSideHighlight` can also be removed by setting it to false if needed. This prop is set to true by default.
|
4
|
-
|
5
|
-
**NOTE**: We advise against using the `disableHover` Table prop when nesting Table Rows within a Table.
|
3
|
+
Additionally, the `collapsibleSideHighlight` can also be removed by setting it to false if needed. This prop is set to true by default.
|
@@ -1,5 +1,3 @@
|
|
1
1
|
The `collapsible_content` can display any content, including nested Table Rows.
|
2
2
|
|
3
|
-
Additionally, the `collapsible_side_highlight` can also be removed by setting it to false if needed. This prop is set to true by default.
|
4
|
-
|
5
|
-
**NOTE**: We advise against using the `disable_hover` Table prop when nesting Table Rows within a Table.
|
3
|
+
Additionally, the `collapsible_side_highlight` can also be removed by setting it to false if needed. This prop is set to true by default.
|
@@ -1,3 +1 @@
|
|
1
|
-
The `collapsible_content` can also be used to display nested Tables within each Row.
|
2
|
-
|
3
|
-
**NOTE**: We advise against using the `disable_hover` Table prop when nesting Tables within a Table.
|
1
|
+
The `collapsible_content` can also be used to display nested Tables within each Row.
|
@@ -25,7 +25,7 @@ type TextInputProps = {
|
|
25
25
|
name: string,
|
26
26
|
label: string,
|
27
27
|
mask?: 'currency' | 'zipCode' | 'postalCode' | 'ssn',
|
28
|
-
onChange: (e: React.FormEvent<HTMLInputElement
|
28
|
+
onChange: (e: React.FormEvent<HTMLInputElement>, sanitizedValue?: string) => void,
|
29
29
|
placeholder: string,
|
30
30
|
required?: boolean,
|
31
31
|
type: string,
|
@@ -102,10 +102,16 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
102
102
|
|
103
103
|
let cursorPosition = e.target.selectionStart;
|
104
104
|
const isAtEnd = cursorPosition === inputValue.length;
|
105
|
-
|
105
|
+
|
106
106
|
const formattedValue = INPUTMASKS[mask].format(inputValue)
|
107
|
+
|
108
|
+
let sanitizedValue = formattedValue;
|
109
|
+
if (INPUTMASKS[mask].sanitize) {
|
110
|
+
sanitizedValue = INPUTMASKS[mask].sanitize(formattedValue)
|
111
|
+
}
|
112
|
+
|
107
113
|
e.target.value = formattedValue
|
108
|
-
|
114
|
+
|
109
115
|
// Keep cursor position
|
110
116
|
if (!isAtEnd) {
|
111
117
|
// Account for extra characters (e.g., commas added/removed in currency)
|
@@ -116,9 +122,11 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
116
122
|
}
|
117
123
|
e.target.selectionStart = e.target.selectionEnd = cursorPosition
|
118
124
|
}
|
125
|
+
|
126
|
+
onChange(e, sanitizedValue);
|
127
|
+
} else {
|
128
|
+
onChange(e)
|
119
129
|
}
|
120
|
-
|
121
|
-
onChange(e)
|
122
130
|
}
|
123
131
|
|
124
132
|
const childInput = children ? children.type === "input" : undefined
|
@@ -3,6 +3,7 @@ type InputMask = {
|
|
3
3
|
formatDefaultValue: (value: string) => string
|
4
4
|
pattern: string
|
5
5
|
placeholder: string
|
6
|
+
sanitize?: (value: string) => string;
|
6
7
|
}
|
7
8
|
|
8
9
|
type InputMaskDictionary = {
|
@@ -73,35 +74,41 @@ export const INPUTMASKS: InputMaskDictionary = {
|
|
73
74
|
// eslint-disable-next-line no-useless-escape
|
74
75
|
pattern: '^\\$\\d{1,3}(?:,\\d{3})*(?:\\.\\d{2})?$',
|
75
76
|
placeholder: '$0.00',
|
77
|
+
sanitize: (value: string) => value.replace(/[$,]/g, ''),
|
76
78
|
},
|
77
79
|
zipCode: {
|
78
80
|
format: formatBasicPostal,
|
79
81
|
formatDefaultValue: formatBasicPostal,
|
80
82
|
pattern: '\\d{5}',
|
81
83
|
placeholder: '12345',
|
84
|
+
sanitize: (value: string) => value,
|
82
85
|
},
|
83
86
|
postalCode: {
|
84
87
|
format: formatExtendedPostal,
|
85
88
|
formatDefaultValue: formatExtendedPostal,
|
86
89
|
pattern: '\\d{5}-\\d{4}',
|
87
90
|
placeholder: '12345-6789',
|
91
|
+
sanitize: (value: string) => value.replace(/-/g, ''),
|
88
92
|
},
|
89
93
|
ssn: {
|
90
94
|
format: formatSSN,
|
91
95
|
formatDefaultValue: formatSSN,
|
92
96
|
pattern: '\\d{3}-\\d{2}-\\d{4}',
|
93
97
|
placeholder: '123-45-6789',
|
98
|
+
sanitize: (value: string) => value.replace(/-/g, ''),
|
94
99
|
},
|
95
100
|
creditCard: {
|
96
101
|
format: formatCreditCard,
|
97
102
|
formatDefaultValue: formatCreditCard,
|
98
103
|
pattern: '\\d{4} \\d{4} \\d{4} \\d{4}',
|
99
104
|
placeholder: '1234 5678 9012 3456',
|
105
|
+
sanitize: (value: string) => value.replace(/\s/g, ''),
|
100
106
|
},
|
101
107
|
cvv: {
|
102
108
|
format: formatCVV,
|
103
109
|
formatDefaultValue: formatCVV,
|
104
110
|
pattern: '\\d{3,4}',
|
105
111
|
placeholder: '123',
|
112
|
+
sanitize: (value: string) => value,
|
106
113
|
},
|
107
|
-
}
|
114
|
+
}
|