phlex_ui 0.1.6 → 0.1.7

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: 443bba42189a98a9688d7218421e85da741c759ee3e9d7720817d4623ebbb85e
4
- data.tar.gz: 92b24956dbcb18b4ba30be83a9f1fa736e9679fad74eb36522a1a8b97f085e0c
3
+ metadata.gz: 1db25a586afbbb6554e100020c190c9aa8af7c1614f43360706527cb5096304c
4
+ data.tar.gz: c8c4f8ee86d194ff6b196dd48e2e92c3903513bb58933eeb72c5ada2ec68e033
5
5
  SHA512:
6
- metadata.gz: 589b3e9cf3fdd3c09cb137d6dd8183d3ffed38a4ab87329337224e2320b9555b45b201df3006002c55f04011564be28719775fac8c12d459cc61601bf1553c76
7
- data.tar.gz: e5fbd20b89c5a55f9aefe048f74d19f6241c0b7af7d047405a455b785d8d84251ce528dcd8a1198a6c5ed62a23cfa8e1908b2d8fbd4da5f70457b3135893b67f
6
+ metadata.gz: 8b8f07f52de3a9c716938cac850e602cddb98ff82378661f0e4ab8f082a5dfccdc396c9ffd8cad2bc90934bbc0f29250009f1ee08f48ec1b2dc9a89c99f10135
7
+ data.tar.gz: cae1c1771af47e3e6573a8e34a80599ae5bc29473f9fd1b7d366bd53e44e2097f7d6251b874377fac6118b84c288b3ebbc01e87a0f453d7de98eba4b41f60a8d
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Body < Base
5
- def template
6
- table(**attrs)
7
- end
4
+ class Calendar::Body < Base
5
+ def template
6
+ table(**attrs)
7
+ end
8
8
 
9
- private
9
+ private
10
10
 
11
- def default_attrs
12
- {
13
- data: {
14
- calendar_target: "calendar"
15
- },
16
- }
17
- end
11
+ def default_attrs
12
+ {
13
+ data: {
14
+ calendar_target: "calendar"
15
+ }
16
+ }
18
17
  end
19
- end
18
+ end
19
+ end
@@ -1,104 +1,104 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Days < Base
5
- BASE_CLASS = "inline-flex items-center justify-center rounded-md text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-8 w-8 p-0 font-normal aria-selected:opacity-100"
4
+ class Calendar::Days < Base
5
+ BASE_CLASS = "inline-flex items-center justify-center rounded-md text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-8 w-8 p-0 font-normal aria-selected:opacity-100"
6
6
 
7
- def template
8
- render_selected_date_template
9
- render_today_date_template
10
- render_current_month_date_template
11
- render_other_month_date_template
12
- end
7
+ def template
8
+ render_selected_date_template
9
+ render_today_date_template
10
+ render_current_month_date_template
11
+ render_other_month_date_template
12
+ end
13
13
 
14
- private
14
+ private
15
15
 
16
- def render_selected_date_template
17
- date_template("selectedDateTemplate") do
18
- button(
19
- data_day: "{{day}}",
20
- data_action: " click->calendar#selectDay",
21
- name: "day",
22
- class:
23
- tokens(
24
- BASE_CLASS,
25
- "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground"
26
- ),
27
- role: "gridcell",
28
- tabindex: "0",
29
- type: "button",
30
- aria_selected: "true"
31
- ) { "{{dayDate}}" }
32
- end
33
- end
16
+ def render_selected_date_template
17
+ date_template("selectedDateTemplate") do
18
+ button(
19
+ data_day: "{{day}}",
20
+ data_action: " click->calendar#selectDay",
21
+ name: "day",
22
+ class:
23
+ tokens(
24
+ BASE_CLASS,
25
+ "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground"
26
+ ),
27
+ role: "gridcell",
28
+ tabindex: "0",
29
+ type: "button",
30
+ aria_selected: "true"
31
+ ) { "{{dayDate}}" }
32
+ end
33
+ end
34
34
 
35
- def render_today_date_template
36
- date_template("todayDateTemplate") do
37
- button(
38
- data_day: "{{day}}",
39
- data_action: " click->calendar#selectDay",
40
- name: "day",
41
- class:
42
- tokens(
43
- BASE_CLASS,
44
- "bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
45
- ),
46
- role: "gridcell",
47
- tabindex: "-1",
48
- type: "button"
49
- ) { "{{dayDate}}" }
50
- end
51
- end
35
+ def render_today_date_template
36
+ date_template("todayDateTemplate") do
37
+ button(
38
+ data_day: "{{day}}",
39
+ data_action: " click->calendar#selectDay",
40
+ name: "day",
41
+ class:
42
+ tokens(
43
+ BASE_CLASS,
44
+ "bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
45
+ ),
46
+ role: "gridcell",
47
+ tabindex: "-1",
48
+ type: "button"
49
+ ) { "{{dayDate}}" }
50
+ end
51
+ end
52
52
 
