coveragebook_components 0.7.1 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/build/coco/app.css +27 -20
  3. data/app/assets/build/coco/app.js +136 -309
  4. data/app/assets/build/coco/book.css +11 -7
  5. data/app/assets/build/coco/book.js +143 -185
  6. data/app/assets/js/coco.js +2 -30
  7. data/app/assets/js/{base/mixins → libs/alpine/directives}/undo.js +12 -13
  8. data/app/assets/js/libs/alpine/index.js +15 -13
  9. data/app/components/coco/app/blocks/slide_editor/slide_editor.html.erb +2 -1
  10. data/app/components/coco/app/blocks/slide_editor/slide_editor.js +0 -3
  11. data/app/components/coco/app/elements/{form_button/form_button.css → button_to/button_to.css} +1 -1
  12. data/app/components/coco/app/elements/{form_button/form_button.rb → button_to/button_to.rb} +1 -1
  13. data/app/components/coco/app/elements/color_picker/color_picker.js +0 -2
  14. data/app/components/coco/app/elements/image_picker/image_picker.js +0 -2
  15. data/app/components/coco/app/elements/link/link.css +11 -1
  16. data/app/components/coco/app/elements/link/link.rb +1 -0
  17. data/app/components/coco/app/elements/menu/menu.css +1 -1
  18. data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.html.erb +2 -1
  19. data/app/components/coco/app/elements/seamless_textarea/seamless_textarea.js +1 -7
  20. data/app/components/coco/app/elements/snackbar/snackbar.js +0 -2
  21. data/app/components/coco/app/elements/toast/toast.css +1 -1
  22. data/app/components/coco/app/elements/toast/toast.js +0 -2
  23. data/app/components/coco/base/button/button.js +0 -2
  24. data/app/components/coco/base/button/button.rb +3 -9
  25. data/app/components/coco/base/dropdown/dropdown.js +1 -3
  26. data/app/components/coco/base/link/link.css +11 -11
  27. data/app/components/coco/base/link/link.rb +1 -5
  28. data/app/components/coco/base/modal_dialog/modal_dialog.css +1 -1
  29. data/app/components/coco/concerns/acts_as_button_group.rb +1 -1
  30. data/app/helpers/coco/app_helper.rb +60 -37
  31. data/app/helpers/coco/base_helper.rb +2 -2
  32. data/app/helpers/coco/url_helper.rb +6 -12
  33. data/lib/coco.rb +1 -1
  34. metadata +12 -21
  35. data/app/assets/js/app/mixins/dropdown.js +0 -18
  36. data/app/assets/js/app/mixins/index.js +0 -3
  37. data/app/assets/js/base/mixins/attr-observer.js +0 -54
  38. data/app/assets/js/base/mixins/attrs.js +0 -58
  39. data/app/assets/js/base/mixins/dropdown.js +0 -69
  40. data/app/assets/js/base/mixins/index.js +0 -17
  41. data/app/assets/js/base/mixins/options.js +0 -76
  42. data/app/assets/js/base/mixins/size-observer.js +0 -34
  43. data/app/assets/js/base/mixins/tooltip.js +0 -81
  44. /data/app/assets/js/libs/alpine/{plugins → directives}/destroy.js +0 -0
  45. /data/app/assets/js/libs/alpine/{plugins → directives}/dimensions.js +0 -0
  46. /data/app/assets/js/libs/alpine/{plugins → directives}/dropdown.js +0 -0
  47. /data/app/assets/js/libs/alpine/{plugins → directives}/notification.js +0 -0
  48. /data/app/assets/js/libs/alpine/{plugins → directives}/options.js +0 -0
  49. /data/app/assets/js/libs/alpine/{plugins → directives}/tooltip.js +0 -0
  50. /data/app/components/coco/app/elements/{form_button/form_button.html.erb → button_to/button_to.html.erb} +0 -0
