playbook_ui 7.0.0.pre.alpha11 → 7.0.0.pre.alpha12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_date_picker/_date_picker.html.erb +19 -15
  3. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +1 -3
  4. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +2 -2
  5. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +29 -16
  6. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.html.erb +1 -2
  7. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.jsx +1 -2
  8. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -0
  9. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_format.html.erb +4 -0
  10. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_format.jsx +4 -0
  11. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_input.html.erb +9 -9
  12. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_input.jsx +8 -8
  13. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_input.md +3 -1
  14. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.html.erb +1 -0
  15. data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range.jsx +1 -0
  16. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +1 -1
  17. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +1 -1
  18. data/app/pb_kits/playbook/pb_form/docs/_form_simple_form.html.erb +17 -3
  19. data/app/pb_kits/playbook/pb_form/docs/_form_simple_form_validate.html.erb +3 -3
  20. data/app/pb_kits/playbook/pb_form/form_builder/date_picker_field.rb +32 -1
  21. data/lib/playbook/version.rb +1 -1
  22. data/lib/tasks/pb_release.rake +5 -1
  23. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e23c8fdddf3856d91cd2669f81dfeb607eb5cdd8eb78036ee8d25f369789cd86
4
- data.tar.gz: 644b79c7f3e469781e44390f426f889919ac950aa21cf441d477bd2302d1898c
3
+ metadata.gz: 94ac0232046d608bf8ae158596a7734d1b67f23fb91b1c64b30baede6f4ad758
4
+ data.tar.gz: eed40c32073db9ff048cb4c7b965dbef077058dacaff858e9a753da281fcf881
5
5
  SHA512:
6
- metadata.gz: 73a27538028125d8e714c9c7e61536a190f9dbcf84178b405d7b47d44d20f3656b6cf5f0024fcc6b13794293f4704883bccd6f34838d814780f9449929ffa99d
7
- data.tar.gz: d2058ae5504a9ce734f94fccd9ae69096dbb1683f4096e4db14416aa7bfb207c9700002d748d4f8ffba72492e35e280e5787cbe7f04f0c92a027c2b69f8b28e7
6
+ metadata.gz: ea8f2b075e31b0bdc0cf3d9dea2b386912492c3d046095e86775e6b54e8368f3af077446962cb0cdf8ba06046ee5d7153cc354cf331f6dd8bc3308888dff529c
7
+ data.tar.gz: 771928c8397ce43f9f038b9d64c8e358e1380e7f41fa51770df2742ccef8aee5de38dbd9cf0ec139accf029be26d8d7db8baacda51b7efcb5fc1efaf7845537b
@@ -3,21 +3,25 @@
3
3
  class: object.classname + object.error_class,
4
4
  data: object.data,
5
5
  id: object.id) do %>
6
- <div class="input_wrapper">
7
- <%= pb_rails("text_input", props: {
8
- aria: object.input_aria,
9
- autocomplete: false,
10
- dark: object.dark,
11
- data: object.input_data,
12
- disabled: object.disable_input,
13
- error: object.error,
14
- id: object.picker_id,
15
- label: object.hide_label ? nil : object.label,
16
- name: object.name,
17
- placeholder: object.placeholder,
18
- required: object.required,
19
- type: object.type
20
- }) %>
6
+ <% if object.children %>
7
+ <div class="input_wrapper">
8
+ <%= capture(&object.children) %>
9
+ <% else %>
10
+ <div class="input_wrapper">
11
+ <%= pb_rails("text_input", props: {
12
+ aria: object.input_aria,
13
+ autocomplete: false,
14
+ dark: object.dark,
15
+ data: object.input_data,
16
+ disabled: object.disable_input,
17
+ error: object.error,
18
+ id: object.picker_id,
19
+ label: object.hide_label ? nil : object.label,
20
+ name: object.name,
21
+ placeholder: object.placeholder,
22
+ required: object.required,
23
+ }) %>
24
+ <% end %>
21
25
  <% if !object.hide_icon %>
22
26
  <div
23
27
  class="<%= object.icon_wrapper_class %>"
@@ -62,8 +62,7 @@ const DatePicker = (props: DatePickerProps) => {
62
62
  name,
63
63
  onChange = () => {},
64
64
  pickerId,
65
- placeholder,
66
- type,
65
+ placeholder = 'Select Date',
67
66
  yearRange = [ 1900, 2100 ],
68
67
  } = props
69
68
 
