playbook_ui 14.5.0.pre.alpha.PLAY1548intltelinputupdatelatest4032 → 14.5.0.pre.alpha.PLAY15814040

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7965ad0a31d9d18d905cedd8a804cafc16faa273ada6eb2a62e12e55a2945688
4
- data.tar.gz: cb55355040cec1dfb434fde14e62c4f236d32365db8a5f646f82e18d9c6765c8
3
+ metadata.gz: a67ca5956ad8fb6abcfb9e5c95242c2ffd782f3f26ae0e9e49585d0d598bb139
4
+ data.tar.gz: edf1cfe77da72b9312f7f83334608744aa60b59687315f3aef6d0c7f7788a52d
5
5
  SHA512:
6
- metadata.gz: 7004f33f0684cd4774d4560503bbb0f9f8ce78f54da1aa9d98d4de56d6c585bf55326bb0e591628b0fa74ee30cb0ad091c22ab0aea49aaae5ac0c809ffe7762f
7
- data.tar.gz: 9fac218509a6e59c22d966df75eb7d5568b7355545cbed9ba821de046c098df5802346ea8ce89f46db66ab2d8c5d0de5b0705493fa6cb5ae6663586c8fd5de84
6
+ metadata.gz: 997a3aa11b0d1861e2f9e28fddadbf8b3f2e442b010d9439b168d2005d51153e543a4300bcb3ffb9e9c857b2ccc3041371c7a41f4ebf070982b2a91550e90df2
7
+ data.tar.gz: cd4ac6d1734f9aa82d47fe091cfdb67abdf22f92f613d3ce62e69481a78661ae8998657717feec7447392b3a514b56951d070d90266e53674dd9c0bfefde8252
@@ -13,9 +13,20 @@ export default class PbAdvancedTable extends PbEnhancedElement {
13
13
  get target() {
14
14
  return document.querySelector(CONTENT_SELECTOR.replace("id", this.element.id))
15
15
  }
16
+
17
+ static expandedRows = new Set()
18
+ static isCollapsing = false
16
19
 
17
20
  connect() {
18
21
  this.element.addEventListener('click', () => {
22
+ if (!PbAdvancedTable.isCollapsing) {
23
+ const isExpanded = this.element.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
24
+ if (!isExpanded) {
25
+ PbAdvancedTable.expandedRows.add(this.element.id)
26
+ } else {
27
+ PbAdvancedTable.expandedRows.delete(this.element.id)
28
+ }
29
+ }
19
30
  this.toggleElement(this.target)
20
31
  })
21
32
  }
@@ -75,4 +86,53 @@ export default class PbAdvancedTable extends PbEnhancedElement {
75
86
  this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
76
87
  this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
77
88
  }
89
+
90
+ static handleToggleAllHeaders(element) {
91
+ const table = element.closest('.pb_table')
92
+ const firstLevelButtons = table.querySelectorAll('.pb_advanced_table_body > .pb_table_tr [data-advanced-table]')
93
+
94
+ const expandedRows = Array.from(firstLevelButtons).filter(button =>
95
+ button.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
96
+ )
97
+
98
+ if (expandedRows.length === firstLevelButtons.length) {
99
+ expandedRows.forEach(button => {
100
+ button.click()
101
+ })
102
+ this.expandedRows.clear()
103
+ } else {
104
+ firstLevelButtons.forEach(button => {
105
+ if (!this.expandedRows.has(button.id)) {
106
+ button.click()
107
+ }
108
+ })
109
+ }
110
+ }
111
+ static handleToggleAllSubRows(element, rowDepth) {
112
+ const parentElement = element.closest(".toggle-content")
113
+ const subrowButtons = parentElement.querySelectorAll('.depth-sub-row-' + rowDepth + ' [data-advanced-table]')
114
+
115
+ const expandedSubRows = Array.from(subrowButtons).filter(button =>
116
+ button.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
117
+ )
118
+
119
+ if (expandedSubRows.length === subrowButtons.length) {
120
+ expandedSubRows.forEach(button => {
121
+ button.click()
122
+ })
123
+ } else {
124
+ subrowButtons.forEach(button => {
125
+ if (!this.expandedRows.has(button.id)) {
126
+ button.click()
127
+ }
128
+ })
129
+ }
130
+ }
131
+ }
132
+
133
+ window.expandAllRows = (element) => {
134
+ PbAdvancedTable.handleToggleAllHeaders(element)
78
135
  }