53
- def render_current_month_date_template
54
- date_template("currentMonthDateTemplate") do
55
- button(
56
- data_day: "{{day}}",
57
- data_action: " click->calendar#selectDay",
58
- name: "day",
59
- class:
60
- tokens(
61
- BASE_CLASS,
62
- "bg-background text-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
63
- ),
64
- role: "gridcell",
65
- tabindex: "-1",
66
- type: "button"
67
- ) { "{{dayDate}}" }
68
- end
69
- end
53
+ def render_current_month_date_template
54
+ date_template("currentMonthDateTemplate") do
55
+ button(
56
+ data_day: "{{day}}",
57
+ data_action: " click->calendar#selectDay",
58
+ name: "day",
59
+ class:
60
+ tokens(
61
+ BASE_CLASS,
62
+ "bg-background text-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
63
+ ),
64
+ role: "gridcell",
65
+ tabindex: "-1",
66
+ type: "button"
67
+ ) { "{{dayDate}}" }
68
+ end
69
+ end
70
70
 
71
- def render_other_month_date_template
72
- date_template("otherMonthDateTemplate") do
73
- button(
74
- data_day: "{{day}}",
75
- data_action: " click->calendar#selectDay",
76
- name: "day",
77
- class:
78
- tokens(
79
- BASE_CLASS,
80
- "bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
81
- ),
82
- role: "gridcell",
83
- tabindex: "-1",
84
- type: "button"
85
- ) { "{{dayDate}}" }
86
- end
87
- end
71
+ def render_other_month_date_template
72
+ date_template("otherMonthDateTemplate") do
73
+ button(
74
+ data_day: "{{day}}",
75
+ data_action: " click->calendar#selectDay",
76
+ name: "day",
77
+ class:
78
+ tokens(
79
+ BASE_CLASS,
80
+ "bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground"
81
+ ),
82
+ role: "gridcell",
83
+ tabindex: "-1",
84
+ type: "button"
85
+ ) { "{{dayDate}}" }
86
+ end
87
+ end
88
88
 
89
- def date_template(target, &block)
90
- template_tag(data: { calendar_target: target }) do
91
- td(
92
- class:
93
- "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected])]:rounded-md",
94
- role: "presentation",
95
- &block
96
- )
97
- end
98
- end
89
+ def date_template(target, &block)
90
+ template_tag(data: {calendar_target: target}) do
91
+ td(
92
+ class:
93
+ "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected])]:rounded-md",
94
+ role: "presentation",
95
+ &block
96
+ )
97
+ end
98
+ end
99
99
 
100
- def default_attrs
101
- {}
102
- end
100
+ def default_attrs
101
+ {}
103
102
  end
104
- end
103
+ end
104
+ end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Header < Base
5
- def template(&block)
6
- div(**attrs, &block)
7
- end
4
+ class Calendar::Header < Base
5
+ def template(&block)
6
+ div(**attrs, &block)
7
+ end
8
8
 
9
- private
9
+ private
10
10
 
11
- def default_attrs
12
- {
13
- class: "flex justify-center pt-1 relative items-center",
14
- }
15
- end
11
+ def default_attrs
12
+ {
13
+ class: "flex justify-center pt-1 relative items-center"
14
+ }
16
15
  end
17
- end
16
+ end
17
+ end
@@ -1,43 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Next < Base
5
- def template(&block)
6
- button(**attrs) do
7
- icon
8
- end
9
- end
4
+ class Calendar::Next < Base
5
+ def template(&block)
6
+ button(**attrs) do
7
+ icon
8
+ end
9
+ end
10
10
 
11
- private
11
+ private
12
12
 
13
- def icon
14
- svg(
15
- width: "15",
16
- height: "15",
17
- viewbox: "0 0 15 15",
18
- fill: "none",
19
- xmlns: "http://www.w3.org/2000/svg",
20
- class: "h-4 w-4"
21
- ) do |s|
22
- s.path(
23
- d:
24
- "M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",
25
- fill: "currentColor",
26
- fill_rule: "evenodd",
27
- clip_rule: "evenodd"
28
- )
29
- end
30
- end
13
+ def icon
14
+ svg(
15
+ width: "15",
16
+ height: "15",
17
+ viewbox: "0 0 15 15",
18
+ fill: "none",
19
+ xmlns: "http://www.w3.org/2000/svg",
20
+ class: "h-4 w-4"
21
+ ) do |s|
22
+ s.path(
23
+ d:
24
+ "M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",
25
+ fill: "currentColor",
26
+ fill_rule: "evenodd",
27
+ clip_rule: "evenodd"
28
+ )
29
+ end
30
+ end
31
31
 
