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.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_copy_button/_copy_button.tsx +45 -19
  3. data/app/pb_kits/playbook/pb_copy_button/docs/example.yml +0 -1
  4. data/app/pb_kits/playbook/pb_copy_button/docs/index.js +1 -2
  5. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.md +1 -3
  6. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows_rails.md +1 -3
  7. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md +1 -3
  8. data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table_rails.md +1 -3
  9. data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +1 -1
  10. data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +13 -5
  11. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +8 -1
  12. data/dist/chunks/{_typeahead-CHd0V9EL.js → _typeahead-CtCqFlTG.js} +2 -2
  13. data/dist/chunks/_weekday_stacked-DSsdjRl5.js +45 -0
  14. data/dist/chunks/{lib-BV_AF_eh.js → lib-BGzBzFZX.js} +3 -3
  15. data/dist/chunks/{pb_form_validation-nsvkJU2J.js → pb_form_validation-BvNy9Bd6.js} +1 -1
  16. data/dist/chunks/vendor.js +1 -1
  17. data/dist/playbook-doc.js +1 -19
  18. data/dist/playbook-rails-react-bindings.js +1 -1
  19. data/dist/playbook-rails.js +1 -1
  20. data/lib/playbook/version.rb +1 -1
  21. metadata +6 -9
  22. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook.jsx +0 -54
  23. data/app/pb_kits/playbook/pb_copy_button/docs/_copy_button_hook.md +0 -3
  24. data/app/pb_kits/playbook/pb_copy_button/usePBCopy.ts +0 -45
  25. data/dist/chunks/_weekday_stacked-BatiLk3-.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 719c04e3277caff3dccb29b8f0f9cd73d95575124566a62679cb9e04cd515607
4
- data.tar.gz: 5bff5d992cf118909bb4c1cb15cddb03a8df47031386df5036838290b7cfdc21
3
+ metadata.gz: 42cd5c9388b082daa6b0db3409a51e6d2b1ba19825ad83b85dc833f41e2da10c
4
+ data.tar.gz: 169bf49e86981071c953ffcac2af91413489268b07e1fc471a53e3f9d3046afe
5
5
  SHA512:
6
- metadata.gz: 27bc1f7456bfe3104ea86f56af5412c6903459731c3a53f95b719dabf63ce064ee918ba784715feedbfd1e77f3b9f252adaefbbfa4b8da05f75e34f996f99411
7
- data.tar.gz: c0ef732ce4f03d700cc2db2e755a88fc6aa685297c6f214123c61569a02570da6b0ac30b2e563b63f73f2195d812659146b1989f3179bce82304fe540028f8b3
6
+ metadata.gz: 1abfd264ef4d34b866f2d4b85caf5bc1c84badf343773cad2c9515b9d25a706573e354d5bf236d4083d5fa7c01f47f576aa74c744c814e146bc1d56770230df6
7
+ data.tar.gz: 2d232c4fd5162bff68cb13cb1190a5a24ce95ff842f3928ab2b5edc9ef29bc82293c08fb55cbf0cea40ac4049395b9e6d5671a1589c19d2c27164f6aed7369d3
@@ -1,4 +1,5 @@
1
- import React from 'react'
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?: 'top' | 'right' | 'bottom' | 'left'
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, copy] = usePBCopy({ value, from, timeout })
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 {...ariaProps}
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 icon="copy"
81
+ <Button
82
+ icon='copy'
57
83
  onClick={copy}
58
84
  >
59
- {text}
85
+ { text }
60
86
  </Button>
61
87
  </Tooltip>
62
88
  </div>
@@ -6,4 +6,3 @@ examples:
6
6
  react:
7
7
  - copy_button_default: Default
8
8
  - copy_button_from: Copy From
9
- - copy_button_hook: Copy Hook
@@ -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 `collapsibleContent` can also be used to display nested Tables within each Row.
2
-
3
- **NOTE**: We advise against using the `disableHover` Table prop when nesting Tables within a Table.
1
+ The `collapsibleContent` can also be used to display nested Tables within each Row.
@@ -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.
@@ -48,4 +48,4 @@
48
48
  .border-active {
49
49
  border-bottom: 1px;
50
50
  }
51
- }
51
+ }
@@ -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>) => void,
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
+ }