136
+ window.expandAllSubRows = (element, rowDepth) => {
137
+ PbAdvancedTable.handleToggleAllSubRows(element, rowDepth)
138
+ }
@@ -13,12 +13,4 @@
13
13
  <% end %>
14
14
  <% end %>
15
15
  <% end %>
16
- <% end %>
17
-
18
- <script type="text/javascript">
19
- var expandAllRows = (element) => {
20
- element.closest('.pb_table').querySelectorAll('.pb_advanced_table_body > .pb_table_tr [data-advanced-table]').forEach((button) => {
21
- button.dispatchEvent(new Event('click'));
22
- });
23
- };
24
- </script>
16
+ <% end %>
@@ -23,12 +23,4 @@
23
23
  <% end %>
24
24
  <% end %>
25
25
  <% end %>
26
- <% end %>
27
-
28
- <script type="text/javascript">
29
- var expandAllSubRows = (element, rowDepth) => {
30
- element.closest(".toggle-content").querySelectorAll('.depth-sub-row-' + rowDepth + ' [data-advanced-table]').forEach((button) => {
31
- button.dispatchEvent(new Event('click'));
32
- });
33
- };
34
- </script>
26
+ <% end %>
@@ -5,7 +5,7 @@ import { get } from 'lodash'
5
5
  import classnames from 'classnames'
6
6
 
7
7
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
8
- import { GlobalProps, globalProps } from '../utilities/globalProps'
8
+ import { GlobalProps, globalProps, globalInlineProps } from '../utilities/globalProps'
9
9
  import type { ProductColors, CategoryColors, BackgroundColors } from '../types/colors'
10
10
 
11
11
  import Icon from '../pb_icon/_icon'
@@ -49,6 +49,7 @@ type CardBodyProps = {
49
49
  padding?: string,
50
50
  } & GlobalProps
51
51
 
52
+
52
53
  // Header component
