playbook_ui 13.0.0 → 13.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68b8019423c98f0b17cb991be96ff5eaf31f5ec127a81e1079f1d30d89bf2f8a
4
- data.tar.gz: 266d1ba7ec9735ab40b632b590b448742429e780ef5635f92bd9e74b0e0fc6df
3
+ metadata.gz: ebfbb350f5457ca825d0c7991f1e2fff2dd63e1a925523715b154af8f9b3b233
4
+ data.tar.gz: 96c352b2239aa01b2b30446b23520322494ca2d72cd62c456b6835f9f1a6656e
5
5
  SHA512:
6
- metadata.gz: b2a9a36c332c8f6cf8ced66861d01e6bccaf17d6ace709c3c1e3a180f89a145d8d4d98beecf8ba52cbdde6d41129238df73b0c364e9997ae4f225587a6d85c11
7
- data.tar.gz: 4f42ad5ca624705aa6139ebf6b698ede8350fe94dd30fafbce662a433c6a898fd16ee47d22710ca648999c4bbd4ef9457458acc44c9c35f0d22823e84276d2bd
6
+ metadata.gz: 681a3e6dc4fd90450765d3fd35d34b7dd08b67c67ae79f529b6f18498a8fe986b73360cb06c310eac254307139a2405b51b67d7488ed5983a8cc3daf0130c26f
7
+ data.tar.gz: af4a5c732a179ca234c04c2dad6835fb3201687233cc49353f0e73f1cf49ddc408b5570b9846d297d109c2a012b62534ba8f669dba5c6a5f006aeaa5f80a7c44
@@ -3,4 +3,11 @@
3
3
  border: 1px #ccc dashed;
4
4
  text-align: center;
5
5
  }
6
+ ::file-selector-button {
7
+ visibility: hidden;
8
+ padding: 0;
9
+ border: none;
10
+ width: 0;
11
+ }
6
12
  }
13
+
@@ -1,7 +0,0 @@
1
- This kit provides a drag and drop interface for file uploads. Currently, the kit leverages [react-dropzone](https://github.com/react-dropzone/react-dropzone).
2
-
3
- ### Props
4
-
5
- `accept: [String]` Use this prop to set the list of valid file types
6
- `customMessage: [String]` Use this prop to set a custom message, replacing the default text
7
- `onFilesAccepted: Function` The callback function, providing the list of dropped files
@@ -0,0 +1,7 @@
1
+ <%= pb_rails("file_upload", props: {id: "import_file"}) do %>
2
+ <input
3
+ id="import_file"
4
+ type="file"
5
+ name="import_file"
6
+ />
7
+ <% end %>
@@ -0,0 +1 @@
1
+ The `id` for the File Upload and the existing input you are choosing to wrap with our Kit with must match each other. This will ensure that the click on the button a.k.a, the underlying label's `for`, triggers the File Upload.
@@ -0,0 +1,3 @@
1
+ <%= pb_rails("file_upload") %>
2
+
3
+
@@ -1,6 +1,8 @@
1
1
  examples:
2
2
 
3
3
  rails:
4
+ - file_upload_default: File Upload
5
+ - file_upload_custom: Custom
4
6
 
5
7
  react:
6
8
  - file_upload_default: Default List of files to upload
@@ -0,0 +1,25 @@
1
+
2
+ <div class="pb_file_upload_kit" id="import_file">
3
+ <div class="pb_form_group_kit cursor_pointer">
4
+ <label for="import_file" class="pb_button_kit_secondary_inline_enabled">Upload File</label>
5
+ <div class="pb_text_input_kit">
6
+ <div class=" text_input_wrapper">
7
+ <input placeholder="custom-placeholder" id="import_file" type="file">
8
+ </div>
9
+ </div>
10
+ </div>
11
+ </div>
12
+
13
+ <h1>not custom</h1>
14
+
15
+ <div class="pb_file_upload_kit" id="test">
16
+ <div class="pb_form_group_kit cursor_pointer">
17
+ <label for="upload-test" class="pb_button_kit_secondary_inline_enabled">Upload File</label>
18
+ <div class="pb_text_input_kit">
19
+ <div class=" text_input_wrapper">
20
+ <input class="text_input cursor_pointer" id="upload-test" type="file" classname="cursor_pointer">
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </div>
25
+
@@ -0,0 +1,17 @@
1
+ <%= content_tag("div",
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id) do %>
6
+ <%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
7
+ <label for="upload-<%= object.id %>" class="pb_button_kit_secondary_inline_enabled"><%= "#{object.label}" %></label>
8
+ <%= pb_rails("text_input", props: {
9
+ type: "file",
10
+ input_options: {
11
+ id: "upload-#{object.id}",
12
+ classname: "cursor_pointer",
13
+ }.merge(object.input_options)
14
+ }) %>
15
+ <% end %>
16
+ </label>
17
+ <% end %>
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbFileUpload
5
+ class FileUpload < Playbook::KitBase
6
+ prop :accept, type: Playbook::Props::String,
7
+ default: ""
8
+
9
+ prop :files, type: Playbook::Props::Array,
10
+ default: []
11
+
12
+ prop :label, type: Playbook::Props::String,
13
+ default: "Upload File"
14
+
15
+ prop :placeholder, type: Playbook::Props::String,
16
+ default: "No file"
17
+
18
+ prop :full_width, type: Playbook::Props::Boolean,
19
+ default: false
20
+
21
+ prop :input_options, type: Playbook::Props::Hash,
22
+ default: {}
23
+
24
+ def classname
25
+ file_upload_class = generate_classname("pb_file_upload_kit")
26
+ file_upload_class + full_width_class
27
+ end
28
+
29
+ def full_width_class
30
+ full_width ? " full_width" : ""
31
+ end
32
+ end
33
+ end
34
+ end
@@ -17,92 +17,97 @@ const formatDate = (newDate: Date | string) => {
17
17
 
18
18
  export const toMinute = (newDate: Date | string, timeZone?: string): string => {
19
19
  const date = formatDate(newDate)
20
+
20
21
  if (timeZone) {
21
- return date.toLocaleTimeString(undefined, { timeZone, hour: "2-digit", minute: "2-digit" }).slice(3, 5);
22
+ return date.toLocaleTimeString("en-US", { timeZone, hour: "2-digit", minute: "2-digit" }).slice(3, 5);
22
23
  } else {
23
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" }).slice(3, 5);
24
+ return date.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }).slice(3, 5);
24
25
  }
25
26
  }
