ariadne_view_components 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ariadne_view_components.js +1 -1
  3. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  4. data/app/components/ariadne/comment_component.html.erb +31 -37
  5. data/app/components/ariadne/comment_component.rb +9 -7
  6. data/app/components/ariadne/rich-text-area-component.ts +2 -2
  7. data/app/components/ariadne/tab_container_component.erb +1 -3
  8. data/app/lib/ariadne/action_view_extensions/form_helper.rb +1 -1
  9. data/lib/ariadne/view_components/version.rb +1 -1
  10. data/static/arguments.yml +2 -2
  11. data/static/classes.yml +4 -8
  12. data/static/constants.json +6 -5
  13. metadata +6 -41
  14. data/app/assets/builds/ariadne_view_components.css +0 -2355
  15. data/app/components/ariadne/ariadne-form-with.d.ts +0 -20
  16. data/app/components/ariadne/ariadne-form-with.js +0 -85
  17. data/app/components/ariadne/ariadne-form.d.ts +0 -22
  18. data/app/components/ariadne/ariadne-form.js +0 -84
  19. data/app/components/ariadne/ariadne.d.ts +0 -2
  20. data/app/components/ariadne/ariadne.js +0 -16
  21. data/app/components/ariadne/clipboard-copy-component.d.ts +0 -4
  22. data/app/components/ariadne/clipboard-copy-component.js +0 -18
  23. data/app/components/ariadne/clipboard_copy_component.d.ts +0 -4
  24. data/app/components/ariadne/clipboard_copy_component.js +0 -18
  25. data/app/components/ariadne/comment-component.d.ts +0 -0
  26. data/app/components/ariadne/comment-component.js +0 -33
  27. data/app/components/ariadne/comment-component.ts +0 -37
  28. data/app/components/ariadne/rich-text-area-component.d.ts +0 -4
  29. data/app/components/ariadne/rich-text-area-component.js +0 -27
  30. data/app/components/ariadne/slideover-component.d.ts +0 -9
  31. data/app/components/ariadne/slideover-component.js +0 -20
  32. data/app/components/ariadne/slideover_component.d.ts +0 -9
  33. data/app/components/ariadne/slideover_component.js +0 -19
  34. data/app/components/ariadne/tab-component.js +0 -1
  35. data/app/components/ariadne/tab-container-component copy.d.ts +0 -1
  36. data/app/components/ariadne/tab-container-component copy.js +0 -23
  37. data/app/components/ariadne/tab-container-component.d.ts +0 -1
  38. data/app/components/ariadne/tab-container-component.js +0 -23
  39. data/app/components/ariadne/tab-nav-component.d.ts +0 -9
  40. data/app/components/ariadne/tab-nav-component.js +0 -32
  41. data/app/components/ariadne/tabs-component.d.ts +0 -0
  42. data/app/components/ariadne/tabs-component.js +0 -1
  43. data/app/components/ariadne/time-ago-component.d.ts +0 -1
  44. data/app/components/ariadne/time-ago-component.js +0 -1
  45. data/app/components/ariadne/time_ago_component.d.ts +0 -1
  46. data/app/components/ariadne/time_ago_component.js +0 -1
  47. data/app/components/ariadne/tooltip-component.d.ts +0 -24
  48. data/app/components/ariadne/tooltip-component.js +0 -42