32
- def default_attrs
33
- {
34
- name: "next-month",
35
- aria_label: "Go to next month",
36
- class:
37
- "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input hover:bg-accent hover:text-accent-foreground h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute right-1",
38
- type: "button",
39
- data_action: "click->calendar#nextMonth"
40
- }
41
- end
32
+ def default_attrs
33
+ {
34
+ name: "next-month",
35
+ aria_label: "Go to next month",
36
+ class:
37
+ "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input hover:bg-accent hover:text-accent-foreground h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute right-1",
38
+ type: "button",
39
+ data_action: "click->calendar#nextMonth"
40
+ }
42
41
  end
43
- end
42
+ end
43
+ end
@@ -1,43 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Prev < Base
5
- def template(&block)
6
- button(**attrs) do
7
- icon
8
- end
9
- end
4
+ class Calendar::Prev < Base
5
+ def template(&block)
6
+ button(**attrs) do
7
+ icon
8
+ end
9
+ end
10
10
 
11
- private
11
+ private
12
12
 
13
- def icon
14
- svg(
15
- width: "15",
16
- height: "15",
17
- viewbox: "0 0 15 15",
18
- fill: "none",
19
- xmlns: "http://www.w3.org/2000/svg",
20
- class: "h-4 w-4"
21
- ) do |s|
22
- s.path(
23
- d:
24
- "M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z",
25
- fill: "currentColor",
26
- fill_rule: "evenodd",
27
- clip_rule: "evenodd"
28
- )
29
- end
30
- end
13
+ def icon
14
+ svg(
15
+ width: "15",
16
+ height: "15",
17
+ viewbox: "0 0 15 15",
18
+ fill: "none",
19
+ xmlns: "http://www.w3.org/2000/svg",
20
+ class: "h-4 w-4"
21
+ ) do |s|
22
+ s.path(
23
+ d:
24
+ "M8.84182 3.13514C9.04327 3.32401 9.05348 3.64042 8.86462 3.84188L5.43521 7.49991L8.86462 11.1579C9.05348 11.3594 9.04327 11.6758 8.84182 11.8647C8.64036 12.0535 8.32394 12.0433 8.13508 11.8419L4.38508 7.84188C4.20477 7.64955 4.20477 7.35027 4.38508 7.15794L8.13508 3.15794C8.32394 2.95648 8.64036 2.94628 8.84182 3.13514Z",
25
+ fill: "currentColor",
26
+ fill_rule: "evenodd",
27
+ clip_rule: "evenodd"
28
+ )
29
+ end
30
+ end
31
31
 
32
- def default_attrs
33
- {
34
- name: "previous-month",
35
- aria_label: "Go to previous month",
36
- class:
37
- "rdp-button_reset rdp-button inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input hover:bg-accent hover:text-accent-foreground h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute left-1",
38
- type: "button",
39
- data_action: "click->calendar#prevMonth"
40
- }
41
- end
32
+ def default_attrs
33
+ {
34
+ name: "previous-month",
35
+ aria_label: "Go to previous month",
36
+ class:
37
+ "rdp-button_reset rdp-button inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input hover:bg-accent hover:text-accent-foreground h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute left-1",
38
+ type: "button",
39
+ data_action: "click->calendar#prevMonth"
40
+ }
42
41
  end
43
- end
42
+ end
43
+ end
@@ -1,27 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Title < Base
5
- def initialize(default: "Month Year", **attrs)
6
- @default = default
7
- super(**attrs)
8
- end
4
+ class Calendar::Title < Base
5
+ def initialize(default: "Month Year", **attrs)
6
+ @default = default
7
+ super(**attrs)
8
+ end
9
9
 
10
- def template
11
- div(**attrs) { @default }
12
- end
10
+ def template
11
+ div(**attrs) { @default }
12
+ end
13
13
 
14
- private
14
+ private
15
15
 
16
- def default_attrs
17
- {
18
- class: "text-sm font-medium",
19
- aria_live: "polite",
20
- role: "presentation",
21
- data: {
22
- calendar_target: "title"
23
- }
24
- }
25
- end
16
+ def default_attrs
17
+ {
18
+ class: "text-sm font-medium",
19
+ aria_live: "polite",
20
+ role: "presentation",
21
+ data: {
22
+ calendar_target: "title"
23
+ }
24
+ }
26
25
  end
