layers-design-system 2.0.11 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "layers-design-system",
3
3
  "main": "src/main.js",
4
- "version": "2.0.11",
4
+ "version": "2.1.0",
5
5
  "scripts": {
6
6
  "start": "vue-cli-service serve ./src/main-docs.js",
7
7
  "build": "vue-cli-service build --target lib ./src/main.js",
@@ -54,7 +54,7 @@
54
54
  </template>
55
55
 
56
56
  <script>
57
- import LIcon from '../LIcon'
57
+ import LIcon from '../LIcon/index.vue'
58
58
 
59
59
  let typeMap = {
60
60
  success: 'success',
@@ -1,7 +1,7 @@
1
- import StringEditor from "./StringEditor";
2
- import AmountEditor from "./AmountEditor";
3
- import NumberEditor from "./NumberEditor";
4
- import DateEditor from "./DateEditor";
1
+ import StringEditor from "./StringEditor.vue";
2
+ import AmountEditor from "./AmountEditor.vue";
3
+ import NumberEditor from "./NumberEditor.vue";
4
+ import DateEditor from "./DateEditor.vue";
5
5
 
6
6
  import { FieldTypeComponents } from '../../../../helpers/FieldTypeComponents'
7
7
 
@@ -1,7 +1,7 @@
1
- import StringView from "./StringView";
2
- import AmountView from "./AmountView";
3
- import NumberView from "./NumberView";
4
- import DateView from "./DateView";
1
+ import StringView from "./StringView.vue";
2
+ import AmountView from "./AmountView.vue";
3
+ import NumberView from "./NumberView.vue";
4
+ import DateView from "./DateView.vue";
5
5
 
6
6
  import { FieldTypeComponents } from '../../../../helpers/FieldTypeComponents'
7
7
 
@@ -49,8 +49,8 @@ import isEqual from "lodash/isEqual";
49
49
  import findIndex from "lodash/findIndex";
50
50
  import find from "lodash/find";
51
51
 
52
- import AddFilterButton from "./AddFilterButton";
53
- import FilterChip from "./Filters/FilterChip";
52
+ import AddFilterButton from "./AddFilterButton.vue";
53
+ import FilterChip from "./Filters/FilterChip.vue";
54
54
 
55
55
  export default {
56
56
  tagName: "l-search-bar",
@@ -1,8 +1,8 @@
1
- import StringView from "./StringView";
2
- import NumberView from "./NumberView";
3
- import AmountView from "./AmountView";
4
- import EmailView from "./EmailView";
5
- import DateView from "./DateView";
1
+ import StringView from "./StringView.vue";
2
+ import NumberView from "./NumberView.vue";
3
+ import AmountView from "./AmountView.vue";
4
+ import EmailView from "./EmailView.vue";
5
+ import DateView from "./DateView.vue";
6
6
 
7
7
  import { FieldTypeComponents } from '../../../helpers/FieldTypeComponents'
8
8
 
@@ -31,8 +31,8 @@
31
31
  </template>
32
32
 
33
33
  <script>
34
- import LTableHeaderCell from "./LTableHeaderCell";
35
- import LTableHeaderLoader from "./LTableHeaderLoader";
34
+ import LTableHeaderCell from "./LTableHeaderCell.vue";
35
+ import LTableHeaderLoader from "./LTableHeaderLoader.vue";
36
36
 
37
37
  export default {
38
38
  components: { LTableHeaderCell, LTableHeaderLoader },
@@ -57,7 +57,7 @@
57
57
  </template>
58
58
 
59
59
  <script>
60
- import LTableHeaderResizer from "./LTableHeaderResizer";
60
+ import LTableHeaderResizer from "./LTableHeaderResizer.vue";
61
61
 
62
62
  export default {
63
63
  components: { LTableHeaderResizer },
@@ -78,13 +78,13 @@
78
78
  import FieldTypes from "./FieldTypes";
79
79
  FieldTypes.register();
80
80
 
81
- import LTableBody from "./LTableBody";
82
- import LTableHeader from "./LTableHeader";
83
- import LTableEndspace from "./LTableEndspace"
84
- import LTableLoadMore from "./LTableLoadMore";
85
- import LTableReloader from "./LTableReloader";
86
- import LTableBodySpacer from "./LTableBodySpacer";
87
- import LTablePagination from "./LTablePagination";
81
+ import LTableBody from "./LTableBody.vue";
82
+ import LTableHeader from "./LTableHeader.vue";
83
+ import LTableEndspace from "./LTableEndspace.vue"
84
+ import LTableLoadMore from "./LTableLoadMore.vue";
85
+ import LTableReloader from "./LTableReloader.vue";
86
+ import LTableBodySpacer from "./LTableBodySpacer.vue";
87
+ import LTablePagination from "./LTablePagination.vue";
88
88
 
89
89
  import {changeSelection} from './helpers'
90
90
 
@@ -63,37 +63,36 @@
63
63
  </template>
64
64
 
65
65
  <script>
66
- import { Editor, EditorContent, BubbleMenu } from '@tiptap/vue-2'
67
- import Document from '@tiptap/extension-document'
68
- import Text from '@tiptap/extension-text'
69
- import ListItem from '@tiptap/extension-list-item'
66
+ import { Editor, EditorContent, BubbleMenu } from "@tiptap/vue-2";
67
+ import Document from "@tiptap/extension-document";
68
+ import Text from "@tiptap/extension-text";
69
+ import ListItem from "@tiptap/extension-list-item";
70
70
 
71
71
  //Layers Custom Extensions
72
- import LayersParagraph from './extensions/LayersParagraph'
73
- import LayersBold from './extensions/LayersBold'
74
- import LayersItalic from './extensions/LayersItalic'
75
- import LayersUnderline from './extensions/LayersUnderline'
76
- import LayersHeading from './extensions/LayersHeading'
77
- import LayersBulletList from './extensions/LayersBulletList'
78
- import LayersOrderedList from './extensions/LayersOrderedList'
79
- import LayersBlockquote from './extensions/LayersBlockquote'
80
- import LayersLink from './extensions/LayersLink'
81
- import LayersPlaceholder from './extensions/LayersPlaceholder'
82
- import LayersBreakLine from './extensions/LayersBreakLine'
83
- import LayersHistory from './extensions/LayersHistory'
72
+ import LayersParagraph from "./extensions/LayersParagraph";
73
+ import LayersBold from "./extensions/LayersBold";
74
+ import LayersItalic from "./extensions/LayersItalic";
75
+ import LayersUnderline from "./extensions/LayersUnderline";
76
+ import LayersHeading from "./extensions/LayersHeading";
77
+ import LayersBulletList from "./extensions/LayersBulletList";
78
+ import LayersOrderedList from "./extensions/LayersOrderedList";
79
+ import LayersBlockquote from "./extensions/LayersBlockquote";
80
+ import LayersLink from "./extensions/LayersLink";
81
+ import LayersPlaceholder from "./extensions/LayersPlaceholder";
82
+ import LayersBreakLine from "./extensions/LayersBreakLine";
83
+ import LayersHistory from "./extensions/LayersHistory";
84
84
 
85
85
  //Custom Components
86
- import LinkBox from './LinkBox'
87
- import FloatingLink from './FloatingLink.vue'
86
+ import LinkBox from "./LinkBox.vue";
87
+ import FloatingLink from "./FloatingLink.vue";
88
88
 
89
89
  //Helpers
90
- import { getTagA } from './helpers/addProtocol.js'
91
- import removeEmptyTags from './helpers/removeEmptyTags.js'
92
- import DOMPurify from 'dompurify'
93
- import Autolinker from 'autolinker'
90
+ import removeEmptyTags from "./helpers/removeEmptyTags.js";
91
+ import DOMPurify from "dompurify";
92
+ import Autolinker from "autolinker";
94
93
 
95
94
  export default {
96
- tagName: 'l-text-editor',
95
+ tagName: "l-text-editor",
97
96
 
98
97
  props: {
99
98
  value: String,
@@ -111,77 +110,77 @@ export default {
111
110
  editor: null,
112
111
  markUps: [
113
112
  {
114
- name: 'bold',
115
- tooltip: 'Negrito',
116
- icon: 'uil-bold',
113
+ name: "bold",
114
+ tooltip: "Negrito",
115
+ icon: "uil-bold",
117
116
  },
118
117
  {
119
- name: 'italic',
120
- tooltip: 'Itálico',
121
- icon: 'uil-italic',
118
+ name: "italic",
119
+ tooltip: "Itálico",
120
+ icon: "uil-italic",
122
121
  },
123
122
  {
124
- name: 'underline',
125
- tooltip: 'Sublinhado',
126
- icon: 'uil-underline',
123
+ name: "underline",
124
+ tooltip: "Sublinhado",
125
+ icon: "uil-underline",
127
126
  },
128
127
  {
129
- name: 'heading',
130
- tooltip: 'Título',
131
- icon: require('../../assets/button-text-editor/title.svg'),
128
+ name: "heading",
129
+ tooltip: "Título",
130
+ icon: require("../../assets/button-text-editor/title.svg"),
132
131
  },
133
132
  {
134
- name: 'bulletList',
135
- tooltip: 'Lista com marcadores',
136
- icon: 'uil-list-ul',
133
+ name: "bulletList",
134
+ tooltip: "Lista com marcadores",
135
+ icon: "uil-list-ul",
137
136
  },
138
137
  {
139
- name: 'orderedList',
140
- tooltip: 'Lista numerada',
141
- icon: 'uil-list-ol-alt',
138
+ name: "orderedList",
139
+ tooltip: "Lista numerada",
140
+ icon: "uil-list-ol-alt",
142
141
  },
143
142
  {
144
- name: 'link',
145
- tooltip: 'Inserir link',
146
- icon: 'uil-link-alt',
143
+ name: "link",
144
+ tooltip: "Inserir link",
145
+ icon: "uil-link-alt",
147
146
  },
148
147
  {
149
- name: 'blockquote',
150
- tooltip: 'Citação',
151
- icon: require('../../assets/button-text-editor/double-quotes.svg'),
148
+ name: "blockquote",
149
+ tooltip: "Citação",
150
+ icon: require("../../assets/button-text-editor/double-quotes.svg"),
152
151
  },
153
152
  {
154
- name: 'removeFormatting',
155
- tooltip: 'Remover formatação',
156
- icon: require('../../assets/button-text-editor/remove-formatting.svg'),
153
+ name: "removeFormatting",
154
+ tooltip: "Remover formatação",
155
+ icon: require("../../assets/button-text-editor/remove-formatting.svg"),
157
156
  },
158
157
  ],
159
158
  showLinkBox: false,
160
159
  isEditorFocused: null,
161
160
  tooltipDelay: 125,
162
- }
161
+ };
163
162
  },
164
163
 
165
164
  methods: {
166
165
  isUnicon(value) {
167
- return value.startsWith('uil-')
166
+ return value.startsWith("uil-");
168
167
  },
169
168
 
170
169
  markUpText(type) {
171
- if (type === 'link') {
172
- this.toggleLinkBox()
173
- return
170
+ if (type === "link") {
171
+ this.toggleLinkBox();
172
+ return;
174
173
  }
175
- const commandChain = this.editor.chain().focus()
176
- commandChain.setMarkUp(type).run()
174
+ const commandChain = this.editor.chain().focus();
175
+ commandChain.setMarkUp(type).run();
177
176
  },
178
177
 
179
178
  toggleLinkBox() {
180
- this.showLinkBox = !this.showLinkBox
179
+ this.showLinkBox = !this.showLinkBox;
181
180
  },
182
181
  closeLinkBox() {
183
- this.editor.commands.focus()
184
- this.toggleLinkBox()
182
+ this.editor.commands.focus();
183
+ this.toggleLinkBox();
185
184
  },
186
185
 
187
186
  markUpLink(info) {
@@ -189,91 +188,89 @@ export default {
189
188
  this.editor
190
189
  .chain()
191
190
  .focus()
192
- .extendMarkRange('link')
193
- .setLink({ href: info.url, target: '_blank' })
194
- .run()
191
+ .extendMarkRange("link")
192
+ .setLink({ href: info.url, target: "_blank" })
193
+ .run();
195
194
  } else {
196
- this.editor.commands.insertContent(getTagA(info.url, info.insertedText))
195
+ this.editor.commands.insertContent(Autolinker.link(info.insertedText));
197
196
  }
198
197
  },
199
198
  markOffLink() {
200
- this.editor
201
- .chain()
202
- .focus()
203
- .extendMarkRange('link')
204
- .unsetLink()
205
- .run()
199
+ this.editor.chain().focus().extendMarkRange("link").unsetLink().run();
206
200
  },
207
201
 
208
202
  hasSomeMarkUpActive() {
209
- const textEditorContent = this.editor.getJSON().content
210
- const textEditorMarkUps = this.markUps.map((markUp) => markUp.name)
203
+ const textEditorContent = this.editor.getJSON().content;
204
+ const textEditorMarkUps = this.markUps.map((markUp) => markUp.name);
211
205
 
212
- const textNodesActive = textEditorContent.map((node) => node.type)
206
+ const textNodesActive = textEditorContent.map((node) => node.type);
213
207
 
214
208
  const hasSomeNode = textNodesActive.some((node) =>
215
209
  textEditorMarkUps.includes(node)
216
- )
210
+ );
217
211
  const hasSomeMark = textEditorContent.some((node) => {
218
- if (node.hasOwnProperty('content')) {
219
- return node.content.some((content) => content.hasOwnProperty('marks'))
212
+ if (node.hasOwnProperty("content")) {
213
+ return node.content.some((content) =>
214
+ content.hasOwnProperty("marks")
215
+ );
220
216
  }
221
- })
217
+ });
222
218
 
223
- return hasSomeNode || hasSomeMark
219
+ return hasSomeNode || hasSomeMark;
224
220
  },
225
221
 
226
222
  addSpaceToFinalParagraphTag(text) {
227
- return text.replace(/<\/p>/g, ' </p>')
223
+ return text.replace(/<\/p>/g, " </p>");
228
224
  },
229
225
  },
230
226
 
231
227
  computed: {
232
228
  previousURL() {
233
- return this.editor.getAttributes('link').href
229
+ return this.editor.getAttributes("link").href;
234
230
  },
235
231
  showFloatingLink() {
236
- return this.editor.isActive('link')
232
+ return this.editor.isActive("link");
237
233
  },
238
234
  finalText() {
239
- const textEditorHTML = this.editor.getHTML()
240
- const textEditorHTMLSpaced = this.addSpaceToFinalParagraphTag(textEditorHTML)
241
- const textEditorHTMLWithLinks = Autolinker.link(textEditorHTMLSpaced)
235
+ const textEditorHTML = this.editor.getHTML();
236
+ const textEditorHTMLSpaced =
237
+ this.addSpaceToFinalParagraphTag(textEditorHTML);
238
+ const textEditorHTMLWithLinks = Autolinker.link(textEditorHTMLSpaced);
242
239
 
243
240
  return DOMPurify.sanitize(removeEmptyTags(textEditorHTMLWithLinks), {
244
- ADD_ATTR: ['target'],
245
- })
241
+ ADD_ATTR: ["target"],
242
+ });
246
243
  },
247
244
  currentTextSelection() {
248
- const { view, state } = this.editor
249
- const { from, to } = view.state.selection
250
- return state.doc.textBetween(from, to, '')
245
+ const { view, state } = this.editor;
246
+ const { from, to } = view.state.selection;
247
+ return state.doc.textBetween(from, to, "");
251
248
  },
252
249
  arrowXPosition() {
253
- const arrowWidth = 16.8 //px
254
- const buttonLink = this.$refs.link[0].$el
250
+ const arrowWidth = 16.8; //px
251
+ const buttonLink = this.$refs.link[0].$el;
255
252
 
256
253
  //formula to position the arrow based on the button link position
257
254
  const arrowLeftOffset =
258
- buttonLink.offsetLeft + (buttonLink.offsetWidth - arrowWidth) / 2
259
- return { left: `${arrowLeftOffset}px` }
255
+ buttonLink.offsetLeft + (buttonLink.offsetWidth - arrowWidth) / 2;
256
+ return { left: `${arrowLeftOffset}px` };
260
257
  },
261
258
  linkBoxPosition() {
262
- const linkBoxWidth = 456 //px
263
- const textEditorWidth = this.$refs.texteditor.$el.offsetWidth
264
- const buttonLink = this.$refs.link[0].$el
265
- let linkBoxLeftOffset
266
- const overflowLimit = 500
259
+ const linkBoxWidth = 456; //px
260
+ const textEditorWidth = this.$refs.texteditor.$el.offsetWidth;
261
+ const buttonLink = this.$refs.link[0].$el;
262
+ let linkBoxLeftOffset;
263
+ const overflowLimit = 500;
267
264
 
268
265
  if (textEditorWidth > overflowLimit) {
269
266
  //formula to position the link box based on the screen width
270
- linkBoxLeftOffset = `${buttonLink.offsetLeft +
271
- buttonLink.offsetWidth / 2 -
272
- linkBoxWidth / 2}px`
267
+ linkBoxLeftOffset = `${
268
+ buttonLink.offsetLeft + buttonLink.offsetWidth / 2 - linkBoxWidth / 2
269
+ }px`;
273
270
  } else {
274
- linkBoxLeftOffset = '1rem'
271
+ linkBoxLeftOffset = "1rem";
275
272
  }
276
- return { left: linkBoxLeftOffset }
273
+ return { left: linkBoxLeftOffset };
277
274
  },
278
275
  },
279
276
 
@@ -299,23 +296,23 @@ export default {
299
296
  content: this.value,
300
297
  autofocus: false,
301
298
  onUpdate: () => {
302
- this.$emit('input', this.finalText)
303
- this.$emit('useMarkUp', this.hasSomeMarkUpActive())
299
+ this.$emit("input", this.finalText);
300
+ this.$emit("useMarkUp", this.hasSomeMarkUpActive());
304
301
  },
305
302
  onFocus: () => {
306
- this.isEditorFocused = true
307
- this.$emit('focus', true)
303
+ this.isEditorFocused = true;
304
+ this.$emit("focus", true);
308
305
  },
309
306
  onBlur: () => {
310
- this.isEditorFocused = false
307
+ this.isEditorFocused = false;
311
308
  },
312
- })
309
+ });
313
310
  },
314
311
 
315
312
  beforeDestroy() {
316
- this.editor.destroy()
313
+ this.editor.destroy();
317
314
  },
318
- }
315
+ };
319
316
  </script>
320
317
 
321
318
  <style scoped>