@@ -128,7 +127,6 @@ const DatePicker = (props: DatePickerProps) => {
128
127
  label={hideLabel ? null : label}
129
128
  name={name}
130
129
  placeholder={placeholder}
131
- type={type}
132
130
  />
133
131
  <If condition={!hideIcon}>
134
132
  <div
@@ -41,10 +41,10 @@ module Playbook
41
41
  default: "single"
42
42
  prop :picker_id, type: Playbook::Props::String,
43
43
  required: true
44
- prop :placeholder, type: Playbook::Props::String
44
+ prop :placeholder, type: Playbook::Props::String,
45
+ default: "Select Date"
45
46
  prop :required, type: Playbook::Props::Boolean,
46
47
  default: false
47
- prop :type, type: Playbook::Props::String
48
48
  prop :year_range, type: Playbook::Props::Array,
49
49
  default: [1900, 2100]
50
50
 
@@ -11,7 +11,7 @@ const datePickerHelper = (config) => {
11
11
  maxDate,
12
12
  minDate,
13
13
  mode,
14
- onChange,
14
+ onChange = () => {},
15
15
  pickerId,
16
16
  yearRange,
17
17
  } = config
@@ -21,20 +21,25 @@ const datePickerHelper = (config) => {
21
21
  // ===========================================================
22
22
 
23
23
  const defaultDateGetter = () => {
24
- if (defaultDate !== '') {
25
- if (defaultDate === 'blank') {
26
- return ''
27
- } else {
28
- return defaultDate
29
- }
30
- }
31
- if (mode === 'single' && defaultDate === '') {
32
- return new Date()
33
- } else if (mode === 'range' && defaultDate === '') {
34
- const today = new Date()
35
- const tomorrow = new Date(today)
36
- tomorrow.setDate(tomorrow.getDate() + 1)
37
- return [today, tomorrow]
24
+ // if (defaultDate !== '') {
25
+ // if (defaultDate === 'blank') {
26
+ // return ''
27
+ // } else {
28
+ // return defaultDate
29
+ // }
30
+ // }
31
+ // if (mode === 'single' && defaultDate === '') {
32
+ // return new Date()
33
+ // } else if (mode === 'range' && defaultDate === '') {
34
+ // const today = new Date()
35
+ // const tomorrow = new Date(today)
36
+ // tomorrow.setDate(tomorrow.getDate() + 1)
37
+ // return [today, tomorrow]
38
+ // }
39
+ if (defaultDate === '') {
40
+ return null
41
+ } else {
42
+ return defaultDate
38
43
  }
39
44
  }
40
45
  const disabledParser = () => {
@@ -102,7 +107,11 @@ const datePickerHelper = (config) => {
102
107
  }],
103
108
  onChange: [(selectedDates, dateStr) => {
104
109
  onChange(dateStr, selectedDates)
105
- }],
110
+ },
111
+ (selectedDates, dateStr) => {
112
+ updateValueOnChange(dateStr)
113
+ },
114
+ ],
106
115
  onYearChange: [],
107
116
  prevArrow: '<i class="far fa-angle-left"></i>',
108
117
  static: true,
@@ -161,6 +170,10 @@ const datePickerHelper = (config) => {
161
170
  dropdown.value = picker.currentYear
162
171
  }
163
172
  })
173
+ // Update input value attribute on Change
174
+ const updateValueOnChange = (pickerValue) => {
175
+ picker.input.setAttribute('value', pickerValue)
176
+ }
164
177
  if (allowInput){
165
178
  picker.input.removeAttribute('readonly')
166
179
  }
@@ -18,7 +18,6 @@
18
18
  }) %>
19
19
 
20
20
  <%= pb_rails("date_picker", props: {
21
- default_date: "blank",
22
- label: "Blank",
21
+ label: "Default Behavior",
23
22
  picker_id: "date-picker-default-date4"
24
23
  }) %>