27
- end
26
+ end
27
+ end
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar::Weekdays < Base
5
- DAYS = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday].freeze
4
+ class Calendar::Weekdays < Base
5
+ DAYS = %w[Monday Tuesday Wednesday Thursday Friday Saturday Sunday].freeze
6
6
 
7
- def template
8
- template_tag(data: { calendar_target: "weekdaysTemplate" }) do
9
- thead(**attrs) do
10
- tr(class: "flex") do
11
- DAYS.each do |day|
12
- render_day(day)
13
- end
14
- end
15
- end
7
+ def template
8
+ template_tag(data: {calendar_target: "weekdaysTemplate"}) do
9
+ thead(**attrs) do
10
+ tr(class: "flex") do
11
+ DAYS.each do |day|
12
+ render_day(day)
16
13
  end
14
+ end
17
15
  end
16
+ end
17
+ end
18
18
 
19
- private
19
+ private
20
20
 
21
- def render_day(day)
22
- th(
23
- scope: "col",
24
- class: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
25
- aria_label: day
26
- ) { day[0..1] }
27
- end
21
+ def render_day(day)
22
+ th(
23
+ scope: "col",
24
+ class: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
25
+ aria_label: day
26
+ ) { day[0..1] }
27
+ end
28
28
 
29
- def default_attrs
30
- {}
31
- end
29
+ def default_attrs
30
+ {}
32
31
  end
33
- end
32
+ end
33
+ end
@@ -1,39 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Calendar < Base
5
- def initialize(selected_date: nil, input_id: nil, date_format: 'yyyy-MM-dd', **attrs)
6
- @selected_date = selected_date
7
- @input_id = input_id
8
- @date_format = date_format
9
- super(**attrs)
10
- end
4
+ class Calendar < Base
5
+ def initialize(selected_date: nil, input_id: nil, date_format: "yyyy-MM-dd", **attrs)
6
+ @selected_date = selected_date
7
+ @input_id = input_id
8
+ @date_format = date_format
9
+ super(**attrs)
10
+ end
11
11
 
12
- def template
13
- div(**attrs) do
14
- render PhlexUI::Calendar::Header.new do
15
- render PhlexUI::Calendar::Title.new
16
- render PhlexUI::Calendar::Prev.new
17
- render PhlexUI::Calendar::Next.new
18
- end
19
- render PhlexUI::Calendar::Body.new # Where the calendar is rendered (Weekdays and Days)
20
- render PhlexUI::Calendar::Weekdays.new # Template for the weekdays
21
- render PhlexUI::Calendar::Days.new # Template for the days
22
- end
12
+ def template
13
+ div(**attrs) do
14
+ render PhlexUI::Calendar::Header.new do
15
+ render PhlexUI::Calendar::Title.new
16
+ render PhlexUI::Calendar::Prev.new
17
+ render PhlexUI::Calendar::Next.new
23
18
  end
19
+ render PhlexUI::Calendar::Body.new # Where the calendar is rendered (Weekdays and Days)
20
+ render PhlexUI::Calendar::Weekdays.new # Template for the weekdays
21
+ render PhlexUI::Calendar::Days.new # Template for the days
22
+ end
23
+ end
24
24
 
25
- private
25
+ private
26
26
 
27
- def default_attrs
28
- {
29
- class: "p-3 space-y-4",
30
- data: {
31
- controller: "calendar",
32
- calendar_selected_date_value: @selected_date&.to_s,
33
- calendar_format_value: @date_format,
34
- calendar_input_outlet: @input_id,
35
- },
36
- }
37
- end
27
+ def default_attrs
28
+ {
29
+ class: "p-3 space-y-4",
30
+ data: {
31
+ controller: "calendar",
32
+ calendar_selected_date_value: @selected_date&.to_s,
33
+ calendar_format_value: @date_format,
34
+ calendar_input_outlet: @input_id
35
+ }
36
+ }
38
37
  end
39
- end
38
+ end
39
+ end
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexUI
4
- class Command::Dialog < Base
5
- def template(&block)
6
- div(**attrs, &block)
7
- end
4
+ class Command::Dialog < Base
5
+ def template(&block)
6
+ div(**attrs, &block)
7
+ end
8
8
 
9
- private
9
+ private
10
10
 
11
- def default_attrs
12
- {
13
- data: { controller: "dialog" }
14
- }
15
- end
11
+ def default_attrs
12
+ {
13
+ data: {controller: "dialog"}
14
+ }
16
15
  end
17
- end
16
+ end
17
+ end