26
27
 
27
28
  export const toHour = (newDate: Date | string, timeZone?: string): string => {
28
29
  const date = formatDate(newDate)
30
+
29
31
  if (timeZone) {
30
- return date.toLocaleTimeString(undefined, { timeZone, hour: "numeric" }).split(' ')[0];
32
+ return date.toLocaleTimeString("en-US", { timeZone, hour: "numeric" }).split(' ')[0];
31
33
  } else {
32
- return date.toLocaleTimeString(undefined, { hour: "numeric" }).split(' ')[0];
34
+ return date.toLocaleTimeString("en-US", { hour: "numeric" }).split(' ')[0];
33
35
  }
34
36
  }
35
37
 
36
38
  export const toDay = (newDate: Date | string, timeZone?: string): number => {
37
- if (timeZone) {
38
- const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
39
- return date.getDate()
40
- } else {
41
- const date = formatDate(newDate)
42
- return date.getDate()
43
- }
39
+ if (timeZone) {
40
+ const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
41
+ return date.getDate()
42
+ } else {
43
+ const date = formatDate(newDate)
44
+ return date.getDate()
45
+ }
44
46
  }
45
47
 
46
48
  export const toDayAbbr = (newDate: Date | string): string => {
47
49
  const date = formatDate(newDate)
48
- return ABBR_DAYS[date.getUTCDay()]
50
+ return ABBR_DAYS[date.getDay()]
49
51
  }
50
52
 
51
53
  export const toWeekday = (newDate: Date | string): string => {
52
- const date = formatDate(newDate)
53
- return days[date.getUTCDay()]
54
+ const date = formatDate(newDate)
55
+ return days[date.getDay()]
54
56
  }
55
57
 
56
58
  export const toMonth = (newDate: Date | string, timeZone?: string): string => {
57
- if (timeZone) {
58
- const date = new Date(formatDate(newDate).toLocaleString(undefined, { timeZone }));
59
- return months[date.getUTCMonth()]
60
- } else {
61
- const date = formatDate(newDate)
62
- return months[date.getUTCMonth()]
63
- }
59
+ if (timeZone) {
60
+ const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
61
+ return months[date.getMonth()]
62
+ } else {
63
+ const date = formatDate(newDate)
64
+ return months[date.getMonth()]
65
+ }
64
66
  }
65
67
 
66
68
  export const toMonthNum = (newDate: Date | string): number => {
67
69
  const date = formatDate(newDate)
68
- return date.getUTCMonth() +1
70
+ return date.getMonth() + 1
69
71
  }
70
72
 
71
73
  export const toYear = (newDate: Date | string, timeZone?: string): number => {
72
- if (timeZone) {
73
- const date = new Date(newDate.toLocaleString(undefined, { timeZone }));
74
- return date.getUTCFullYear()
75
- } else {
76
- const date = new Date(newDate)
77
- return date.getUTCFullYear()
78
- }
74
+ if (timeZone) {
75
+ const date = new Date(formatDate(newDate).toLocaleString("en-US", { timeZone }));
76
+ return date.getFullYear()
77
+ } else {
78
+ const date = formatDate(newDate)
79
+ return date.getFullYear()
80
+ }
79
81
  }
80
82
 
81
83
  export const toTime = (newDate: Date | string, timeZone?: string): string => {
82
84
  const date = formatDate(newDate)
85
+
83
86
  if (timeZone) {
84
- return date.toLocaleTimeString(undefined, { timeZone, timeStyle: "short" }).split(' ')[0];
87
+ return date.toLocaleTimeString("en-US", { timeZone, timeStyle: "short" }).split(' ')[0];
85
88
  } else {
86
- return date.toLocaleTimeString(undefined, { timeStyle: "short" }).split(' ')[0];
89
+ return date.toLocaleTimeString("en-US", { timeStyle: "short" }).split(' ')[0];
87
90
  }
88
91
  }