@@ -1,20 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { TemplateResult } from 'lit-html';
3
- declare type HTMLFormField = HTMLInputElement | HTMLButtonElement | HTMLSelectElement | HTMLTextAreaElement;
4
- export default class AriadneFormWith extends Controller {
5
- connect(): void;
6
- disconnect(): void;
7
- onBlur: (event: Event) => void;
8
- onSubmit: (event: Event) => void;
9
- validateForm(): boolean;
10
- validateField(field: HTMLFormField): boolean;
11
- shouldValidateField(field: HTMLFormField): boolean;
12
- refreshErrorForInvalidField(field: HTMLFormField, isValid: boolean): void;
13
- removeExistingErrorMessage(field: HTMLFormField): void;
14
- showErrorForInvalidField(field: HTMLFormField): void;
15
- buildFieldErrorHtml(field: HTMLFormField): string;
16
- get formFields(): HTMLFormField[];
17
- get firstInvalidField(): HTMLFormField | undefined;
18
- getRenderString: (data: TemplateResult) => string;
19
- }
20
- export {};
@@ -1,85 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { html } from 'lit-html';
3
- export default class AriadneFormWith extends Controller {
4
- constructor() {
5
- super(...arguments);
6
- this.onBlur = (event) => {
7
- this.validateField(event.target);
8
- };
9
- this.onSubmit = (event) => {
10
- var _a;
11
- if (!this.validateForm()) {
12
- event.preventDefault();
13
- (_a = this.firstInvalidField) === null || _a === void 0 ? void 0 : _a.focus();
14
- }
15
- };
16
- this.getRenderString = (data) => {
17
- const { strings, values } = data;
18
- const v = [...values, ''].map(e => (typeof e === 'object' ? this.getRenderString(e) : e));
19
- return strings.reduce((acc, s, i) => acc + s + v[i], '');
20
- };
21
- }
22
- connect() {
23
- this.element.setAttribute('novalidate', 'true');
24
- this.element.addEventListener('blur', this.onBlur, true);
25
- this.element.addEventListener('submit', this.onSubmit);
26
- this.element.addEventListener('ajax:beforeSend', this.onSubmit);
27
- }
28
- disconnect() {
29
- this.element.removeEventListener('blur', this.onBlur);
30
- this.element.removeEventListener('submit', this.onSubmit);
31
- this.element.removeEventListener('ajax:beforeSend', this.onSubmit);
32
- }
33
- validateForm() {
34
- let isValid = true;
35
- // Not using `find` because we want to validate all the fields
36
- for (const field of this.formFields) {
37
- if (this.shouldValidateField(field) && !this.validateField(field))
38
- isValid = false;
39
- }
40
- return isValid;
41
- }
42
- validateField(field) {
43
- if (!this.shouldValidateField(field))
44
- return true;
45
- const isValid = field.checkValidity();
46
- field.classList.toggle('invalid', !isValid);
47
- this.refreshErrorForInvalidField(field, isValid);
48
- return isValid;
49
- }
50
- shouldValidateField(field) {
51
- return !field.disabled && !['file', 'reset', 'submit', 'button'].includes(field.type);
52
- }
53
- refreshErrorForInvalidField(field, isValid) {
54
- this.removeExistingErrorMessage(field);
55
- if (!isValid)
56
- this.showErrorForInvalidField(field);
57
- }
58
- removeExistingErrorMessage(field) {
59
- var _a;
60
- const fieldContainer = field.closest('.field');
61
- if (!fieldContainer)
62
- return;
63
- const existingErrorMessageElement = fieldContainer.querySelector('.error');
64
- if (existingErrorMessageElement) {
65
- (_a = existingErrorMessageElement === null || existingErrorMessageElement === void 0 ? void 0 : existingErrorMessageElement.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(existingErrorMessageElement);
66
- }
67
- }
68
- showErrorForInvalidField(field) {
69
- field.insertAdjacentHTML('afterend', this.buildFieldErrorHtml(field));
70
- }
71
- buildFieldErrorHtml(field) {
72
- const data = html `<p class="error">${field.validationMessage}</p>`;
73
- return this.getRenderString(data);
74
- }
75
- get formFields() {
76
- return Array.from(this.element.children).filter(node => {
77
- const data = node.attributes.getNamedItem('data-ariadne-form-field');
78
- if ((data === null || data === void 0 ? void 0 : data.value) === 'true')
79
- return true;
80
- });
81
- }
82
- get firstInvalidField() {
83
- return this.formFields.find(field => !field.checkValidity());
84
- }
85
- }
@@ -1,22 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import type { TemplateResult } from 'lit-html';
3
- declare type HTMLFormField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
4
- export default class AriadneFormWith extends Controller {
5
- static targets: string[];
6
- readonly formFieldTargets: [HTMLFormField];
7
- connect(): void;
8
- disconnect(): void;
9
- onBlur: (event: Event) => void;
10
- onSubmit: (event: Event) => void;
11
- validateForm(): boolean;
12
- validateField(field: HTMLFormField): boolean;
13
- shouldValidateField(field: HTMLFormField): boolean;
14
- refreshErrorForInvalidField(field: HTMLFormField, isValid: boolean): void;
15
- removeExistingErrorMessage(field: HTMLFormField): void;
16
- showErrorForInvalidField(field: HTMLFormField): void;
17
- buildFieldErrorHtml(field: HTMLFormField): string;
18
- get formFields(): HTMLFormField[];
19
- get firstInvalidField(): HTMLFormField | undefined;
20
- getRenderString: (data: TemplateResult) => string;
21
- }
22
- export {};
@@ -1,84 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { html } from 'lit-html';
3
- export default class AriadneFormWith extends Controller {
4
- constructor() {
5
- super(...arguments);
6
- this.onBlur = (event) => {
7
- this.validateField(event.target);
8
- };
9
- this.onSubmit = (event) => {
10
- var _a;
11
- if (!this.validateForm()) {
12
- event.preventDefault();
13
- (_a = this.firstInvalidField) === null || _a === void 0 ? void 0 : _a.focus();
14
- }
15
- };
16
- this.getRenderString = (data) => {
17
- const { strings, values } = data;
18
- const v = [...values, ''].map(e => (typeof e === 'object' ? this.getRenderString(e) : e));
19
- return strings.reduce((acc, s, i) => acc + s + v[i], '');
20
- };
21
- }
22
- connect() {
23
- this.element.setAttribute('novalidate', 'true');
24
- this.element.addEventListener('blur', this.onBlur, true);
25
- this.element.addEventListener('submit', this.onSubmit);
26
- this.element.addEventListener('ajax:beforeSend', this.onSubmit);
27
- }
28
- disconnect() {
29
- this.element.removeEventListener('blur', this.onBlur);
30
- this.element.removeEventListener('submit', this.onSubmit);
31
- this.element.removeEventListener('ajax:beforeSend', this.onSubmit);
32
- }
33
- validateForm() {
34
- let isValid = true;
35
- // Not using `find` because we want to validate all the fields
36
- for (const field of this.formFields) {
37
- if (this.shouldValidateField(field) && !this.validateField(field))
38
- isValid = false;
39
- }
40
- return isValid;
41
- }
42
- validateField(field) {
43
- if (!this.shouldValidateField(field))
44
- return true;
45
- const isValid = field.checkValidity();
46
- field.classList.toggle('invalid', !isValid);
47
- this.refreshErrorForInvalidField(field, isValid);
48
- return isValid;
49
- }
50
- shouldValidateField(field) {
51
- return (!field.disabled &&
52
- !field.classList.contains('ProseMirror') &&
53
- !['file', 'reset', 'submit', 'button'].includes(field.type));
54
- }
55
- refreshErrorForInvalidField(field, isValid) {
56
- this.removeExistingErrorMessage(field);
57
- if (!isValid)
58
- this.showErrorForInvalidField(field);
59
- }
60
- removeExistingErrorMessage(field) {
61
- var _a;
62
- const fieldContainer = field.closest('.field');
63
- if (!fieldContainer)
64
- return;
65
- const existingErrorMessageElement = fieldContainer.querySelector('.error');
66
- if (existingErrorMessageElement) {
67
- (_a = existingErrorMessageElement === null || existingErrorMessageElement === void 0 ? void 0 : existingErrorMessageElement.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(existingErrorMessageElement);
68
- }
69
- }
70
- showErrorForInvalidField(field) {
71
- field.insertAdjacentHTML('afterend', this.buildFieldErrorHtml(field));
72
- }
73
- buildFieldErrorHtml(field) {
74
- const data = html `<p class="error">${field.validationMessage}</p>`;
75
- return this.getRenderString(data);
76
- }
77
- get formFields() {
78
- return Array.from(this.formFieldTargets);
79
- }
80
- get firstInvalidField() {
81
- return this.formFields.find(field => !field.checkValidity());
82
- }
83
- }
84
- AriadneFormWith.targets = ['formField'];
@@ -1,2 +0,0 @@
1
- import './tab-container-component';
2
- import './time-ago-component';
@@ -1,16 +0,0 @@
1
- import { Application } from '@hotwired/stimulus';
2
- import AriadneForm from './ariadne-form';
3
- import ClipboardCopyComponent from './clipboard-copy-component';
4
- import RichTextAreaComponent from './rich-text-area-component';
5
- import SlideoverComponent from './slideover-component';
6
- import TabNavComponent from './tab-nav-component';
7
- import TooltipComponent from './tooltip-component';
8
- import './tab-container-component';
9
- import './time-ago-component';
10
- const application = Application.start();
11
- application.register('clipboard-copy-component', ClipboardCopyComponent);
12
- application.register('ariadne-form', AriadneForm);
13
- application.register('rich-text-area-component', RichTextAreaComponent);
14
- application.register('slideover-component', SlideoverComponent);
15
- application.register('tab-nav-component', TabNavComponent);
16
- application.register('tooltip-component', TooltipComponent);
@@ -1,4 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class ClipboardCopyComponent extends Controller {
3
- copy(): void;
4
- }
@@ -1,18 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class ClipboardCopyComponent extends Controller {
3
- copy() {
4
- const value = this.element.attributes.getNamedItem('value');
5
- const forNode = this.element.attributes.getNamedItem('for');
6
- if (value) {
7
- navigator.clipboard.writeText(value.value);
8
- }
9
- else if (forNode) {
10
- const node = document.getElementById(forNode.value);
11
- navigator.clipboard.writeText((node === null || node === void 0 ? void 0 : node.textContent) || '');
12
- }
13
- else {
14
- // just copy inner text
15
- navigator.clipboard.writeText(this.element.textContent || '');
16
- }
17
- }
18
- }
@@ -1,4 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class ClipboardCopyComponent extends Controller {
3
- copy(): void;
4
- }
@@ -1,18 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class ClipboardCopyComponent extends Controller {
3
- copy() {
4
- const value = this.element.attributes.getNamedItem('value');
5
- const forNode = this.element.attributes.getNamedItem('for');
6
- if (value) {
7
- navigator.clipboard.writeText(value.value);
8
- }
9
- else if (forNode) {
10
- const node = document.getElementById(forNode.value);
11
- navigator.clipboard.writeText((node === null || node === void 0 ? void 0 : node.textContent) || '');
12
- }
13
- else {
14
- // just copy inner text
15
- navigator.clipboard.writeText(this.element.textContent || '');
16
- }
17
- }
18
- }
File without changes
@@ -1,33 +0,0 @@
1
- "use strict";
2
- // import {Controller} from '@hotwired/stimulus'
3
- // export default class CommentComponent extends Controller {
4
- // static targets = ['tab', 'tabBarComponent']
5
- // declare readonly commentComponentTarget: HTMLDivElement
6
- // declare readonly tabBarComponentTarget: HTMLElement // technically a `nav but typescript can't find it?
7
- // declare readonly tabTargets: [HTMLButtonElement]
8
- // // keep in sync with comment_component.rb
9
- // SELECTED_TAB_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
10
- // PUBLIC_BACKGROUND_COLOR = 'ariadne-bg-white'
11
- // INTERNAL_BACKGROUND_COLOR = 'ariadne-bg-internal-message'
12
- // toggleTab() {
13
- // for (const tab of this.tabTargets) {
14
- // if (tab.hasAttribute('aria-selected')) {
15
- // tab.classList.remove(...this.SELECTED_TAB_CLASSES)
16
- // this.toggleBackgrounds(tab, false)
17
- // tab.removeAttribute('aria-selected')
18
- // } else {
19
- // tab.setAttribute('aria-selected', 'true')
20
- // tab.classList.add(...this.SELECTED_TAB_CLASSES)
21
- // this.toggleBackgrounds(tab, true)
22
- // }
23
- // }
24
- // }
25
- // toggleBackgrounds(tab: HTMLButtonElement, publicComment: boolean) {
26
- // if (publicComment) {
27
- // this.tabBarComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
28
- // this.tabBarComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
29
- // this.tabBarComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
30
- // this.tabBarComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
31
- // }
32
- // }
33
- // }
@@ -1,37 +0,0 @@
1
- // import {Controller} from '@hotwired/stimulus'
2
-
3
- // export default class CommentComponent extends Controller {
4
- // static targets = ['tab', 'tabBarComponent']
5
-
6
- // declare readonly commentComponentTarget: HTMLDivElement
7
- // declare readonly tabBarComponentTarget: HTMLElement // technically a `nav but typescript can't find it?
8
- // declare readonly tabTargets: [HTMLButtonElement]
9
-
10
- // // keep in sync with comment_component.rb
11
- // SELECTED_TAB_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
12
- // PUBLIC_BACKGROUND_COLOR = 'ariadne-bg-white'
13
- // INTERNAL_BACKGROUND_COLOR = 'ariadne-bg-internal-message'
14
-
15
- // toggleTab() {
16
- // for (const tab of this.tabTargets) {
17
- // if (tab.hasAttribute('aria-selected')) {
18
- // tab.classList.remove(...this.SELECTED_TAB_CLASSES)
19
- // this.toggleBackgrounds(tab, false)
20
- // tab.removeAttribute('aria-selected')
21
- // } else {
22
- // tab.setAttribute('aria-selected', 'true')
23
- // tab.classList.add(...this.SELECTED_TAB_CLASSES)
24
- // this.toggleBackgrounds(tab, true)
25
- // }
26
- // }
27
- // }
28
- // toggleBackgrounds(tab: HTMLButtonElement, publicComment: boolean) {
29
- // if (publicComment) {
30
- // this.tabBarComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
31
- // this.tabBarComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
32
-
33
- // this.tabBarComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
34
- // this.tabBarComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
35
- // }
36
- // }
37
- // }
@@ -1,4 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class RichTextArea extends Controller {
3
- connect(): void;
4
- }
@@ -1,27 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { Editor } from '@tiptap/core';
3
- import { StarterKit } from '@tiptap/starter-kit';
4
- export default class RichTextArea extends Controller {
5
- connect() {
6
- const editorElements = document.getElementsByClassName('tiptap-editor');
7
- for (const editorElement of editorElements) {
8
- new Editor({
9
- element: editorElement,
10
- extensions: [StarterKit],
11
- content: '',
12
- editorProps: {
13
- attributes: {
14
- class: 'ariadne-m-5 focus:ariadne-outline-none ariadne-block ariadne-w-full ariadne-resize-none ariadne-p-0 ariadne-pb-2 ariadne-border-none focus:ariadne-ring-0 sm:ariadne-text-sm'
15
- }
16
- }
17
- });
18
- const tiptapValueContainer = document.querySelector('input[data-tiptap-value-container=true]');
19
- if (tiptapValueContainer) {
20
- const parentForm = editorElement.closest('form');
21
- parentForm === null || parentForm === void 0 ? void 0 : parentForm.addEventListener('submit', () => {
22
- tiptapValueContainer.setAttribute('value', editorElement.textContent || '');
23
- });
24
- }
25
- }
26
- }
27
- }
@@ -1,9 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class SlideoverComponent extends Controller {
3
- static targets: string[];
4
- readonly expandableTarget: HTMLDivElement;
5
- readonly expandWrapperTarget: HTMLDivElement;
6
- readonly slidePanelTargets: [HTMLDivElement];
7
- readonly buttonWrapperTarget: HTMLDivElement;
8
- toggle(): void;
9
- }
@@ -1,20 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class SlideoverComponent extends Controller {
3
- toggle() {
4
- var _a;
5
- this.expandableTarget.classList.toggle('ariadne-hidden');
6
- this.expandWrapperTarget.classList.toggle('bg-filter-panel');
7
- for (const slidePanel of this.slidePanelTargets) {
8
- slidePanel.classList.toggle('ariadne-hidden');
9
- }
10
- this.buttonWrapperTarget.classList.toggle('bg-filter-panel');
11
- if ((_a = document.getElementById('btnClose')) === null || _a === void 0 ? void 0 : _a.classList.contains('ariadne-hidden')) {
12
- const formID = this.buttonWrapperTarget.getAttribute('data-slideover-component-form-id');
13
- if (formID) {
14
- const form = document.getElementById(formID);
15
- form === null || form === void 0 ? void 0 : form.submit();
16
- }
17
- }
18
- }
19
- }
20
- SlideoverComponent.targets = ['expandable', 'expandWrapper', 'slidePanel', 'buttonWrapper'];
@@ -1,9 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class SlideoverComponent extends Controller {
3
- static targets: string[];
4
- readonly expandableTarget: HTMLDivElement;
5
- readonly expandWrapperTarget: HTMLDivElement;
6
- readonly slidePanelTargets: [HTMLDivElement];
7
- readonly buttonWrapperTarget: HTMLDivElement;
8
- toggle(): void;
9
- }
@@ -1,19 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class SlideoverComponent extends Controller {
3
- toggle() {
4
- var _a;
5
- // eslint-disable-next-line no-debugger
6
- debugger;
7
- this.expandableTarget.classList.toggle('hidden');
8
- this.expandWrapperTarget.classList.toggle('bg-filter-panel');
9
- for (const slidePanel of this.slidePanelTargets) {
10
- slidePanel.classList.toggle('hidden');
11
- }
12
- this.buttonWrapperTarget.classList.toggle('bg-filter-panel');
13
- if ((_a = document.getElementById('btnClose')) === null || _a === void 0 ? void 0 : _a.classList.contains('hidden')) {
14
- const form = this.buttonWrapperTarget.closest('form');
15
- form === null || form === void 0 ? void 0 : form.submit();
16
- }
17
- }
18
- }
19
- SlideoverComponent.targets = ['expandable', 'expandWrapper', 'slidePanel', 'buttonWrapper'];
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- import '@github/tab-container-element';
@@ -1,23 +0,0 @@
1
- import '@github/tab-container-element';
2
- // // keep in sync with tab_container_component.rb
3
- // const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
4
- // const DEFAULT_UNSELECTED_CLASSES: string[] = [
5
- // 'ariadne-text-gray-500',
6
- // 'hover:ariadne-text-gray-700',
7
- // 'hover:ariadne-border-gray-300'
8
- // ]
9
- for (const tabContainer of document.getElementsByTagName('tab-container')) {
10
- tabContainer.addEventListener('tab-container-change', function (event) {
11
- var _a;
12
- const newPanel = event.detail.relatedTarget;
13
- const tabContainer = newPanel.closest('tab-container');
14
- const tabList = tabContainer.firstElementChild;
15
- const currentTab = tabList.querySelector('[aria-selected="true"]');
16
- const tabId = (_a = newPanel.getAttribute('id')) === null || _a === void 0 ? void 0 : _a.split('-').slice(1).join('-');
17
- const newTab = tabList.querySelector(`#${tabId}`);
18
- currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES);
19
- currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES);
20
- newTab.classList.add(...DEFAULT_SELECTED_CLASSES);
21
- newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES);
22
- });
23
- }
@@ -1 +0,0 @@
1
- import '@github/tab-container-element';
@@ -1,23 +0,0 @@
1
- import '@github/tab-container-element';
2
- // keep in sync with tab_container_component.rb
3
- const DEFAULT_SELECTED_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600'];
4
- const DEFAULT_UNSELECTED_CLASSES = [
5
- 'ariadne-text-gray-500',
6
- 'hover:ariadne-text-gray-700',
7
- 'hover:ariadne-border-gray-300'
8
- ];
9
- for (const tabContainer of document.getElementsByTagName('tab-container')) {
10
- tabContainer.addEventListener('tab-container-change', function (event) {
11
- var _a;
12
- const newPanel = event.detail.relatedTarget;
13
- const tabContainer = newPanel.closest('tab-container');
14
- const tabList = tabContainer.firstElementChild;
15
- const currentTab = tabList.querySelector('[aria-selected="true"]');
16
- const tabId = (_a = newPanel.getAttribute('id')) === null || _a === void 0 ? void 0 : _a.split('-').slice(1).join('-');
17
- const newTab = tabList.querySelector(`#${tabId}`);
18
- currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES);
19
- currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES);
20
- newTab.classList.add(...DEFAULT_SELECTED_CLASSES);
21
- newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES);
22
- });
23
- }
@@ -1,9 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class TabNavComponent extends Controller {
3
- static targets: string[];
4
- readonly tabTargets: [HTMLAnchorElement];
5
- SELECTED_CLASSES: string[];
6
- UNSELECTED_CLASSES: string[];
7
- connect(): void;
8
- toggle(event: Event): void;
9
- }
@@ -1,32 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class TabNavComponent extends Controller {
3
- constructor() {
4
- super(...arguments);
5
- // keep in synch with tab_nav_component
6
- this.SELECTED_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600'];
7
- this.UNSELECTED_CLASSES = ['ariadne-text-gray-500', 'hover:ariadne-text-gray-700', 'hover:ariadne-border-gray-300'];
8
- }
9
- connect() {
10
- for (const tab of this.tabTargets) {
11
- if (tab.hasAttribute('aria-current')) {
12
- tab.classList.add(...this.SELECTED_CLASSES);
13
- tab.classList.remove(...this.UNSELECTED_CLASSES);
14
- }
15
- }
16
- }
17
- toggle(event) {
18
- for (const tab of this.tabTargets) {
19
- if (tab === event.target) {
20
- tab.setAttribute('aria-current', 'page');
21
- tab.classList.add(...this.SELECTED_CLASSES);
22
- tab.classList.remove(...this.UNSELECTED_CLASSES);
23
- }
24
- else if (tab.hasAttribute('aria-current')) {
25
- tab.removeAttribute('aria-current');
26
- tab.classList.add(...this.UNSELECTED_CLASSES);
27
- tab.classList.remove(...this.SELECTED_CLASSES);
28
- }
29
- }
30
- }
31
- }
32
- TabNavComponent.targets = ['tab'];
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- import '@github/time-elements';
@@ -1 +0,0 @@
1
- import '@github/time-elements';
@@ -1 +0,0 @@
1
- import '@github/time-elements';
@@ -1 +0,0 @@
1
- import '@github/time-elements';
@@ -1,24 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import type { Instance, Placement } from '@popperjs/core';
3
- export default class TooltipComponent extends Controller {
4
- static targets: string[];
5
- readonly triggerTarget: HTMLElement;
6
- readonly tooltipTarget: HTMLElement;
7
- static values: {
8
- placement: {
9
- type: StringConstructor;
10
- default: string;
11
- };
12
- offset: {
13
- type: ArrayConstructor;
14
- default: number[];
15
- };
16
- };
17
- readonly placementValue: Placement;
18
- readonly offsetValue: Array<number>;
19
- popperInstance: Instance;
20
- connect(): void;
21
- disconnect(): void;
22
- show(): void;
23
- hide(): void;
24
- }
@@ -1,42 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { createPopper } from '@popperjs/core';
3
- export default class TooltipComponent extends Controller {
4
- // Create a new Popper instance
5
- connect() {
6
- this.popperInstance = createPopper(this.triggerTarget, this.tooltipTarget, {
7
- placement: this.placementValue,
8
- modifiers: [
9
- {
10
- name: 'offset',
11
- options: {
12
- offset: this.offsetValue
13
- }
14
- }
15
- ]
16
- });
17
- }
18
- // Destroy the Popper instance
19
- disconnect() {
20
- if (this.popperInstance) {
21
- this.popperInstance.destroy();
22
- }
23
- }
24
- show() {
25
- this.tooltipTarget.setAttribute('data-tooltip-show', '');
26
- this.tooltipTarget.classList.remove('ariadne-invisible');
27
- // We need to tell Popper to update the tooltip position
28
- // after we show the tooltip, otherwise it will be incorrect
29
- this.popperInstance.update();
30
- this.dispatch('shown', { detail: { trigger: this.triggerTarget, tooltip: this.tooltipTarget } });
31
- }
32
- hide() {
33
- this.tooltipTarget.removeAttribute('data-tooltip-show');
34
- this.tooltipTarget.classList.add('ariadne-invisible');
35
- this.dispatch('ariadne-hidden', { detail: { trigger: this.triggerTarget, tooltip: this.tooltipTarget } });
36
- }
37
- }
38
- TooltipComponent.targets = ['trigger', 'tooltip'];
39
- TooltipComponent.values = {
40
- placement: { type: String, default: 'top' },
41
- offset: { type: Array, default: [0, 8] }
42
- };