playbook_ui 12.19.0.pre.alpha.movemarkdown639 → 12.20.0.pre.alpha.movemarkdown668
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +38 -0
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +94 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_calendar_input_icon.scss +33 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_day_styles.scss +78 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +775 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_header_styles.scss +116 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_inline_styles.scss +173 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +68 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_month_and_year_styles.scss +127 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_overrides.scss +47 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +64 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +127 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.tsx +25 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.tsx +56 -0
- data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx +68 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +1 -2
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +22 -7
- data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +32 -5
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +9 -4
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx +5 -3
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +2 -1
- data/app/pb_kits/playbook/pb_table/styles/_alignment.scss +32 -0
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +19 -0
- data/app/pb_kits/playbook/pb_table/styles/_content.scss +13 -0
- data/app/pb_kits/playbook/pb_table/styles/_desktop_collapse.scss +125 -0
- data/app/pb_kits/playbook/pb_table/styles/_headers.scss +16 -0
- data/app/pb_kits/playbook/pb_table/styles/_hover.scss +74 -0
- data/app/pb_kits/playbook/pb_table/styles/_mobile.scss +125 -0
- data/app/pb_kits/playbook/pb_table/styles/_mobile_collapse.scss +125 -0
- data/app/pb_kits/playbook/pb_table/styles/_reset.scss +17 -0
- data/app/pb_kits/playbook/pb_table/styles/_side_highlight.scss +24 -0
- data/app/pb_kits/playbook/pb_table/styles/_single-line.scss +34 -0
- data/app/pb_kits/playbook/pb_table/styles/_sticky_header.scss +23 -0
- data/app/pb_kits/playbook/pb_table/styles/_structure.scss +50 -0
- data/app/pb_kits/playbook/pb_table/styles/_table-card.scss +62 -0
- data/app/pb_kits/playbook/pb_table/styles/_table-dark.scss +100 -0
- data/app/pb_kits/playbook/pb_table/styles/_tablet_collapse.scss +125 -0
- data/app/pb_kits/playbook/pb_table/styles/_variables.scss +26 -0
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +16 -0
- data/app/pb_kits/playbook/pb_typeahead/{_typeahead.jsx → _typeahead.tsx} +24 -12
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +18 -0
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +28 -0
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +11 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +10 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +66 -0
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +37 -0
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +26 -0
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +11 -0
- data/app/pb_kits/playbook/pb_typeahead/{index.js → index.ts} +37 -29
- data/app/pb_kits/playbook/pb_typeahead/types.d.ts +2 -0
- data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
- data/app/pb_kits/playbook/utilities/_positioning.scss +14 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +16 -4
- data/dist/playbook-rails.js +4 -4
- data/lib/playbook/version.rb +2 -2
- data/lib/playbook/z_index.rb +20 -7
- metadata +46 -4
@@ -0,0 +1,26 @@
|
|
1
|
+
@import "../../tokens/spacing";
|
2
|
+
@import "../../tokens/typography";
|
3
|
+
|
4
|
+
//--------- PADDING ---------//
|
5
|
+
|
6
|
+
// Cell padding between cells
|
7
|
+
$cell-gutter: $space-xs;
|
8
|
+
|
9
|
+
// First & last cell padding
|
10
|
+
$cell-pad-endcap: $space-lg;
|
11
|
+
|
12
|
+
// Vertical cell padding
|
13
|
+
$cell-pad-sm: $space-xs;
|
14
|
+
$cell-pad-md: $space-sm;
|
15
|
+
$cell-pad-lg: $space-lg;
|
16
|
+
|
17
|
+
$cell-pad-list: (
|
18
|
+
table-sm: $cell-pad-sm,
|
19
|
+
table-md: $cell-pad-md,
|
20
|
+
table-lg: $cell-pad-lg
|
21
|
+
);
|
22
|
+
|
23
|
+
//--------- CONTENT ---------//
|
24
|
+
|
25
|
+
$default-header-size: $font-smaller;
|
26
|
+
$default-font-size: $font-small;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
[class^=pb_table] {
|
2
|
+
&.vertical-border {
|
3
|
+
td,
|
4
|
+
th {
|
5
|
+
border-right: 1px solid $border_light !important;
|
6
|
+
}
|
7
|
+
|
8
|
+
@media screen and (min-width: $screen-xs-min) {
|
9
|
+
tr:hover {
|
10
|
+
td:last-child {
|
11
|
+
border-right-color: darken($border_light, 10%) !important;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
/* @flow */
|
2
|
-
|
3
1
|
import React from 'react'
|
4
2
|
import Select from 'react-select'
|
5
3
|
import AsyncSelect from 'react-select/async'
|
@@ -19,6 +17,7 @@ import Placeholder from './components/Placeholder'
|
|
19
17
|
import ValueContainer from './components/ValueContainer'
|
20
18
|
|
21
19
|
import { noop, buildDataProps } from '../utilities/props'
|
20
|
+
import { Noop } from '../types'
|
22
21
|
|
23
22
|
/**
|
24
23
|
* @typedef {object} Props
|
@@ -33,16 +32,28 @@ type TypeaheadProps = {
|
|
33
32
|
components?: object,
|
34
33
|
createable?: boolean,
|
35
34
|
dark?: boolean,
|
36
|
-
data?:
|
35
|
+
data?: { [key: string]: string },
|
37
36
|
error?: string,
|
38
37
|
id?: string,
|
39
38
|
label?: string,
|
40
|
-
loadOptions?: string,
|
39
|
+
loadOptions?: string | Noop,
|
41
40
|
getOptionLabel?: string | (() => any),
|
42
41
|
getOptionValue?: string | (() => any),
|
43
42
|
name?: string,
|
44
43
|
}
|
45
44
|
|
45
|
+
export type SelectValueType = {
|
46
|
+
label: string,
|
47
|
+
value: string,
|
48
|
+
imageUrl?: string,
|
49
|
+
}
|
50
|
+
|
51
|
+
type TagOnChangeValues = {
|
52
|
+
action?: string,
|
53
|
+
option?: SelectValueType,
|
54
|
+
removedValue?: string,
|
55
|
+
}
|
56
|
+
|
46
57
|
/**
|
47
58
|
* @constant {React.ReactComponent} Typeahead
|
48
59
|
* @param {TypeaheadProps} props - props as described at https://react-select.com/props
|
@@ -67,7 +78,7 @@ const Typeahead = ({
|
|
67
78
|
Control,
|
68
79
|
ClearIndicator,
|
69
80
|
IndicatorsContainer,
|
70
|
-
IndicatorSeparator: null,
|
81
|
+
IndicatorSeparator: null as null,
|
71
82
|
MenuList,
|
72
83
|
MultiValue,
|
73
84
|
Option,
|
@@ -85,8 +96,9 @@ const Typeahead = ({
|
|
85
96
|
isSearchable: true,
|
86
97
|
name,
|
87
98
|
multiKit: '',
|
88
|
-
onCreateOption: null,
|
99
|
+
onCreateOption: null as null,
|
89
100
|
plusIcon: false,
|
101
|
+
onMultiValueClick: (_option: SelectValueType) => { },
|
90
102
|
...props,
|
91
103
|
}
|
92
104
|
|
@@ -96,7 +108,7 @@ const Typeahead = ({
|
|
96
108
|
: (async ? AsyncSelect : Select)
|
97
109
|
)
|
98
110
|
|
99
|
-
const handleOnChange = (_data, { action, option, removedValue }) => {
|
111
|
+
const handleOnChange = (_data: SelectValueType, { action, option, removedValue }: TagOnChangeValues) => {
|
100
112
|
if (action === 'select-option') {
|
101
113
|
if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(option)
|
102
114
|
const multiValueClearEvent = new CustomEvent(`pb-typeahead-kit-${selectProps.id}-result-option-select`, { detail: option ? option : _data })
|
@@ -123,13 +135,13 @@ const Typeahead = ({
|
|
123
135
|
|
124
136
|
return (
|
125
137
|
<div {...dataProps}
|
126
|
-
|
138
|
+
className={classnames(classes, inlineClass)}
|
127
139
|
>
|
128
140
|
<Tag
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
141
|
+
classNamePrefix="typeahead-kit-select"
|
142
|
+
error={error}
|
143
|
+
onChange={handleOnChange}
|
144
|
+
{...selectProps}
|
133
145
|
/>
|
134
146
|
</div>
|
135
147
|
)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React, { useEffect } from 'react'
|
2
|
+
import { components } from 'react-select'
|
3
|
+
|
4
|
+
const ClearContainer = (props: any) => {
|
5
|
+
const { selectProps, clearValue } = props
|
6
|
+
useEffect(() => {
|
7
|
+
document.addEventListener(`pb-typeahead-kit-${selectProps.id}:clear`, clearValue)
|
8
|
+
}, [true])
|
9
|
+
|
10
|
+
return (
|
11
|
+
<components.ClearIndicator
|
12
|
+
className="clear_indicator"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
)
|
16
|
+
}
|
17
|
+
|
18
|
+
export default ClearContainer
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { components } from 'react-select'
|
3
|
+
|
4
|
+
import Flex from '../../pb_flex/_flex'
|
5
|
+
import TextInput from '../../pb_text_input/_text_input'
|
6
|
+
|
7
|
+
type Props = {
|
8
|
+
selectProps: any,
|
9
|
+
}
|
10
|
+
|
11
|
+
const TypeaheadControl = (props: Props) => (
|
12
|
+
<div className="pb_typeahead_wrapper">
|
13
|
+
<TextInput
|
14
|
+
dark={props.selectProps.dark}
|
15
|
+
error={props.selectProps.error}
|
16
|
+
label={props.selectProps.label}
|
17
|
+
>
|
18
|
+
<Flex>
|
19
|
+
<components.Control
|
20
|
+
className="text_input"
|
21
|
+
{...props}
|
22
|
+
/>
|
23
|
+
</Flex>
|
24
|
+
</TextInput>
|
25
|
+
</div>
|
26
|
+
)
|
27
|
+
|
28
|
+
export default TypeaheadControl
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { components } from 'react-select'
|
3
|
+
|
4
|
+
import Badge from '../../pb_badge/_badge'
|
5
|
+
import FormPill from '../../pb_form_pill/_form_pill'
|
6
|
+
import { SelectValueType } from '../_typeahead'
|
7
|
+
|
8
|
+
type Props = {
|
9
|
+
data: SelectValueType,
|
10
|
+
multiValueTemplate: any,
|
11
|
+
removeProps: any,
|
12
|
+
selectProps: any,
|
13
|
+
}
|
14
|
+
|
15
|
+
const MultiValue = (props: Props) => {
|
16
|
+
const { removeProps } = props
|
17
|
+
const { imageUrl, label } = props.data
|
18
|
+
const { multiKit } = props.selectProps
|
19
|
+
|
20
|
+
const formPillProps = {
|
21
|
+
marginRight: 'xs',
|
22
|
+
name: label,
|
23
|
+
avatarUrl: '',
|
24
|
+
}
|
25
|
+
|
26
|
+
if (typeof imageUrl === 'string') formPillProps.avatarUrl = imageUrl
|
27
|
+
|
28
|
+
return (
|
29
|
+
<components.MultiValueContainer
|
30
|
+
className="text_input_multivalue_container"
|
31
|
+
{...props}
|
32
|
+
>
|
33
|
+
{multiKit === 'badge' &&
|
34
|
+
<Badge
|
35
|
+
closeProps={removeProps}
|
36
|
+
removeIcon
|
37
|
+
text={label}
|
38
|
+
variant="primary"
|
39
|
+
/>
|
40
|
+
}
|
41
|
+
|
42
|
+
{multiKit !== 'badge' && imageUrl &&
|
43
|
+
<FormPill
|
44
|
+
avatarUrl={imageUrl}
|
45
|
+
closeProps={removeProps}
|
46
|
+
marginRight="xs"
|
47
|
+
name={label}
|
48
|
+
size={multiKit === 'smallPill' ? 'small' : ''}
|
49
|
+
text=''
|
50
|
+
/>
|
51
|
+
}
|
52
|
+
|
53
|
+
{multiKit !== 'badge' && !imageUrl &&
|
54
|
+
<FormPill
|
55
|
+
closeProps={removeProps}
|
56
|
+
marginRight="xs"
|
57
|
+
name=''
|
58
|
+
size={multiKit === 'smallPill' ? 'small' : ''}
|
59
|
+
text={label}
|
60
|
+
/>
|
61
|
+
}
|
62
|
+
</components.MultiValueContainer>
|
63
|
+
)
|
64
|
+
}
|
65
|
+
|
66
|
+
export default MultiValue
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { components } from 'react-select'
|
3
|
+
|
4
|
+
import User from '../../pb_user/_user'
|
5
|
+
|
6
|
+
const Option = (props: any) => {
|
7
|
+
const {
|
8
|
+
imageUrl,
|
9
|
+
} = props.data
|
10
|
+
const { valueComponent } = props.selectProps
|
11
|
+
|
12
|
+
return (
|
13
|
+
<components.Option {...props}>
|
14
|
+
<>
|
15
|
+
{!valueComponent && imageUrl &&
|
16
|
+
<User
|
17
|
+
align="left"
|
18
|
+
avatarUrl={imageUrl}
|
19
|
+
dark={props.selectProps.dark}
|
20
|
+
name={props.label}
|
21
|
+
orientation="horizontal"
|
22
|
+
/>
|
23
|
+
}
|
24
|
+
|
25
|
+
{valueComponent &&
|
26
|
+
valueComponent(props.data)
|
27
|
+
}
|
28
|
+
|
29
|
+
{!valueComponent && !imageUrl &&
|
30
|
+
props.label
|
31
|
+
}
|
32
|
+
</>
|
33
|
+
</components.Option>
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
export default Option
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { components } from 'react-select'
|
3
|
+
|
4
|
+
import Flex from '../../pb_flex/_flex'
|
5
|
+
import Icon from '../../pb_icon/_icon'
|
6
|
+
|
7
|
+
const Placeholder = (props: any) => (
|
8
|
+
<>
|
9
|
+
<Flex
|
10
|
+
align="center"
|
11
|
+
className="placeholder"
|
12
|
+
>
|
13
|
+
<components.IndicatorsContainer
|
14
|
+
{...props}
|
15
|
+
/>
|
16
|
+
{props.selectProps.plusIcon &&
|
17
|
+
<Icon
|
18
|
+
className="typeahead-plus-icon"
|
19
|
+
icon="plus"
|
20
|
+
/>
|
21
|
+
}
|
22
|
+
</Flex>
|
23
|
+
</>
|
24
|
+
)
|
25
|
+
|
26
|
+
export default Placeholder
|
@@ -2,18 +2,26 @@ import PbEnhancedElement from '../pb_enhanced_element'
|
|
2
2
|
import { debounce } from 'lodash'
|
3
3
|
|
4
4
|
export default class PbTypeahead extends PbEnhancedElement {
|
5
|
+
_searchInput: HTMLInputElement
|
6
|
+
_resultsElement: HTMLElement
|
7
|
+
_debouncedSearch: Function
|
8
|
+
_resultsLoadingIndicator: HTMLElement
|
9
|
+
_resultOptionTemplate: HTMLElement
|
10
|
+
_resultsOptionCache: Map<string, Array<DocumentFragment>>
|
11
|
+
_searchContext: string
|
12
|
+
|
5
13
|
static get selector() {
|
6
14
|
return '[data-pb-typeahead-kit]'
|
7
15
|
}
|
8
16
|
|
9
17
|
connect() {
|
10
|
-
this.element.addEventListener('keydown', (event) => this.handleKeydown(event))
|
18
|
+
this.element.addEventListener('keydown', (event: KeyboardEvent) => this.handleKeydown(event))
|
11
19
|
this.searchInput.addEventListener('focus', () => this.debouncedSearch())
|
12
20
|
this.searchInput.addEventListener('input', () => this.debouncedSearch())
|
13
|
-
this.resultsElement.addEventListener('click', (event) => this.optionSelected(event))
|
21
|
+
this.resultsElement.addEventListener('click', (event: MouseEvent) => this.optionSelected(event))
|
14
22
|
}
|
15
23
|
|
16
|
-
handleKeydown(event) {
|
24
|
+
handleKeydown(event: KeyboardEvent) {
|
17
25
|
if (event.key === 'ArrowUp') {
|
18
26
|
event.preventDefault()
|
19
27
|
this.focusPreviousOption()
|
@@ -24,7 +32,7 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
24
32
|
}
|
25
33
|
|
26
34
|
search() {
|
27
|
-
if (this.searchTerm.length < this.searchTermMinimumLength) return this.clearResults()
|
35
|
+
if (this.searchTerm.length < parseInt(this.searchTermMinimumLength)) return this.clearResults()
|
28
36
|
|
29
37
|
this.toggleResultsLoadingIndicator(true)
|
30
38
|
this.showResults()
|
@@ -34,17 +42,17 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
34
42
|
const search = {
|
35
43
|
searchingFor: searchTerm,
|
36
44
|
searchingContext: searchContext,
|
37
|
-
setResults: (results) => {
|
45
|
+
setResults: (results: Array<DocumentFragment>) => {
|
38
46
|
this.resultsCacheUpdate(searchTerm, searchContext, results)
|
39
47
|
},
|
40
48
|
}
|
41
49
|
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
|
42
50
|
}
|
43
51
|
|
44
|
-
resultsCacheUpdate(searchTerm, searchContext, results) {
|
52
|
+
resultsCacheUpdate(searchTerm: string, searchContext: string, results: Array<DocumentFragment>) {
|
45
53
|
const searchTermAndContext = this.cacheKeyFor(searchTerm, searchContext)
|
46
54
|
if (this.resultsOptionCache.has(searchTermAndContext)) this.resultsOptionCache.delete(searchTermAndContext)
|
47
|
-
if (this.resultsOptionCache.size > 32) this.resultsOptionCache.delete(this.resultsOptionCache.keys
|
55
|
+
if (this.resultsOptionCache.size > 32) this.resultsOptionCache.delete(this.resultsOptionCache.keys().next().value)
|
48
56
|
|
49
57
|
this.resultsOptionCache.set(searchTermAndContext, results)
|
50
58
|
this.showResults()
|
@@ -57,7 +65,7 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
57
65
|
get debouncedSearch() {
|
58
66
|
return this._debouncedSearch = (
|
59
67
|
this._debouncedSearch ||
|
60
|
-
|
68
|
+
debounce(this.search, parseInt(this.searchDebounceTimeout)).bind(this)
|
61
69
|
)
|
62
70
|
}
|
63
71
|
|
@@ -70,12 +78,12 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
70
78
|
this.resultsElement.appendChild(this.newResultOption(result.cloneNode(true)))
|
71
79
|
}
|
72
80
|
for (const result of this.resultsElement.querySelectorAll('[data-result-option-item]')) {
|
73
|
-
result.addEventListener('mousedown', (event) => this.optionSelected(event))
|
81
|
+
result.addEventListener('mousedown', (event: MouseEvent) => this.optionSelected(event))
|
74
82
|
}
|
75
83
|
}
|
76
84
|
|
77
|
-
optionSelected(event) {
|
78
|
-
const resultOption = event.target.closest('[data-result-option-item]')
|
85
|
+
optionSelected(event: MouseEvent) {
|
86
|
+
const resultOption = (event.target as Element).closest('[data-result-option-item]')
|
79
87
|
if (!resultOption) return
|
80
88
|
|
81
89
|
this.resultsCacheClear()
|
@@ -89,8 +97,8 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
89
97
|
this.resultsElement.innerHTML = ''
|
90
98
|
}
|
91
99
|
|
92
|
-
newResultOption(content) {
|
93
|
-
const resultOption = this.resultOptionTemplate.content.cloneNode(true)
|
100
|
+
newResultOption(content: DocumentFragment) {
|
101
|
+
const resultOption = (this.resultOptionTemplate as HTMLTemplateElement).content.cloneNode(true) as Element
|
94
102
|
resultOption.querySelector('slot[name="content"]').replaceWith(content)
|
95
103
|
return resultOption
|
96
104
|
}
|
@@ -100,9 +108,9 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
100
108
|
const previousIndex = currentIndex - 1
|
101
109
|
const previousOptionItem = (
|
102
110
|
this.resultOptionItems[previousIndex] ||
|
103
|
-
|
104
|
-
)
|
105
|
-
previousOptionItem.focus()
|
111
|
+
this.resultOptionItems[this.resultOptionItems.length - 1]
|
112
|
+
);
|
113
|
+
(previousOptionItem as HTMLElement).focus()
|
106
114
|
}
|
107
115
|
|
108
116
|
focusNextOption() {
|
@@ -110,9 +118,9 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
110
118
|
const nextIndex = currentIndex + 1
|
111
119
|
const nextOptionItem = (
|
112
120
|
this.resultOptionItems[nextIndex] ||
|
113
|
-
|
114
|
-
)
|
115
|
-
nextOptionItem.focus()
|
121
|
+
this.resultOptionItems[0]
|
122
|
+
);
|
123
|
+
(nextOptionItem as HTMLElement).focus()
|
116
124
|
}
|
117
125
|
|
118
126
|
get resultOptionItems() {
|
@@ -134,11 +142,11 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
134
142
|
get searchContext() {
|
135
143
|
if (this._searchContext) return this._searchContext
|
136
144
|
|
137
|
-
const selector = this.element.dataset.searchContextValueSelector
|
138
|
-
if (selector) return (
|
145
|
+
const selector = (this.element as HTMLElement).dataset.searchContextValueSelector
|
146
|
+
if (selector) return ((
|
139
147
|
this.element.parentNode.querySelector(selector) ||
|
140
|
-
|
141
|
-
).value
|
148
|
+
this.element.closest(selector)
|
149
|
+
) as HTMLInputElement).value
|
142
150
|
|
143
151
|
return null
|
144
152
|
}
|
@@ -151,7 +159,7 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
151
159
|
return this.cacheKeyFor(this.searchTerm, this.searchContext)
|
152
160
|
}
|
153
161
|
|
154
|
-
cacheKeyFor(searchTerm, searchContext) {
|
162
|
+
cacheKeyFor(searchTerm: string, searchContext: string) {
|
155
163
|
return [searchTerm, JSON.stringify(searchContext)].join()
|
156
164
|
}
|
157
165
|
|
@@ -160,11 +168,11 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
160
168
|
}
|
161
169
|
|
162
170
|
get searchTermMinimumLength() {
|
163
|
-
return this.element.dataset.pbTypeaheadKitSearchTermMinimumLength
|
171
|
+
return (this.element as HTMLElement).dataset.pbTypeaheadKitSearchTermMinimumLength
|
164
172
|
}
|
165
173
|
|
166
174
|
get searchDebounceTimeout() {
|
167
|
-
return this.element.dataset.pbTypeaheadKitSearchDebounceTimeout
|
175
|
+
return (this.element as HTMLElement).dataset.pbTypeaheadKitSearchDebounceTimeout
|
168
176
|
}
|
169
177
|
|
170
178
|
get resultsElement() {
|
@@ -192,9 +200,9 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
192
200
|
)
|
193
201
|
}
|
194
202
|
|
195
|
-
toggleResultsLoadingIndicator(visible) {
|
196
|
-
var visibilityProperty = 0
|
197
|
-
if (visible) visibilityProperty = 1
|
203
|
+
toggleResultsLoadingIndicator(visible: boolean) {
|
204
|
+
var visibilityProperty = '0'
|
205
|
+
if (visible) visibilityProperty = '1'
|
198
206
|
this.resultsLoadingIndicator.style.opacity = visibilityProperty
|
199
207
|
}
|
200
208
|
}
|
@@ -18,7 +18,7 @@ type UserProps = {
|
|
18
18
|
data?: {[key: string]: string},
|
19
19
|
id?: string,
|
20
20
|
name?: string,
|
21
|
-
orientation?: "
|
21
|
+
orientation?: "horizontal" | "vertical",
|
22
22
|
size?: "sm" | "md" | "lg",
|
23
23
|
subtitle?: string | Array<Node> | Node,
|
24
24
|
territory?: string,
|
@@ -48,3 +48,17 @@
|
|
48
48
|
.z_index_10 {
|
49
49
|
z-index: 1000;
|
50
50
|
}
|
51
|
+
|
52
|
+
$zIndex_values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
|
53
|
+
|
54
|
+
@each $size, $size_value in $breakpoints_grid {
|
55
|
+
@each $zIndex_value in $zIndex_values {
|
56
|
+
$min_size: map-get($size_value, "min");
|
57
|
+
$max_size: map-get($size_value, "max");
|
58
|
+
.z_index_#{$size}_#{$zIndex_value} {
|
59
|
+
@include break_on($min_size, $max_size) {
|
60
|
+
z-index: #{$zIndex_value * 100} !important;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
@@ -113,9 +113,11 @@ type Shadow = {
|
|
113
113
|
|
114
114
|
type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
|
115
115
|
|
116
|
+
type ZIndexType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
|
117
|
+
type ZIndexResponsiveType = {[key: string]: ZIndexType}
|
116
118
|
type ZIndex = {
|
117
|
-
zIndex?:
|
118
|
-
}
|
119
|
+
zIndex?: ZIndexType,
|
120
|
+
} | ZIndexResponsiveType
|
119
121
|
|
120
122
|
// keep this as the last type definition
|
121
123
|
export type GlobalProps = AlignContent & AlignItems & AlignSelf &
|
@@ -178,9 +180,19 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
178
180
|
css += maxWidth ? `max_width_${maxWidth } ` : ''
|
179
181
|
return css
|
180
182
|
},
|
181
|
-
zIndexProps: (
|
183
|
+
zIndexProps: (zIndex: ZIndex) => {
|
182
184
|
let css = ''
|
183
|
-
|
185
|
+
Object.entries(zIndex).forEach((zIndexEntry) => {
|
186
|
+
if (zIndexEntry[0] == "zIndex") {
|
187
|
+
if (typeof zIndexEntry[1] == "number") {
|
188
|
+
css += `z_index_${zIndexEntry[1]} `
|
189
|
+
} else if (typeof zIndexEntry[1] == "object") {
|
190
|
+
Object.entries(zIndexEntry[1]).forEach((zIndexObj) => {
|
191
|
+
css += `z_index_${zIndexObj[0]}_${zIndexObj[1]} `
|
192
|
+
})
|
193
|
+
}
|
194
|
+
}
|
195
|
+
})
|
184
196
|
return css
|
185
197
|
},
|
186
198
|
shadowProps: ({ shadow }: Shadow) => {
|