89
92
 
90
93
  export const toMeridiem = (newDate: Date | string, timeZone?: string): string => {
91
- const date = formatDate(newDate)
92
- if (timeZone) {
93
- return date.toLocaleString(undefined, { timeZone, hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
94
- } else {
95
- return date.toLocaleString(undefined, { hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
96
- }
94
+ const date = formatDate(newDate)
95
+
96
+ if (timeZone) {
97
+ return date.toLocaleString("en-US", { timeZone, hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
98
+ } else {
99
+ return date.toLocaleString("en-US", { hour12: true }).slice(-2).charAt(0).toLocaleLowerCase();
100
+ }
97
101
  }
98
102
 
99
103
  export const toTimeZone = (newDate: Date | string, timeZone?: string): string => {
100
- const date = formatDate(newDate)
101
- if (timeZone) {
102
- return date.toLocaleString(undefined, { timeZone, timeZoneName: "short" }).split(' ')[3];
103
- } else {
104
- return date.toLocaleString(undefined, { timeZoneName: "short" }).split(' ')[3];
105
- }
104
+ const date = formatDate(newDate)
105
+
106
+ if (timeZone) {
107
+ return date.toLocaleString("en-US", { timeZone, timeZoneName: "short" }).split(' ')[3];
108
+ } else {
109
+ return date.toLocaleString("en-US", { timeZoneName: "short" }).split(' ')[3];
110
+ }
106
111
  }
107
112
 
108
113
  export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): string => {
@@ -111,15 +116,17 @@ export const toTimeWithMeridiem = (newDate: Date | string, timeZone: string): st
111
116
  }
112
117
 
113
118
  export const toIso = (newDate: Date | string): string => {
114
- const date = formatDate(newDate)
115
- return date.toISOString()
119
+ const date = formatDate(newDate)
120
+ return date.toISOString()
116
121
  }
117
122
 
118
123
  export const fromNow = (newDate: Date | string): string => {
119
124
  const startDate = formatDate(newDate).getTime()
120
125
  const endDate = new Date().getTime()
121
126
  const elapsedTime = endDate - startDate
122
- let elapsedTimeString = `${Math.round(elapsedTime / (365.25 * 24 * 60 * 60 * 1000))} years ago.`; // 730+ days
127
+ let elapsedTimeString = `${Math.round(elapsedTime / (365.25 * 24 * 60 * 60 * 1000))} years ago`; // 730+ days
128
+
129
+ const MILLISECONDS_IN_A_MONTH = 30.44 * 24 * 60 * 60 * 1000
123
130
 
124
131
  const elapsedTimeData = [
125
132
  { min: 0, max: 44999, value: "a few seconds ago" }, // 0-44 seconds
@@ -130,7 +137,7 @@ export const fromNow = (newDate: Date | string): string => {
130
137
  { min: 75700000, max: 172899999, value: "a day ago" }, // 22-48 hours
131
138
  { min: 172900000, max: 2169999999, value: `${Math.round(elapsedTime / 86400000)} days ago`}, // 2-25 days
132
139
  { min: 2170000000, max: 5184999999, value: "a month ago"}, // 26-60 days
133
- { min: 5185000000, max: 27561699999, value: `${Math.round(elapsedTime / 30.44 * 24 * 60 * 60 * 1000)} months ago`}, // 60-319 days
140
+ { min: 5185000000, max: 27561699999, value: `${Math.round(elapsedTime / MILLISECONDS_IN_A_MONTH)} months ago`}, // 60-319 days
134
141
  { min: 27561700000, max: 63072999999, value: "a year ago"}, // 320-730 days
135
142
  ];
136
143
 
@@ -149,7 +156,7 @@ export const toCustomFormat = (newDate: Date | string, format = 'month_day'): st
149
156
  if (format == "month_day") {
150
157
  return `${toMonthNum(date)}/${toDay(date)}`
151
158
  } else {
152
- return `${date.toLocaleString(undefined, { month: "short" })} ${toDay(date)}`
159
+ return `${date.toLocaleString("en-US", { month: "short" })} ${toDay(date)}`
153
160
  }
154
161
  }
155
162
 
@@ -70,7 +70,6 @@
70
70
  @-moz-document url-prefix() {
71
71
  .passphrase-popover {
72
72
  position: relative;
73
- top: $space_sm;
74
73
  left: -($space_xs * 1.5);
75
74
  }
76
75
  }
@@ -68,7 +68,7 @@ const Time = (props: TimeProps) => {
68
68
  )
69
69
  )}
70
70
 
71
- <time dateTime={date.toString()}>
71
+ <time dateTime={date.toLocaleString()}>
72
72
  <span>
73
73
  {unstyled
74
74
  ? (