53
54
  const Header = (props: CardHeaderProps) => {
54
55
  const { children, className, headerColor = 'category_1', headerColorStriped = false } = props
@@ -107,6 +108,7 @@ const Card = (props: CardPropTypes): React.ReactElement => {
107
108
 
108
109
  // coerce to array
109
110
  const cardChildren = React.Children.toArray(children)
111
+ const inlineStyles = globalInlineProps(props);
110
112
 
111
113
  const subComponentTags = (tagName: string) => {
112
114
  return cardChildren.filter((c: string) => (
@@ -135,6 +137,7 @@ const Card = (props: CardPropTypes): React.ReactElement => {
135
137
  {...dataProps}
136
138
  {...htmlProps}
137
139
  className={classnames(cardCss, globalProps(props), className)}
140
+ style={inlineStyles}
138
141
  >
139
142
  {subComponentTags('Header')}
140
143
  {
@@ -163,6 +166,7 @@ const Card = (props: CardPropTypes): React.ReactElement => {
163
166
  {...dataProps}
164
167
  {...htmlProps}
165
168
  className={classnames(cardCss, globalProps(props), className)}
169
+ style={inlineStyles}
166
170
  >
167
171
  {subComponentTags('Header')}
168
172
  {nonHeaderChildren}
@@ -6,7 +6,7 @@ import classnames from "classnames";
6
6
  import Modal from "react-modal";
7
7
 
8
8
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
9
- import { globalProps } from "../utilities/globalProps";
9
+ import { globalProps, globalInlineProps } from "../utilities/globalProps";
10
10
 
11
11
  import Body from "../pb_body/_body";
12
12
  import Button from "../pb_button/_button";
@@ -91,6 +91,8 @@ const Dialog = (props: DialogProps): React.ReactElement => {
91
91
  beforeClose: "pb_dialog_overlay_before_close",
92
92
  };
93
93
 
94
+ const inlineStyles = globalInlineProps(props);
95
+
94
96
  const classes = classnames(
95
97
  buildCss("pb_dialog_wrapper"),
96
98
  globalProps(props),
@@ -184,6 +186,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
184
186
  overlayClassName={overlayClassNames}
185
187
  portalClassName={portalClassName}
186
188
  shouldCloseOnOverlayClick={shouldCloseOnOverlayClick && !loading}
189
+ style={{ content: inlineStyles }}
187
190
  >
188
191
  <>
189
192
  {title && !status ? <Dialog.Header>{title}</Dialog.Header> : null}
@@ -192,6 +195,7 @@ const Dialog = (props: DialogProps): React.ReactElement => {
192
195
  <Dialog.Body
193
196
  className="dialog_status_text_align"
194
197
  padding="md"
198
+
195
199
  >
196
200
  <Flex align="center"
197
201
  orientation="column"
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
4
- import { GlobalProps, globalProps } from '../utilities/globalProps'
4
+ import { GlobalProps, globalProps, globalInlineProps } from '../utilities/globalProps'
5
5
  import { GenericObject, Sizes } from '../types'
6
6
 
7
7
  type FlexProps = {
@@ -61,6 +61,7 @@ const Flex = (props: FlexProps): React.ReactElement => {
61
61
  const alignSelfClass = alignSelf !== 'none' ? `align_self_${alignSelf}` : ''
62
62
  const dataProps = buildDataProps(data)
63
63
  const htmlProps = buildHtmlProps(htmlOptions)
64
+ const inlineStyles = globalInlineProps(props)
64
65
 
65
66
 
66
67
  return (
@@ -83,6 +84,7 @@ const Flex = (props: FlexProps): React.ReactElement => {
83
84
  globalProps(props),
84
85
  className
85
86
  )}
87
+ style={inlineStyles}
86
88
  {...dataProps}
87
89
  {...htmlProps}
88
90
  >
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { buildCss, buildHtmlProps } from '../utilities/props'
4
- import { globalProps, GlobalProps } from '../utilities/globalProps'
4
+ import { globalProps, GlobalProps, globalInlineProps} from '../utilities/globalProps'
5
5
  type FlexItemPropTypes = {
6
6
  children: React.ReactNode[] | React.ReactNode,
7
7
  fixedSize?: string,
@@ -35,14 +35,20 @@ const FlexItem = (props: FlexItemPropTypes): React.ReactElement => {
35
35
  const fixedStyle =
36
36
  fixedSize !== undefined ? { flexBasis: `${fixedSize}` } : null
37
37
  const orderClass = order !== 'none' ? `order_${order}` : null
38
+ const inlineStyles = globalInlineProps(props)
39
+ const combinedStyles = {
40
+ ...fixedStyle,
41
+ ...inlineStyles
42
+ }
38
43
 
39
44
  const htmlProps = buildHtmlProps(htmlOptions)
40
45
 
46
+
41
47
  return (
42
48
  <div
43
49
  {...htmlProps}
44
50
  className={classnames(buildCss('pb_flex_item_kit', growClass, shrinkClass, flexClass, displayFlexClass), orderClass, alignSelfClass, globalProps(props), className)}
45
- style={fixedStyle}
51
+ style={combinedStyles}
46
52
  >
47
53
  {children}
48
54
  </div>
@@ -1,8 +1,5 @@
1
- <%= content_tag(:div,
2
- id: object.id,
3
- data: object.data,
4
- class: object.classname,
5
- style: object.style_value,
6
- **combined_html_options) do %>
1
+ <%= pb_content_tag(:div,
2
+ style: object.inline_styles
3
+ ) do %>
7
4
  <%= content.presence %>
8
5
  <% end %>
@@ -20,8 +20,11 @@ module Playbook
20
20
  generate_classname("pb_flex_item_kit", fixed_size_class, grow_class, shrink_class, display_flex_class) + align_self_class
21
21
  end
22
22
 
23
- def style_value
24
- "flex-basis: #{fixed_size};" if fixed_size.present?
23
+ def inline_styles
24
+ styles = []
25
+ styles << "flex-basis: #{fixed_size};" if fixed_size.present?
26
+ styles << "height: #{height};" if height.present?
27
+ styles.join(" ")
25
28
  end
26
29
 
27
30
  private
@@ -6,18 +6,6 @@ $dropdown-min-width: 340px;
6
6
  $flag-min-resolution: 192dpi;
7
7
 
8
8
  .pb_phone_number_input {
9
- .iti {
10
- width: 100%;
11
- }
12
-
13
- .iti__flag {
14
- margin-right: 6px;
15
- }
16
-
17
- .iti__a11y-text {
18
- display: none;
19
- }
20
-
21
9
  input::placeholder {
22
10
  color: $focus_input_light;
23
11
  }
@@ -27,7 +15,7 @@ $flag-min-resolution: 192dpi;
27
15
  border-color: $primary !important;
28
16
  }
29
17
 
30
- .iti__selected-country:focus-visible {
18
+ .iti__selected-flag:focus-visible {
31
19
  outline-style: none;
32
20
  }
33
21
  }
@@ -41,23 +29,7 @@ $flag-min-resolution: 192dpi;
41
29
  border-bottom: 1px solid $border_light !important;
42
30
  }
43
31
 
44
- .iti__selected-country-primary {
45
- display: flex;
46
- justify-content: center;
47
- align-items: center;
48
- margin-right: 10px;
49
- }
50
-
51
- .iti__selected-country {
52
- position: absolute;
53
- z-index: 2;
54
- top: 0;
55
- display: flex;
56
- height: 100%;
57
- justify-content: center;
58
- align-items: center;
59
- border-width: 0;
60
-
32
+ .iti__selected-flag {
61
33
  padding: 0 $space_xxs 0 $space_sm;
62
34
  border-radius: $space_xxs;
63
35
 
@@ -79,11 +51,11 @@ $flag-min-resolution: 192dpi;
79
51
  }
80
52
  }
81
53
 
82
- .iti--allow-dropdown .iti__country-container:hover .iti__selected-country {
54
+ .iti--allow-dropdown .iti__flag-container:hover .iti__selected-flag {
83
55
  background-color: $focus_input_light;
84
56
  }
85
57
 
86
- .iti__country-container:hover + .text_input {
58
+ .iti__flag-container:hover + .text_input {
87
59
  background-color: $focus_input_light;
88
60
  }
89
61
 
@@ -92,14 +64,11 @@ $flag-min-resolution: 192dpi;
92
64
  border-radius: 1px;
93
65
  }
94
66
 
95
- .iti__flag.iti__globe {
96
- background-image: url("https://unpkg.com/intl-tel-input@21.1.4/build/img/globe.png");
97
- background-position: center;
98
- height: 20px;
99
- background-size: 20px 20px;
67
+ .iti--separate-dial-code {
68
+ width: 100%;
100
69
  }
101
70
 
102
- .iti--show-flags .iti__selected-country {
71
+ .iti--separate-dial-code .iti__selected-flag {
103
72
  background-color: rgba($white, $opacity_1);
104
73
  }
105
74
 
@@ -126,7 +95,7 @@ $flag-min-resolution: 192dpi;
126
95
  position: relative;
127
96
  vertical-align: top;
128
97
  width: $space_xxs + 1px;
129
- top: $space_xs - 1px;
98
+ top: $space_xs + 2px;
130
99
  transform: rotate($transform-rotate-deg);
131
100
  color: $slate;
132
101
  }
@@ -167,13 +136,10 @@ $flag-min-resolution: 192dpi;
167
136
  .iti__dropdown-content {
168
137
  border-radius: $space_xs;
169
138
  border: 1px solid $border_light !important;
170
- position: absolute;
171
- z-index: 2;
172
- top: 100%;
173
139
  }
174
140
 
175
141
  &.dark {
176
- .iti--allow-dropdown .iti__country-container {
142
+ .iti--allow-dropdown .iti__flag-container {
177
143
  background-color: rgba($white, 0);
178
144
 
179
145
  &:hover {
@@ -183,13 +149,13 @@ $flag-min-resolution: 192dpi;
183
149
  background-color: rgba($white, 0.15);
184
150
  }
185
151
 
186
- .iti__selected-country {
152
+ .iti__selected-flag {
187
153
  background-color: rgba($white, 0);
188
154
  }
189
155
  }
190
156
  }
191
157
 
192
- .iti__selected-country {
158
+ .iti__selected-flag {
193
159
  background-color: rgba($white, 0);
194
160
  color: $white;
195
161
  }
@@ -1,7 +1,8 @@
1
1
  import React, { forwardRef, useEffect, useRef, useState, useImperativeHandle } from 'react'
2
2
  import classnames from 'classnames'
3
3
 
4
- import intlTelInput from 'intl-tel-input/build/js/intlTelInputWithUtils.js'
4
+ import intlTelInput from 'intl-tel-input'
5
+ import 'intl-tel-input/build/js/utils.js'
5
6
 
6
7
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
7
8
  import { globalProps } from '../utilities/globalProps'
@@ -49,7 +50,7 @@ const formatToGlobalCountryName = (countryName: string) => {
49
50
  }
50
51
 
51
52
  const formatAllCountries = () => {
52
- const countryData = intlTelInput.getCountryData()
53
+ const countryData = window.intlTelInputGlobals.getCountryData()
53
54
 
54
55
  for (let i = 0; i < countryData.length; i++) {
55
56
  const country = countryData[i]
@@ -216,13 +217,11 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
216
217
  useEffect(() => {
217
218
  const telInputInit = intlTelInput(inputRef.current, {
218
219
  separateDialCode: true,
219
- countryOrder: preferredCountries,
220
+ preferredCountries,
220
221
  allowDropdown: !disabled,
221
222
  autoInsertDialCode: false,
222
223
  initialCountry,
223
- onlyCountries,
224
- countrySearch: false,
225
- fixDropdownWidth: false,
224
+ onlyCountries
226
225
  })
227
226
 
228
227
  inputRef.current.addEventListener("countrychange", (evt: Event) => {
@@ -1,4 +1 @@
1
- declare module 'intl-tel-input/build/js/intlTelInputWithUtils.js' {
2
- const intlTelInput: any;
3
- export default intlTelInput;
4
- }
1
+ declare module 'intl-tel-input'
@@ -21,7 +21,7 @@ import classnames from "classnames";
21
21
  import { globalProps, GlobalProps } from "../utilities/globalProps";
22
22
  import { uniqueId } from 'lodash';
23
23
 
24
- type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth'>
24
+ type ModifiedGlobalProps = Omit<GlobalProps, 'minWidth' | 'maxHeight' | 'minHeight'>
25
25
 
26
26
  type PbPopoverProps = {
27
27
  aria?: { [key: string]: string };
@@ -1,4 +1,7 @@
1
1
  export default [
2
+ "minHeight",
3
+ "maxHeight",
4
+ "height",
2
5
  "left",
3
6
  "bottom",
4
7
  "right",
@@ -170,12 +170,24 @@ type ZIndex = {
170
170
  zIndex?: ZIndexType,
171
171
  } | ZIndexResponsiveType
172
172
 
173
+ type Height = {
174
+ height?: string
175
+ }
176
+
177
+ type MaxHeight = {
178
+ maxHeight?: string
179
+ }
180
+
181
+ type MinHeight = {
182
+ minHeight?: string
183
+ }
184
+
173
185
  // keep this as the last type definition
174
186
  export type GlobalProps = AlignContent & AlignItems & AlignSelf &
175
187
  BorderRadius & Cursor & Dark & Display & DisplaySizes & Flex & FlexDirection &
176
188
  FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
177
189
  LineHeight & Margin & MinWidth & MaxWidth & NumberSpacing & Order & Overflow & Padding &
178
- Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & { hover?: string } & Top & Right & Bottom & Left;
190
+ Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & { hover?: string } & Top & Right & Bottom & Left & Height & MaxHeight & MinHeight;
179
191
 
180
192
  const getResponsivePropClasses = (prop: {[key: string]: string}, classPrefix: string) => {
181
193
  const keys: string[] = Object.keys(prop)
@@ -498,7 +510,22 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
498
510
  } else {
499
511
  return verticalAlign ? `vertical_align_${verticalAlign} ` : ''
500
512
  }
501
- }
513
+ },
514
+
515
+ }
516
+
517
+ const PROP_INLINE_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => {[key: string]: any}} = {
518
+ heightProps: ({ height }: Height) => {
519
+ return height ? { height } : {};
520
+ },
521
+
522
+ maxHeightProps: ({ maxHeight }: MaxHeight) => {
523
+ return maxHeight ? { maxHeight } : {};
524
+ },
525
+
526
+ minHeightProps: ({ minHeight }: MinHeight) => {
527
+ return minHeight ? { minHeight } : {};
528
+ },
502
529
  }
503
530
 
504
531
  type DefaultProps = {[key: string]: string} | Record<string, unknown>
@@ -510,6 +537,16 @@ export const globalProps = (props: GlobalProps, defaultProps: DefaultProps = {})
510
537
  }).filter((value) => value?.length > 0).join(" ")
511
538
  }
512
539
 
540
+ // New function for inline styles
541
+ export const globalInlineProps = (props: GlobalProps): React.CSSProperties => {
542
+ const styles = Object.keys(PROP_INLINE_CATEGORIES).reduce((acc, key) => {
543
+ const result = PROP_INLINE_CATEGORIES[key](props);
544
+ return { ...acc, ...(typeof result === 'object' ? result : {}) }; // Ensure result is an object before spreading
545
+ }, {});
546
+
547
+ return styles; // Return the styles object directly
548
+ }
549
+
513
550
 
514
551
  export const deprecatedProps = (): void => {
515
552
  // if (process.env.NODE_ENV === 'development') {