@@ -1,69 +0,0 @@
1
- import { tippy, hideOnEsc } from "@libs/tippy";
2
-
3
- export default function withDropdown(props = {}) {
4
- function withDropdownMixin(component) {
5
- const tippyEl = component.$refs.dropdownTrigger || component.$root;
6
-
7
- const dropdown = tippy(tippyEl, {
8
- trigger: "click",
9
- interactive: true,
10
- animation: false,
11
- content: component.$refs.dropdownPanel,
12
- plugins: [hideOnEsc],
13
-
14
- onMount() {
15
- if (component.onDropdownMount) {
16
- component.onDropdownMount();
17
- }
18
- },
19
-
20
- onCreate() {
21
- if (component.onDropdownCreate) {
22
- component.onDropdownCreate();
23
- }
24
- },
25
-
26
- onShow: () => {
27
- component.dropdown.open = true;
28
- if (component.onDropdownShow) {
29
- return component.onDropdownShow();
30
- }
31
-
32
- if (component.setState) {
33
- component.setState("active");
34
- }
35
- },
36
-
37
- onHide: () => {
38
- component.dropdown.open = false;
39
- if (component.onDropdownHide) {
40
- component.onDropdownHide();
41
- }
42
- if (component.resetState) {
43
- component.resetState();
44
- }
45
- },
46
-
47
- ...props,
48
- });
49
-
50
- return Object.assign(component, {
51
- dropdown: Alpine.reactive({
52
- instance: dropdown,
53
- open: false,
54
-
55
- hide() {
56
- this.instance.hide();
57
- },
58
-
59
- show() {
60
- this.instance.show();
61
- },
62
- }),
63
- });
64
- }
65
-
66
- withDropdownMixin.props = ["dropdown"];
67
-
68
- return withDropdownMixin;
69
- }
@@ -1,17 +0,0 @@
1
- import withAttrObserver from "./attr-observer";
2
- import withAttrs from "./attrs";
3
- import withDropdown from "./dropdown";
4
- import withOptions from "./options";
5
- import withSizeObserver from "./size-observer";
6
- import withTooltip from "./tooltip";
7
- import withUndo from "./undo";
8
-
9
- export {
10
- withAttrObserver,
11
- withAttrs,
12
- withDropdown,
13
- withOptions,
14
- withSizeObserver,
15
- withTooltip,
16
- withUndo,
17
- };
@@ -1,76 +0,0 @@
1
- import { kebabCase, camelCase } from "lodash";
2
-
3
- export default function withOptions(props = {}) {
4
- return function (component) {
5
- if (!component.options) {
6
- return component;
7
- }
8
-
9
- const el = component.$root;
10
- const oldDestroy = component.destroy;
11
- const optionsProps = component.options || {};
12
- const optionsAttrs = Object.keys(optionsProps).map(
13
- (name) => `data-${kebabCase(name)}`
14
- );
15
-
16
- Object.keys(optionsProps).forEach((name) => {
17
- const attrName = `data-${kebabCase(name)}`;
18
- if (el.hasAttribute(attrName)) {
19
- component.options[name] = el.getAttribute(attrName);
20
- }
21
- });
22
-
23
- let attrObserver = new MutationObserver((mutationsList) => {
24
- for (const mutation of mutationsList) {
25
- if (
26
- mutation.type !== "attributes" ||
27
- !optionsAttrs.includes(mutation.attributeName)
28
- ) {
29
- return;
30
- }
31
-
32
- const propName = camelCase(mutation.attributeName.replace("data-", ""));
33
- let value = mutation.target.getAttribute(mutation.attributeName);
34
-
35
- switch (value) {
36
- case "true":
37
- value = true;
38
- break;
39
- case "false":
40
- value = false;
41
- break;
42
- }
43
-
44
- component.options[propName] = value;
45
- }
46
- });
47
-
48
- Object.assign(
49
- component,
50
- Alpine.reactive({
51
- destroy() {
52
- attrObserver.disconnect();
53
- attrObserver = null;
54
-
55
- if (oldDestroy) {
56
- oldDestroy.call(this);
57
- }
58
- },
59
- })
60
- );
61
-
62
- attrObserver.observe(el, { attributes: true });
63
-
64
- component.$watch("options", (options, oldOptions) => {
65
- for (const [key, value] of Object.entries(options)) {
66
- el.setAttribute(`data-${kebabCase(key)}`, value);
67
-
68
- if (component.onOptionChange) {
69
- component.onOptionChange(key, value);
70
- }
71
- }
72
- });
73
-
74
- return component;
75
- };
76
- }
@@ -1,34 +0,0 @@
1
- export default function withSizeObserver(props = {}) {
2
- return function (component) {
3
- const resizeTarget = props.target || component.$root;
4
- const oldDestroy = component.destroy;
5
-
6
- const sizeObserver = Alpine.reactive({
7
- observer: null,
8
- handler(target) {
9
- if (component.onResize) {
10
- component.onResize(target.contentRect, target);
11
- }
12
- },
13
- });
14
-
15
- sizeObserver.observer = new ResizeObserver((entries) =>
16
- sizeObserver.handler(entries[0])
17
- );
18
-
19
- Object.assign(component, {
20
- destroy() {
21
- sizeObserver.observer.disconnect();
22
- sizeObserver.observer = null;
23
-
24
- if (oldDestroy) {
25
- oldDestroy.call(this);
26
- }
27
- },
28
- });
29
-
30
- sizeObserver.observer.observe(resizeTarget);
31
-
32
- return component;
33
- };
34
- }
@@ -1,81 +0,0 @@
1
- import tippy from "@libs/tippy";
2
-
3
- export default function withTooltip(props = {}) {
4
- function withTooltipMixin(component) {
5
- const el = component.$root;
6
- const oldDestroy = component.destroy;
7
-
8
- if (!component.hasData("tippy-content")) {
9
- component.setData("tippy-disabled", true);
10
- }
11
-
12
- const content = component.getData("tippy-content");
13
- const tooltip = tippy(el, {
14
- theme: "coco-tooltip",
15
-
16
- onShow() {
17
- if (component.onTooltipShow) {
18
- return component.onTooltipShow();
19
- } else {
20
- return component.refuteData("tippy-disabled", true);
21
- }
22
- },
23
-
24
- content() {
25
- return content;
26
- },
27
-
28
- ...props,
29
- });
30
-
31
- Object.assign(
32
- component,
33
- Alpine.reactive({
34
- tooltip: {
35
- content,
36
- instance: tooltip,
37
- originalContent: content,
38
- },
39
-
40
- getTooltip() {
41
- return this.tooltip;
42
- },
43
-
44
- setTooltip(content) {
45
- this.tooltip.content = content;
46
- },
47
-
48
- resetTooltip() {
49
- this.tooltip.content = this.tooltip.originalContent;
50
- },
51
-
52
- destroy() {
53
- if (this.tooltip && this.tooltip.instance) {
54
- this.tooltip.instance.destroy();
55
- this.tooltip = null;
56
- }
57
-
58
- if (oldDestroy) {
59
- oldDestroy.call(this);
60
- }
61
- },
62
- })
63
- );
64
-
65
- Alpine.effect(() => {
66
- if (component.tooltip && component.tooltip.instance) {
67
- const value = component.tooltip.content;
68
- if (value !== null) {
69
- component.tooltip.instance.setContent(value);
70
- component.setData("tippy-content", value);
71
- }
72
- }
73
- });
74
-
75
- return component;
76
- }
77
-
78
- withTooltipMixin.props = ["tooltip"];
79
-
80
- return withTooltipMixin;
81
- }