@ternarytech-io/gears-ui 0.0.0-stage → 0.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.
Files changed (90) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +160 -2
  3. package/package.json +104 -6
  4. package/src/code-editor.ts +25 -0
  5. package/src/components/TAccentPicker.vue +41 -0
  6. package/src/components/TAdvancedSelect.vue +128 -0
  7. package/src/components/TAdvancedTable.vue +130 -0
  8. package/src/components/TAlert.vue +41 -0
  9. package/src/components/TAuthLayout.vue +32 -0
  10. package/src/components/TAvatar.vue +28 -0
  11. package/src/components/TBadge.vue +29 -0
  12. package/src/components/TButton.vue +60 -0
  13. package/src/components/TCard.vue +40 -0
  14. package/src/components/TCheckbox.vue +29 -0
  15. package/src/components/TCodeEditor.vue +128 -0
  16. package/src/components/TColorModeButton.vue +14 -0
  17. package/src/components/TColorPicker.vue +61 -0
  18. package/src/components/TCommandPalette.vue +109 -0
  19. package/src/components/TCopyButton.vue +72 -0
  20. package/src/components/TDatePicker.vue +83 -0
  21. package/src/components/TDropdown.vue +76 -0
  22. package/src/components/TDropzone.vue +76 -0
  23. package/src/components/TEmpty.vue +21 -0
  24. package/src/components/TFieldGroup.vue +11 -0
  25. package/src/components/TFileUpload.vue +92 -0
  26. package/src/components/TFontPicker.vue +23 -0
  27. package/src/components/TFormField.vue +40 -0
  28. package/src/components/TIcon.vue +12 -0
  29. package/src/components/TImageUpload.vue +131 -0
  30. package/src/components/TInput.vue +52 -0
  31. package/src/components/TInputMask.vue +70 -0
  32. package/src/components/TInputNumber.vue +62 -0
  33. package/src/components/TInputTags.vue +53 -0
  34. package/src/components/TLogView.vue +39 -0
  35. package/src/components/TModal.vue +54 -0
  36. package/src/components/TNav.vue +75 -0
  37. package/src/components/TPage.vue +48 -0
  38. package/src/components/TPagination.vue +44 -0
  39. package/src/components/TPanelList.vue +29 -0
  40. package/src/components/TProgress.vue +18 -0
  41. package/src/components/TRadioGroup.vue +68 -0
  42. package/src/components/TRadiusPicker.vue +21 -0
  43. package/src/components/TRangeSlider.vue +63 -0
  44. package/src/components/TRichEditor.vue +82 -0
  45. package/src/components/TSearchButton.vue +20 -0
  46. package/src/components/TSectionLayout.vue +37 -0
  47. package/src/components/TSelect.vue +60 -0
  48. package/src/components/TSelectMenu.vue +126 -0
  49. package/src/components/TSeparator.vue +10 -0
  50. package/src/components/TShell.vue +72 -0
  51. package/src/components/TSkeleton.vue +17 -0
  52. package/src/components/TSlideover.vue +47 -0
  53. package/src/components/TSortable.vue +61 -0
  54. package/src/components/TSpinner.vue +14 -0
  55. package/src/components/TSplitter.vue +85 -0
  56. package/src/components/TStatCard.vue +26 -0
  57. package/src/components/TSteps.vue +19 -0
  58. package/src/components/TSwitch.vue +18 -0
  59. package/src/components/TTable.vue +134 -0
  60. package/src/components/TTabs.vue +38 -0
  61. package/src/components/TTextarea.vue +42 -0
  62. package/src/components/TThemeBasePicker.vue +22 -0
  63. package/src/components/TThemeScope.vue +22 -0
  64. package/src/components/TToaster.vue +27 -0
  65. package/src/components/TTooltip.vue +33 -0
  66. package/src/components/TTopbar.vue +17 -0
  67. package/src/components/TVectorMap.vue +74 -0
  68. package/src/composables/useColorMode.ts +41 -0
  69. package/src/composables/useCommandPalette.ts +11 -0
  70. package/src/composables/useField.ts +26 -0
  71. package/src/composables/useOverlay.ts +55 -0
  72. package/src/composables/useToast.ts +33 -0
  73. package/src/index.ts +199 -0
  74. package/src/monaco.ts +27 -0
  75. package/src/plugins/coloris.ts +8 -0
  76. package/src/plugins/datepicker.ts +7 -0
  77. package/src/plugins/dropzone.ts +5 -0
  78. package/src/plugins/index.ts +49 -0
  79. package/src/plugins/inputMask.ts +7 -0
  80. package/src/plugins/once.ts +8 -0
  81. package/src/plugins/richEditor.ts +37 -0
  82. package/src/plugins/slider.ts +4 -0
  83. package/src/plugins/sortable.ts +7 -0
  84. package/src/plugins/tomSelect.ts +4 -0
  85. package/src/shims.d.ts +17 -0
  86. package/src/styles/gears.css +560 -0
  87. package/src/styles/plugins.css +10 -0
  88. package/src/theme.ts +28 -0
  89. package/src/types.ts +160 -0
  90. package/src/vectorMap.ts +14 -0
