playbook_ui 14.9.0.pre.rc.5 → 14.9.0.pre.rc.7
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/_playbook.scss +1 -0
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +63 -12
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +2 -1
- data/app/pb_kits/playbook/pb_typeahead/index.ts +29 -3
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +5 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +4 -0
- data/app/pb_kits/playbook/tokens/_height.scss +19 -0
- data/app/pb_kits/playbook/tokens/exports/_height.module.scss +37 -0
- data/app/pb_kits/playbook/utilities/_height.scss +33 -0
- data/app/pb_kits/playbook/utilities/_max_width.scss +4 -0
- data/app/pb_kits/playbook/utilities/_min_width.scss +1 -1
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +0 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +24 -0
- data/dist/chunks/{_typeahead-D0PihN_3.js → _typeahead-C8Q_fFYF.js} +2 -2
- data/dist/chunks/{_weekday_stacked-uMIX8f-A.js → _weekday_stacked-Cup4SPuD.js} +1 -1
- data/dist/chunks/{lib-BC6ESsxG.js → lib-SyD3buPZ.js} +1 -1
- data/dist/chunks/{pb_form_validation-B_Z9rEbg.js → pb_form_validation-Dt8UJgrJ.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/classnames.rb +3 -0
- data/lib/playbook/forms/builder/typeahead_field.rb +13 -0
- data/lib/playbook/height.rb +29 -0
- data/lib/playbook/kit_base.rb +16 -1
- data/lib/playbook/max_height.rb +29 -0
- data/lib/playbook/min_height.rb +29 -0
- data/lib/playbook/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a873f79ad37157b40632f9496af3b021318e1990b47d68020378eabf7d5fd763
|
4
|
+
data.tar.gz: ff4dca04a1216da4cee0ca387267cd3d7e3363486d9220e8d2c45aaa243634ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e529e5af7a2e2a1b24e1d0eb8bf24f4d1793d07539fe2ee18a4902649b1e9bb14d4e92d7d409e8fb3ca2f02b6033767df8bd8030cd3aaaac69972836f56c65c
|
7
|
+
data.tar.gz: d8de91df2e0d3cf27a0c053c215838755abe9d138d22dc24b4105f15e3acd3f13a8adbf756cc6a23cbf68e6a0d134d5b8c0b8d16be3b1636daf8b6f0f3d528a9
|
@@ -23,7 +23,7 @@
|
|
23
23
|
%>
|
24
24
|
|
25
25
|
<%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
|
26
|
-
<%= form.typeahead :
|
26
|
+
<%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
|
27
27
|
<%= form.text_field :example_text_field, props: { label: true } %>
|
28
28
|
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
|
29
29
|
<%= form.email_field :example_email_field, props: { label: true } %>
|
@@ -92,7 +92,7 @@
|
|
92
92
|
const selectedUserData = JSON.parse(selectedUserJSON)
|
93
93
|
|
94
94
|
// set the input field's value
|
95
|
-
event.target.querySelector('input[name=
|
95
|
+
event.target.querySelector('input[name=example_typeahead]').value = selectedUserData.login
|
96
96
|
|
97
97
|
// log the selected option's dataset
|
98
98
|
console.log('The selected user data:')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= pb_form_with(scope: :example, url: "", method: :get, loading: true) do |form| %>
|
2
|
-
<%= form.text_field :
|
2
|
+
<%= form.text_field :example_text_field_loading, props: { label: true } %>
|
3
3
|
|
4
4
|
<%= form.actions do |action| %>
|
5
5
|
<%= action.submit %>
|
@@ -22,23 +22,74 @@
|
|
22
22
|
%>
|
23
23
|
|
24
24
|
<%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
|
25
|
-
<%= form.
|
26
|
-
<%= form.
|
27
|
-
<%= form.
|
28
|
-
<%= form.
|
29
|
-
<%= form.
|
30
|
-
<%= form.
|
31
|
-
<%= form.
|
32
|
-
<%= form.
|
33
|
-
<%= form.
|
34
|
-
<%= form.
|
35
|
-
<%= form.
|
25
|
+
<%= form.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
|
26
|
+
<%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
|
27
|
+
<%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field" } %>
|
28
|
+
<%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
|
29
|
+
<%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
|
30
|
+
<%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
|
31
|
+
<%= form.password_field :example_password_field_validation, props: { label: true, required: true } %>
|
32
|
+
<%= form.url_field :example_url_field_validation, props: { label: true, required: true } %>
|
33
|
+
<%= form.text_area :example_text_area_validation, props: { label: true, required: true } %>
|
34
|
+
<%= form.dropdown_field :example_dropdown_validation, props: { label: true, options: example_dropdown_options, required: true } %>
|
35
|
+
<%= form.select :example_select_validation, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
|
36
|
+
<%= form.collection_select :example_collection_select_validation, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
36
37
|
<%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
|
37
38
|
<%= form.date_picker :example_date_picker_2, props: { label: true, required: true } %>
|
38
|
-
<%= form.star_rating_field :
|
39
|
+
<%= form.star_rating_field :example_star_rating_validation, props: { variant: "interactive", label: true, required: true } %>
|
39
40
|
|
40
41
|
<%= form.actions do |action| %>
|
41
42
|
<%= action.submit %>
|
42
43
|
<%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
|
43
44
|
<% end %>
|
44
45
|
<% end %>
|
46
|
+
|
47
|
+
<!-- form.typeahead user results example template -->
|
48
|
+
<template data-typeahead-example-result-option>
|
49
|
+
<%= pb_rails("user", props: {
|
50
|
+
name: tag(:slot, name: "name"),
|
51
|
+
orientation: "horizontal",
|
52
|
+
align: "left",
|
53
|
+
avatar_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=",
|
54
|
+
avatar: true
|
55
|
+
}) %>
|
56
|
+
</template>
|
57
|
+
|
58
|
+
<!-- form.typeahead JS example implementation -->
|
59
|
+
<%= javascript_tag defer: "defer" do %>
|
60
|
+
document.addEventListener("pb-typeahead-kit-search", function(event) {
|
61
|
+
if (!event.target.dataset || !event.target.dataset.typeaheadExample2) return
|
62
|
+
|
63
|
+
fetch(`https://api.github.com/search/users?q=${encodeURIComponent(event.detail.searchingFor)}`)
|
64
|
+
.then(response => response.json())
|
65
|
+
.then((result) => {
|
66
|
+
const resultOptionTemplate = document.querySelector("[data-typeahead-example-result-option]")
|
67
|
+
|
68
|
+
event.detail.setResults((result.items || []).map((user) => {
|
69
|
+
const wrapper = resultOptionTemplate.content.cloneNode(true)
|
70
|
+
wrapper.children[0].dataset.user = JSON.stringify(user)
|
71
|
+
wrapper.querySelector('slot[name="name"]').replaceWith(user.login)
|
72
|
+
wrapper.querySelector('img').dataset.src = user.avatar_url
|
73
|
+
return wrapper
|
74
|
+
}))
|
75
|
+
})
|
76
|
+
})
|
77
|
+
|
78
|
+
|
79
|
+
document.addEventListener("pb-typeahead-kit-result-option-selected", function(event) {
|
80
|
+
if (!event.target.dataset.typeaheadExample2) return
|
81
|
+
|
82
|
+
const selectedUserJSON = event.detail.selected.firstElementChild.dataset.user
|
83
|
+
const selectedUserData = JSON.parse(selectedUserJSON)
|
84
|
+
|
85
|
+
// set the input field's value
|
86
|
+
event.target.querySelector('input[name=example_typeahead_validation]').value = selectedUserData.login
|
87
|
+
|
88
|
+
// log the selected option's dataset
|
89
|
+
console.log('The selected user data:')
|
90
|
+
console.dir(selectedUserData)
|
91
|
+
|
92
|
+
// do even more with the data later - TBD
|
93
|
+
event.target.dataset.user = selectedUserJSON
|
94
|
+
})
|
95
|
+
<% end %>
|
@@ -4,11 +4,12 @@ import { debounce } from 'lodash'
|
|
4
4
|
export default class PbTypeahead extends PbEnhancedElement {
|
5
5
|
_searchInput: HTMLInputElement
|
6
6
|
_resultsElement: HTMLElement
|
7
|
-
_debouncedSearch:
|
7
|
+
_debouncedSearch: () => void
|
8
8
|
_resultsLoadingIndicator: HTMLElement
|
9
9
|
_resultOptionTemplate: HTMLElement
|
10
10
|
_resultsOptionCache: Map<string, Array<DocumentFragment>>
|
11
11
|
_searchContext: string
|
12
|
+
_validSelection: boolean
|
12
13
|
|
13
14
|
static get selector() {
|
14
15
|
return '[data-pb-typeahead-kit]'
|
@@ -86,6 +87,9 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
86
87
|
const resultOption = (event.target as Element).closest('[data-result-option-item]')
|
87
88
|
if (!resultOption) return
|
88
89
|
|
90
|
+
this._validSelection = true
|
91
|
+
this.removeValidationError()
|
92
|
+
|
89
93
|
this.resultsCacheClear()
|
90
94
|
this.searchInputClear()
|
91
95
|
this.clearResults()
|
@@ -93,6 +97,28 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
93
97
|
this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
|
94
98
|
}
|
95
99
|
|
100
|
+
removeValidationError() {
|
101
|
+
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
102
|
+
if (inputWrapper) {
|
103
|
+
const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement
|
104
|
+
if (errorMessage) {
|
105
|
+
errorMessage.style.display = 'none'
|
106
|
+
}
|
107
|
+
this.searchInput.classList.remove('error')
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
showValidationError() {
|
112
|
+
const inputWrapper = this.searchInput.closest('.text_input_wrapper')
|
113
|
+
if (inputWrapper) {
|
114
|
+
const errorMessage = inputWrapper.querySelector('.pb_body_kit_negative') as HTMLElement
|
115
|
+
if (errorMessage) {
|
116
|
+
errorMessage.style.display = 'block'
|
117
|
+
}
|
118
|
+
this.searchInput.classList.add('error')
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
96
122
|
clearResults() {
|
97
123
|
this.resultsElement.innerHTML = ''
|
98
124
|
}
|
@@ -201,8 +227,8 @@ export default class PbTypeahead extends PbEnhancedElement {
|
|
201
227
|
}
|
202
228
|
|
203
229
|
toggleResultsLoadingIndicator(visible: boolean) {
|
204
|
-
|
230
|
+
let visibilityProperty = '0'
|
205
231
|
if (visible) visibilityProperty = '1'
|
206
232
|
this.resultsLoadingIndicator.style.opacity = visibilityProperty
|
207
233
|
}
|
208
|
-
}
|
234
|
+
}
|
@@ -17,11 +17,14 @@
|
|
17
17
|
<%= pb_rails("text_input", props: {
|
18
18
|
type: "search",
|
19
19
|
input_options: object.input_options,
|
20
|
-
label: object.label,
|
21
20
|
name: object.name,
|
22
21
|
value: object.value,
|
23
22
|
placeholder: object.placeholder,
|
24
23
|
margin_bottom: "none",
|
24
|
+
required: object.required,
|
25
|
+
validation: object.validation,
|
26
|
+
label: object.label,
|
27
|
+
id: object.input_options[:id],
|
25
28
|
}) %>
|
26
29
|
<%= pb_rails("list", props: { ordered: false, borderless: false, xpadding: true, role: "status", aria: { live: "polite" }, data: { pb_typeahead_kit_results: true } }) do %>
|
27
30
|
<% end %>
|
@@ -33,4 +36,4 @@
|
|
33
36
|
<% end %>
|
34
37
|
</template>
|
35
38
|
<% end %>
|
36
|
-
<% end %>
|
39
|
+
<% end %>
|
@@ -40,6 +40,10 @@ module Playbook
|
|
40
40
|
prop :pill_color, type: Playbook::Props::Enum,
|
41
41
|
values: %w[primary neutral success warning error info data_1 data_2 data_3 data_4 data_5 data_6 data_7 data_8 windows siding roofing doors gutters solar insulation accessories],
|
42
42
|
default: "primary"
|
43
|
+
prop :required, type: Playbook::Props::Boolean,
|
44
|
+
default: false
|
45
|
+
prop :validation, type: Playbook::Props::HashProp,
|
46
|
+
default: {}
|
43
47
|
|
44
48
|
def classname
|
45
49
|
default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
$height_auto: auto !default;
|
3
|
+
$height_xs: 320px !default;
|
4
|
+
$height_sm: 480px !default;
|
5
|
+
$height_md: 768px !default;
|
6
|
+
$height_lg: 1024px !default;
|
7
|
+
$height_xl: 1280px !default;
|
8
|
+
$height_2xl: 1440px !default;
|
9
|
+
$height_3xl: 1920px !default;
|
10
|
+
$heights: (
|
11
|
+
height_auto: $height_auto,
|
12
|
+
height_xs: $height_xs,
|
13
|
+
height_sm: $height_sm,
|
14
|
+
height_md: $height_md,
|
15
|
+
height_lg: $height_lg,
|
16
|
+
height_xl: $height_xl,
|
17
|
+
height_xxl: $height_2xl,
|
18
|
+
height_xxxl: $height_3xl
|
19
|
+
);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
@import "../height";
|
2
|
+
|
3
|
+
:export {
|
4
|
+
@mixin export_height($height_list) {
|
5
|
+
@each $name, $value in $height_list {
|
6
|
+
.#{$name} {
|
7
|
+
height: $value;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
@include export_height($heights);
|
13
|
+
}
|
14
|
+
|
15
|
+
:export {
|
16
|
+
@mixin export_max_height($height_list) {
|
17
|
+
@each $name, $value in $height_list {
|
18
|
+
.max_#{$name} {
|
19
|
+
max-height: $value;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@include export_max_height($heights);
|
25
|
+
}
|
26
|
+
|
27
|
+
:export {
|
28
|
+
@mixin export_min_height($height_list) {
|
29
|
+
@each $name, $value in $height_list {
|
30
|
+
.min_#{$name} {
|
31
|
+
min-height: $value;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
@include export_min_height($heights);
|
37
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
@import "../tokens/exports/height.module";
|
2
|
+
|
3
|
+
@mixin export_height($height_list) {
|
4
|
+
@each $name, $value in $height_list {
|
5
|
+
.#{$name} {
|
6
|
+
height: $value;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
@mixin export_max_height($height_list) {
|
12
|
+
@each $name, $value in $height_list {
|
13
|
+
.max_#{$name} {
|
14
|
+
max-height: $value;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
@mixin export_min_height($height_list) {
|
20
|
+
@each $name, $value in $height_list {
|
21
|
+
.min_#{$name} {
|
22
|
+
min-height: $value;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
@include export_height($heights);
|
28
|
+
@include export_max_height($heights);
|
29
|
+
@include export_min_height($heights);
|
30
|
+
|
31
|
+
.height-resize {
|
32
|
+
resize: vertical;
|
33
|
+
}
|
@@ -361,6 +361,30 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
|
|
361
361
|
css += maxWidth ? `max_width_${filterClassName(maxWidth)} ` : ''
|
362
362
|
return css.trimEnd()
|
363
363
|
},
|
364
|
+
minHeightProps: ({ minHeight }: MinHeight) => {
|
365
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
366
|
+
if (heightValues.includes(minHeight)) {
|
367
|
+
let css = ''
|
368
|
+
css += minHeight ? `min_height_${filterClassName(minHeight)} ` : ''
|
369
|
+
return css.trimEnd()
|
370
|
+
}
|
371
|
+
},
|
372
|
+
maxHeightProps: ({ maxHeight }: MaxHeight) => {
|
373
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
374
|
+
if (heightValues.includes(maxHeight)) {
|
375
|
+
let css = ''
|
376
|
+
css += maxHeight ? `max_height_${filterClassName(maxHeight)} ` : ''
|
377
|
+
return css.trimEnd()
|
378
|
+
}
|
379
|
+
},
|
380
|
+
heightProps: ({ height }: Height) => {
|
381
|
+
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
|
382
|
+
if (heightValues.includes(height)) {
|
383
|
+
let css = ''
|
384
|
+
css += height ? `height_${filterClassName(height)} ` : ''
|
385
|
+
return css.trimEnd()
|
386
|
+
}
|
387
|
+
},
|
364
388
|
zIndexProps: (zIndex: ZIndex) => {
|
365
389
|
let css = ''
|
366
390
|
Object.entries(zIndex).forEach((zIndexEntry) => {
|