@@ -20,8 +20,7 @@ const DatePickerDefaultDate = () => (
20
20
  pickerId="date-picker-default-date3"
21
21
  />
22
22
  <DatePicker
23
- defaultDate="blank"
24
- label="Blank"
23
+ label="Default Behavior"
25
24
  pickerId="date-picker-default-date4"
26
25
  />
27
26
  </div>
@@ -0,0 +1 @@
1
+ The `defaultDate`/`default_date` prop has a null or empty string value by default. You can pass a string or date object if you want a default value on page load.
@@ -1,19 +1,23 @@
1
1
  <%= pb_rails("date_picker", props: {
2
+ default_date: (Date.today).httpdate,
2
3
  format: "m-d-Y",
3
4
  picker_id: "date-picker-format1"
4
5
  }) %>
5
6
 
6
7
  <%= pb_rails("date_picker", props: {
8
+ default_date: (Date.today).httpdate,
7
9
  format: "m/d/y",
8
10
  picker_id: "date-picker-format2"
9
11
  }) %>
10
12
 
11
13
  <%= pb_rails("date_picker", props: {
14
+ default_date: (Date.today).httpdate,
12
15
  format: "n-j-y",
13
16
  picker_id: "date-picker-format3"
14
17
  }) %>
15
18
 
16
19
  <%= pb_rails("date_picker", props: {
20
+ default_date: (Date.today).httpdate,
17
21
  format: "Y-d-m",
18
22
  picker_id: "date-picker-format4"
19
23
  }) %>
@@ -4,18 +4,22 @@ import { DatePicker } from '../../'
4
4
  const DatePickerFormat = () => (
5
5
  <div>
6
6
  <DatePicker
7
+ defaultDate={new Date()}
7
8
  format="m-d-Y"
8
9
  pickerId="date-picker-format1"
9
10
  />
10
11
  <DatePicker
12
+ defaultDate={new Date()}
11
13
  format="m/d/y"
12
14
  pickerId="date-picker-format2"
13
15
  />
14
16
  <DatePicker
17
+ defaultDate={new Date()}
15
18
  format="n-j-y"
16
19
  pickerId="date-picker-format3"
17
20
  />
18
21
  <DatePicker
22
+ defaultDate={new Date()}
19
23
  format="Y-d-m"
20
24
  pickerId="date-picker-format4"
21
25
  />
@@ -1,26 +1,26 @@
1
1
  <%= pb_rails("date_picker", props: {
2
2
  input_aria: { label: "input-field" },
3
3
  input_data: { key: "value", key2: "value2" },
4
+ label: "Aria, Name, and Data Attributes",
4
5
  name: "date-field",
5
6
  picker_id: "date-picker-input1",
6
- type: "date"
7
7
  }) %>
8
8
 
9
9
  <%= pb_rails("date_picker", props: {
10
- default_date: "blank",
10
+ label: "Custom Placeholder",
11
11
  picker_id: "date-picker-input2",
12
- placeholder: "Select Date",
12
+ placeholder: "custom-placeholder",
13
13
  }) %>
14
14
 
15
15
  <%= pb_rails("date_picker", props: {
16
- default_date: "blank",
17
- disable_input: true,
16
+ label: "Blank Placeholder",
18
17
  picker_id: "date-picker-input3",
19
- placeholder: "Disabled Input"
18
+ placeholder: "",
20
19
  }) %>
21
20
 
22
21
  <%= pb_rails("date_picker", props: {
23
- dark: true,
24
- hide_label: true,
25
- picker_id: "date-picker-input4"
22
+ disable_input: true,
23
+ label: "Disable Input",
24
+ picker_id: "date-picker-input4",
25
+ placeholder: "Disabled Input"
26
26
  }) %>
@@ -6,25 +6,25 @@ const DatePickerInput = () => (
6
6
  <DatePicker
7
7
  inputAria={{ label: 'input-field' }}
8
8
  inputData={{ key: 'value', key2: 'value2' }}
9
+ label="Aria, Name, and Data Attributes"
9
10
  name="date-field"
10
11
  pickerId="date-picker-input1"
11
- type="date"
12
12
  />
13
13
  <DatePicker
14
- defaultDate="blank"
14
+ label="Custom Placeholder"
15
15
  pickerId="date-picker-input2"
16
- placeholder="Select Date"
16
+ placeholder="custom-placeholder"
17
17
  />
18
18
  <DatePicker
19
- defaultDate="blank"
20
- disableInput
19
+ label="Blank Placeholder"
21
20
  pickerId="date-picker-input3"
22
- placeholder="Disabled Input"
21
+ placeholder=""
23
22
  />
24
23
  <DatePicker
25
- dark
26
- hideLabel
24
+ disableInput
25
+ label="Disable Input"
27
26
  pickerId="date-picker-input4"
27
+ placeholder="Disabled Input"
28
28
  />
29
29
  </div>
30
30
  )
@@ -1,3 +1,5 @@
1
1
  The date picker is built with the text input kit. Text input props you pass to the date picker kit will be forwarded to the input, with a few exceptions. The `value` attribute is automatically handled and bound to whatever date string is contained by the input field. You cannot pass a custom value prop. `id` props passed to the date picker kit will be assigned to it's parent/wrapper div. The `pickerId` prop is passed directly to the input and is required to instatiate the date picker.
2
2
 
3
- You must use `inputAria` or `input_aria` and `inputData` or `input_data` props if you wish to pass data or aria attributes to the text input kit. If you use `data` or `aria` props they will be passed to the date picker kit itself instead. Also be aware the default behavior of text input aria and data props is to pass those props to attributes on the wrapping div not on the input itself.
3
+ You must use `inputAria` or `input_aria` and `inputData` or `input_data` props if you wish to pass data or aria attributes to the text input kit. If you use `data` or `aria` props they will be passed to the date picker kit itself instead. Also be aware the default behavior of text input aria and data props is to pass those props to attributes on the wrapping div not on the input itself.
4
+
5
+ The placeholder prop has a default string value: "Select Date". You can replace this with your own string or an empty string if you'd prefer it blank.
@@ -1,4 +1,5 @@
1
1
  <%= pb_rails("date_picker", props: {
2
+ default_date: [(Date.today).httpdate, (Date.today + 7).httpdate],
2
3
  mode: "range",
3
4
  picker_id: "date-picker-range"
4
5
  }) %>
@@ -4,6 +4,7 @@ import { DatePicker } from '../../'
4
4
  const DatePickerRange = () => (
5
5
  <div>
6
6
  <DatePicker
7
+ defaultDate={[new Date(), new Date().fp_incr(6)]}
7
8
  mode="range"
8
9
  pickerId="date-picker-range"
9
10
  />
@@ -33,7 +33,7 @@
33
33
  name: "checkbox-name",
34
34
  class: "checkbox-class"
35
35
  %>
36
- <%= form.date_picker :example_date_picker1, props: { default_date: "blank" } %>
36
+ <%= form.date_picker :example_date_picker1, props: { default_date: "blank", label: true } %>
37
37
 
38
38
  <%= form.actions do |action| %>
39
39
  <%= action.submit %>
@@ -28,7 +28,7 @@
28
28
  <%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
29
29
  <%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
30
30
  <%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
31
- <%= form.date_picker :example_date_picker2, props: { default_date: 'blank', required: true } %>
31
+ <%= form.date_picker :example_date_picker2, props: { default_date: 'blank', required: true, label: "hello-label" } %>
32
32
 
33
33
  <%= form.actions do |action| %>
34
34
  <%= action.submit %>
@@ -14,13 +14,24 @@
14
14
  :example_text_area,
15
15
  :example_select_field,
16
16
  :example_collection_select_field,
17
- :example_checkbox_field
18
- :example_date_picker_field1
17
+ :example_checkbox_field,
18
+ :example_checkbox_field_2,
19
+ :example_date_picker_field_1,
20
+ :example_date_picker_field_3
21
+
22
+ # for local testing only
23
+ # will be removed before merging
24
+ def initialize
25
+ # @example_number_field = 123
26
+ @example_date_picker_field_1 = "10/02/1993"
27
+ @example_date_picker_field_3 = Date.today.httpdate
28
+ end
19
29
 
20
30
 
21
31
  def self.model_name
22
32
  ActiveModel::Name.new(self, nil, "ExampleFormModel")
23
33
  end
34
+
24
35
  end
25
36
  %>
26
37
 
@@ -41,6 +52,7 @@
41
52
 
42
53
 
43
54
  <%= pb_rails("form", props: { form_system: "simple_form", form_system_options: [example_form_model.new, url: "", method: :get] }) do |form| %>
55
+
44
56
  <%= form.input :example_text_field, as: :string %>
45
57
  <%= form.input :example_phone_field, as: :tel %>
46
58
  <%= form.input :example_email_field, as: :email %>
@@ -52,7 +64,9 @@
52
64
  <%= form.select :example_select_field, [["Yes", 1], ["No", 2]], props: { label: true } %>
53
65
  <%= form.collection_select :example_collection_select_field, example_collection, :value, :name, props: { label: true } %>
54
66
  <%= form.check_box :example_checkbox_field, props: { text: "Example Checkbox", label: true } %>
55
- <%= form.date_picker :example_date_picker_field1, props: { default_date: 'blank' } %>
67
+ <%= form.check_box :example_checkbox_field_2, props: { text: "Example Checkbox", label: true } %>
68
+ <%= form.date_picker :example_date_picker_field_1, props: { default_date: 'blank', label: true } %>
69
+ <%= form.date_picker :example_date_picker_field_3, props: { default_date: 'blank', label: true } %>
56
70
 
57
71
  <%= form.actions do |action| %>
58
72
  <%= action.submit %>
@@ -14,8 +14,8 @@
14
14
  :example_text_area,
15
15
  :example_select_field,
16
16
  :example_collection_select_field,
17
- :example_checkbox_field
18
- :example_date_picker_field2
17
+ :example_checkbox_field,
18
+ :example_date_picker_field_2
19
19
 
20
20
 
21
21
  def self.model_name
@@ -52,7 +52,7 @@
52
52
  <%= form.select :example_select_field, [["Yes", 1], ["No", 2]], props: { required: true, blank_selection: "Select One...", label: true } %>
53
53
  <%= form.collection_select :example_collection_select_field, example_collection, :value, :name, props: { required: true, blank_selection: "Select One...", label: true } %>
54
54
  <%= form.check_box :example_checkbox_field, props: { text: "Example Checkbox", label: true, required: true } %>
55
- <%= form.date_picker :example_date_picker_field2, props: { default_date: 'blank', required: true } %>
55
+ <%= form.date_picker :example_date_picker_field_2, props: { default_date: 'blank', required: true } %>
56
56
 
57
57
  <%= form.actions do |action| %>
58
58
  <%= action.submit %>
@@ -11,10 +11,41 @@ module Playbook
11
11
 
12
12
  props[:name] = html_attribute_name
13
13
  props[:picker_id] = html_id
14
+ props[:label] = @template.label(@object_name, name) if props[:label] == true
14
15
 
15
- @template.pb_rails("date_picker", props: props)
16
+ puts @object.to_json
17
+
18
+ input = text_field(
19
+ name,
20
+ autocomplete: "off",
21
+ disabled: props[:disable_input],
22
+ data: props[:input_data],
23
+ aria: props[:input_aria],
24
+ props: {
25
+ error: props[:error],
26
+ label: props[:label],
27
+ placeholder: props[:placeholder],
28
+ required: props[:required],
29
+ }
30
+ )
31
+ puts input
32
+
33
+ @template.pb_rails("date_picker", props: props) do
34
+ input
35
+ end
16
36
  end
17
37
  end
18
38
  end
19
39
  end
20
40
  end
41
+
42
+ # Create text input with rails form helper
43
+ # pass options to text input
44
+
45
+ # add hidden, implicit prop identifying it as form helper
46
+ # inside dp erb, create conditional if check to leave out text_input kit
47
+
48
+ # pass that input as a block to @template.pb_rails("date_picker")
49
+ # let rails do the magic
50
+
51
+ # null value handling
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Playbook
3
- VERSION = "7.0.0.pre.alpha11"
3
+ VERSION = "7.0.0.pre.alpha12"
4
4
  end
@@ -62,10 +62,14 @@ namespace :pb_release do
62
62
  `rm -rf playbook_ui-*.gem`
63
63
 
64
64
  # NPM
65
+ puts "\nGenerating distribution files"
66
+ `docker-compose run web yarn release`
67
+ puts "\nOrganizing distribution files"
68
+ `rm dist/playbook-rails.css && mv dist/playbook-react.css dist/playbook.css`
65
69
  puts "\nCreating NPM package..."
66
70
  `npm pack`
67
71
  puts "\nPublishing to NPM..."
68
- `npm publish`
72
+ `npm publish playbook-ui-#{version}.tgz`
69
73
  puts "\nPublished to NPM. Now lets clean up..."
70
74
  `rm -rf playbook-ui-*.tgz`
71
75
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.pre.alpha11
4
+ version: 7.0.0.pre.alpha12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-29 00:00:00.000000000 Z
12
+ date: 2020-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -689,6 +689,7 @@ files:
689
689
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.jsx
690
690
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.html.erb
691
691
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.jsx
692
+ - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md
692
693
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_disabled.html.erb
693
694
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_disabled.jsx
694
695
  - app/pb_kits/playbook/pb_date_picker/docs/_date_picker_error.html.erb
@@ -1855,8 +1856,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1855
1856
  - !ruby/object:Gem::Version
1856
1857
  version: 1.3.1
1857
1858
  requirements: []
1858
- rubyforge_project:
1859
- rubygems_version: 2.7.3
1859
+ rubygems_version: 3.1.4
1860
1860
  signing_key:
1861
1861
  specification_version: 4
1862
1862
  summary: Playbook Design System