package/src/monaco.ts ADDED
@@ -0,0 +1,27 @@
1
+ // Monaco, set up once: bundled web workers (no CDN; Gears may run offline) and light and dark
2
+ // themes on the Gears palette. TCodeEditor loads this the first time an editor is shown, so apps
3
+ // that never show one don't download Monaco.
4
+ import * as monaco from 'monaco-editor'
5
+ import EditorWorker from 'monaco-editor/editor/editor.worker?worker'
6
+ import JsonWorker from 'monaco-editor/languages/features/json/json.worker?worker'
7
+
8
+ self.MonacoEnvironment = {
9
+ getWorker(_id: string, label: string) {
10
+ return label === 'json' ? new JsonWorker() : new EditorWorker()
11
+ }
12
+ }
13
+
14
+ monaco.editor.defineTheme('gears-light', {
15
+ base: 'vs',
16
+ inherit: true,
17
+ rules: [],
18
+ colors: { 'editor.background': '#ffffff', 'editorLineNumber.foreground': '#a2a8b1', 'editor.lineHighlightBackground': '#f6f7f9' }
19
+ })
20
+ monaco.editor.defineTheme('gears-dark', {
21
+ base: 'vs-dark',
22
+ inherit: true,
23
+ rules: [],
24
+ colors: { 'editor.background': '#232525', 'editorLineNumber.foreground': '#5d6470', 'editor.lineHighlightBackground': '#2c2f2f' }
25
+ })
26
+
27
+ export default monaco
@@ -0,0 +1,8 @@
1
+ // Loads Coloris, the first time a TColorPicker is shown.
2
+ import { once } from './once'
3
+
4
+ export const loadColoris = once(async () => {
5
+ const Coloris = (await import('@melloware/coloris')).default
6
+ Coloris.init()
7
+ return Coloris
8
+ })
@@ -0,0 +1,7 @@
1
+ // Loads Vanilla Calendar Pro and Tabler's date picker, the first time a TDatePicker is shown.
2
+ import { globals, once } from './once'
3
+
4
+ export const loadDatepicker = once(async () => {
5
+ globals.VanillaCalendarPro = await import('vanilla-calendar-pro')
6
+ return (await import('@tabler/core')).Datepicker
7
+ })
@@ -0,0 +1,5 @@
1
+ // Loads Dropzone, the first time a TDropzone is shown. Dropzone 6's module build doesn't look for
2
+ // dropzones in the page; TDropzone creates them.
3
+ import { once } from './once'
4
+
5
+ export const loadDropzone = once(async () => (await import('dropzone')).default)
@@ -0,0 +1,49 @@
1
+ // Gears UI's plugin components, on the libraries Tabler's plugins use. Each library is an optional
2
+ // peer dependency that loads the first time its component is shown. Installing this plugin needs
3
+ // all of them; to use only some, import those components from `@ternarytech-io/gears-ui/components/…` instead.
4
+ import type { App } from 'vue'
5
+ import TAdvancedSelect from '../components/TAdvancedSelect.vue'
6
+ import TColorPicker from '../components/TColorPicker.vue'
7
+ import TDatePicker from '../components/TDatePicker.vue'
8
+ import TDropzone from '../components/TDropzone.vue'
9
+ import TInputMask from '../components/TInputMask.vue'
10
+ import TRangeSlider from '../components/TRangeSlider.vue'
11
+ import TRichEditor from '../components/TRichEditor.vue'
12
+ import TSortable from '../components/TSortable.vue'
13
+
14
+ export {
15
+ TAdvancedSelect,
16
+ TColorPicker,
17
+ TDatePicker,
18
+ TDropzone,
19
+ TInputMask,
20
+ TRangeSlider,
21
+ TRichEditor,
22
+ TSortable
23
+ }
24
+
25
+ export type { RichEditorPlugin } from './richEditor'
26
+
27
+ const components = {
28
+ TAdvancedSelect, TColorPicker, TDatePicker, TDropzone, TInputMask, TRangeSlider, TRichEditor,
29
+ TSortable
30
+ }
31
+
32
+ export const GearsUIPlugins = {
33
+ install(app: App) {
34
+ for (const [name, component] of Object.entries(components)) app.component(name, component)
35
+ }
36
+ }
37
+
38
+ declare module 'vue' {
39
+ export interface GlobalComponents {
40
+ TAdvancedSelect: typeof TAdvancedSelect
41
+ TColorPicker: typeof TColorPicker
42
+ TDatePicker: typeof TDatePicker
43
+ TDropzone: typeof TDropzone
44
+ TInputMask: typeof TInputMask
45
+ TRangeSlider: typeof TRangeSlider
46
+ TRichEditor: typeof TRichEditor
47
+ TSortable: typeof TSortable
48
+ }
49
+ }
@@ -0,0 +1,7 @@
1
+ // Loads IMask and Tabler's input mask, the first time a TInputMask is shown.
2
+ import { globals, once } from './once'
3
+
4
+ export const loadInputMask = once(async () => {
5
+ globals.IMask = (await import('imask')).default
6
+ return (await import('@tabler/core')).InputMask
7
+ })
@@ -0,0 +1,8 @@
1
+ // Runs a loader once; later calls get the same promise.
2
+ export function once<T>(load: () => Promise<T>) {
3
+ let promise: Promise<T> | undefined
4
+ return () => promise ??= load()
5
+ }
6
+
7
+ // Tabler's wrappers for the date picker, input mask and sortable find their library on `window`.
8
+ export const globals = window as unknown as { VanillaCalendarPro?: unknown; IMask?: unknown; Sortable?: unknown }
@@ -0,0 +1,37 @@
1
+ /// <reference path="../shims.d.ts" />
2
+ import { once } from './once'
3
+
4
+ // HugeRTE with everything bundled: theme, model, icons, both skins and both content styles, and
5
+ // the plugins TRichEditor offers. Skins are registered as resources, so nothing is fetched.
6
+ export const richEditorPlugins = {
7
+ advlist: () => import('hugerte/plugins/advlist'),
8
+ autolink: () => import('hugerte/plugins/autolink'),
9
+ autoresize: () => import('hugerte/plugins/autoresize'),
10
+ code: () => import('hugerte/plugins/code'),
11
+ codesample: () => import('hugerte/plugins/codesample'),
12
+ fullscreen: () => import('hugerte/plugins/fullscreen'),
13
+ image: () => import('hugerte/plugins/image'),
14
+ link: () => import('hugerte/plugins/link'),
15
+ lists: () => import('hugerte/plugins/lists'),
16
+ searchreplace: () => import('hugerte/plugins/searchreplace'),
17
+ table: () => import('hugerte/plugins/table'),
18
+ wordcount: () => import('hugerte/plugins/wordcount')
19
+ }
20
+ export type RichEditorPlugin = keyof typeof richEditorPlugins
21
+
22
+ export const loadRichEditor = once(async () => {
23
+ const hugerte = (await import('hugerte')).default
24
+ await Promise.all([
25
+ import('hugerte/models/dom'),
26
+ import('hugerte/themes/silver'),
27
+ import('hugerte/icons/default'),
28
+ import('hugerte/skins/ui/oxide/skin.js'),
29
+ import('hugerte/skins/ui/oxide/content.js'),
30
+ import('hugerte/skins/ui/oxide-dark/skin.js'),
31
+ import('hugerte/skins/ui/oxide-dark/content.js'),
32
+ import('hugerte/skins/content/default/content.js'),
33
+ import('hugerte/skins/content/dark/content.js'),
34
+ ...Object.values(richEditorPlugins).map(load => load())
35
+ ])
36
+ return hugerte
37
+ })
@@ -0,0 +1,4 @@
1
+ // Loads noUiSlider, the first time a TRangeSlider is shown.
2
+ import { once } from './once'
3
+
4
+ export const loadSlider = once(async () => (await import('nouislider')).default)
@@ -0,0 +1,7 @@
1
+ // Loads SortableJS and Tabler's sortable, the first time a TSortable is shown.
2
+ import { globals, once } from './once'
3
+
4
+ export const loadSortable = once(async () => {
5
+ globals.Sortable = (await import('sortablejs')).default
6
+ return (await import('@tabler/core')).Sortable
7
+ })
@@ -0,0 +1,4 @@
1
+ // Loads Tom Select, the first time a TAdvancedSelect is shown.
2
+ import { once } from './once'
3
+
4
+ export const loadTomSelect = once(async () => (await import('tom-select')).default)
package/src/shims.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ // Types for module files that ship without their own declarations next to them.
2
+
3
+ declare module '@tabler/core/dist/js/tabler-vector-map.esm.js' {
4
+ export { default as VectorMap } from '@tabler/core/dist/types/src/vector-map'
5
+ }
6
+
7
+ declare module '@tabler/core/dist/js/maps/world.esm.js' {
8
+ import type { VectorMapData } from '@tabler/core/dist/types/src/vector-map'
9
+ export const world: VectorMapData
10
+ }
11
+
12
+ // HugeRTE's models, themes, icons, skins and plugins register themselves with the editor.
13
+ declare module 'hugerte/models/*'
14
+ declare module 'hugerte/themes/*'
15
+ declare module 'hugerte/icons/*'
16
+ declare module 'hugerte/skins/*'
17
+ declare module 'hugerte/plugins/*'