@policystudio/policy-studio-ui-vue 1.0.16 → 1.0.20

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 (51) hide show
  1. package/.eslintrc.js +67 -0
  2. package/.storybook/main.js +2 -1
  3. package/.storybook/preview.js +1 -1
  4. package/README.md +8 -0
  5. package/babel.config.js +3 -0
  6. package/backup-package-lock.json +37194 -0
  7. package/{src/assets/scss/tailwind.css → dist/css/psui_styles.css} +2213 -2735
  8. package/package.json +29 -19
  9. package/src/assets/images/check-checkbox-button.svg +1 -0
  10. package/src/assets/images/radio-checked-button.svg +1 -0
  11. package/src/assets/scss/base.scss +1 -1
  12. package/src/components/accordion/PsAccordion.vue +44 -0
  13. package/src/components/accordion/PsAccordionItem.vue +102 -0
  14. package/src/components/buttons/PsButton.vue +36 -13
  15. package/src/components/chips/PsChips.vue +164 -0
  16. package/src/components/controls/PsCheckbox.vue +3 -3
  17. package/src/components/controls/PsDraggable.vue +27 -2
  18. package/src/components/controls/PsRadioButton.vue +58 -57
  19. package/src/components/controls/PsSlider.vue +13 -12
  20. package/src/components/controls/PsSwitch.vue +76 -76
  21. package/src/components/datatable/PsDataTable.vue +89 -0
  22. package/src/components/datatable/PsDataTableItem.vue +57 -0
  23. package/src/components/forms/PsDropdown.vue +196 -0
  24. package/src/components/forms/PsInput.vue +9 -6
  25. package/src/components/tabs/PsTabHeader.vue +20 -21
  26. package/src/components/tooltip/PsDialogTooltip.vue +79 -0
  27. package/src/components/tooltip/PsRichTooltip.vue +38 -0
  28. package/src/components/tooltip/PsTooltip.vue +120 -0
  29. package/src/components/ui/PsIcon.vue +128 -0
  30. package/src/index.js +51 -22
  31. package/src/stories/Accordion.stories.js +35 -0
  32. package/src/stories/Button.stories.js +11 -11
  33. package/src/stories/Checkbox.stories.js +21 -14
  34. package/src/stories/Chips.stories.js +49 -0
  35. package/src/stories/Colors.stories.mdx +36 -35
  36. package/src/stories/Datatable.stories.js +50 -0
  37. package/src/stories/Dialog.stories.js +9 -9
  38. package/src/stories/Draggable.stories.js +24 -0
  39. package/src/stories/Dropdown.stories.js +34 -0
  40. package/src/stories/Input.stories.js +10 -10
  41. package/src/stories/RadioButton.stories.js +24 -8
  42. package/src/stories/Slider.stories.js +9 -9
  43. package/src/stories/Swith.stories.js +10 -10
  44. package/src/stories/TabHeader.stories.js +9 -9
  45. package/src/stories/Toast.stories.js +13 -13
  46. package/src/stories/Toggle.stories.js +29 -5
  47. package/src/stories/Tooltip.stories.js +113 -0
  48. package/src/util/GeneralFunctions.js +23 -0
  49. package/src/util/imageLoader.js +50 -0
  50. package/tailwind.config.js +19 -4
  51. package/src/assets/scss/tailwind.scss +0 -61088
@@ -1,17 +1,9 @@
1
1
  <template>
2
- <div class="w-full">
3
- <label class="form-control" :for="id">
4
- {{ label }}
5
- <input
6
- type="radio"
7
- name="radio"
8
- :id="id"
9
- @change="$emit('change')"
10
- v-model="childValue"
11
- />
12
- <span class="radio-button"></span>
13
- </label>
14
- </div>
2
+ <label class="wrapper flex items-center">
3
+ {{ label }}
4
+ <input class="checkbox" type="radio" :checked="isChecked" :value="value" @change="$emit('change', $event.target.value)" />
5
+ <span class="checkmark" :class="{ 'checkmark-small' : small }"></span>
6
+ </label>
15
7
  </template>
16
8
 
17
9
  <script>
@@ -19,85 +11,94 @@ export default {
19
11
  name: 'PsRadioButton',
20
12
  props: {
21
13
  label: {
22
- type: String,
23
- required: true
14
+ type: String,
15
+ default: "",
16
+ required:true
17
+ },
18
+ modelValue: {
19
+ default: ""
24
20
  },
25
21
  value: {
26
- required: true
22
+ type: String,
23
+ default: undefined
24
+ },
25
+ small: {
26
+ type: Boolean,
27
+ default: false
27
28
  }
28
29
  },
29
- data() {
30
- return {
31
- id: ''
32
- }
30
+ model: {
31
+ prop: 'modelValue',
32
+ event: 'change'
33
33
  },
34
34
  computed: {
35
- childValue: {
36
- get () {
37
- return this.value
38
- },
39
- set (newValue) {
40
- this.$emit('input', newValue )
41
- }
35
+ isChecked() {
36
+ return this.modelValue == this.value
42
37
  }
43
- },
44
- mounted() {
45
- this.id = 'teste'
46
38
  }
47
39
  }
48
40
  </script>
49
41
 
50
42
  <style scoped>
51
- .form-control {
43
+ .wrapper {
52
44
  display: block;
53
45
  position: relative;
54
- padding-left: 35px;
46
+ padding-left: 32px;
55
47
  cursor: pointer;
56
48
  -webkit-user-select: none;
57
49
  -moz-user-select: none;
58
50
  -ms-user-select: none;
59
51
  user-select: none;
60
52
  }
61
-
62
- .form-control input {
53
+ .wrapper input {
63
54
  position: absolute;
64
55
  opacity: 0;
65
56
  cursor: pointer;
57
+ height: 0;
58
+ width: 0;
66
59
  }
67
-
68
- .radio-button {
60
+ .checkmark {
69
61
  position: absolute;
70
62
  top: 0;
71
63
  left: 0;
72
- height: 20px;
73
- width: 20px;
74
- background-color: #FFF;
75
- border: 2px solid #A2ACB7;
64
+ height: 24px;
65
+ width: 24px;
76
66
  border-radius: 50%;
67
+ background-color: white;
68
+ border: 2px solid #A2ACB7;
77
69
  }
78
-
79
- .form-control input:checked ~ .radio-button {
80
- background-color: #FFF;
81
- border: 2px solid #64B5CE;
70
+ .checkmark-small {
71
+ top: 3px;
72
+ height: 18px !important;
73
+ width: 18px !important;
82
74
  }
83
-
84
- .radio-button:after {
75
+ .wrapper input:checked ~ .checkmark {
76
+ background-color: white;
77
+ border-color: #64B5CE;
78
+ border-width: 2px;
79
+ }
80
+ .checkmark:after {
85
81
  content: "";
86
82
  position: absolute;
87
83
  display: none;
88
84
  }
89
-
90
- .form-control input:checked ~ .radio-button:after {
85
+ .wrapper input:checked ~ .checkmark:after {
91
86
  display: block;
92
87
  }
93
-
94
- .form-control .radio-button:after {
95
- top: 3px;
96
- left: 3px;
97
- width: 10px;
98
- height: 10px;
99
- border-radius: 50%;
100
- background-color: #64B5CE;
88
+ .wrapper .checkmark:after {
89
+ top: 4px;
90
+ left: 4px;
91
+ width: 12px;
92
+ height: 12px;
93
+ border-radius: 50%;
94
+ background: #64B5CE;
95
+ }
96
+ .wrapper .checkmark-small:after {
97
+ top: 3px;
98
+ left: 3px;
99
+ width: 8px;
100
+ height: 8px;
101
+ border-radius: 50%;
102
+ background: #64B5CE;
101
103
  }
102
-
103
104
  </style>
@@ -29,18 +29,6 @@
29
29
  <script>
30
30
  export default {
31
31
  name: 'PsSlider',
32
- computed: {
33
- positionBubble() {
34
- if (this.bubble && this.isMounted) {
35
- return (this.$refs.slider.offsetWidth / this.max) * this.value - 15
36
- }
37
- }
38
- },
39
- methods: {
40
- getValueToScale(value) {
41
- return 100 * value / this.rangeDistanceMax
42
- }
43
- },
44
32
  props: {
45
33
  min: {
46
34
  type: Number,
@@ -75,8 +63,21 @@ export default {
75
63
  isMounted: false
76
64
  }
77
65
  },
66
+ computed: {
67
+ positionBubble() {
68
+ if (this.bubble && this.isMounted) {
69
+ return (this.$refs.slider.offsetWidth / this.max) * this.value - 15
70
+ }
71
+ return 0
72
+ }
73
+ },
78
74
  mounted() {
79
75
  this.isMounted = true
76
+ },
77
+ methods: {
78
+ getValueToScale(value) {
79
+ return 100 * value / this.rangeDistanceMax
80
+ }
80
81
  }
81
82
  }
82
83
  </script>
@@ -1,97 +1,97 @@
1
1
  <template>
2
- <label for="ps-switch" class="psui-flex psui-items-center psui-cursor-pointer psui-relative">
3
- <input type="checkbox" id="ps-switch" class="psui-hidden" :checked="active">
4
- <div
5
- :class="classes"
6
- @click="change()"
7
- ></div>
8
- <span class="psui-ml-3 psui-text-gray-50 psui-text-sm psui-font-medium">{{ label }}</span>
9
- </label>
2
+ <div class="switch-button-control">
3
+ <div
4
+ :class="{ enabled: active, 'switch-button': !small, 'switch-button-small': small }"
5
+ @click="toggle"
6
+ :style="{'--color': color}"
7
+ >
8
+ <div class="button"></div>
9
+ </div>
10
+ <div class="switch-button-label">
11
+ <slot></slot>
12
+ </div>
13
+ </div>
10
14
  </template>
11
15
 
12
16
  <script>
13
- export const sizes = ['big', 'small']
14
17
  export default {
15
18
  name: 'PsSwitch',
16
- computed: {
17
- text() {
18
- if (this.label && this.labelActived) {
19
- return this.active ? this.labelActived : this.label
20
- } else if (this.label) {
21
- return this.label
22
- } else {
23
- return false
24
- }
25
- },
26
- classes() {
27
- if (this.size === 'small') {
28
- return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-4 ps-switch-small psui-rounded-full'
29
- }
30
- return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-6 ps-switch psui-rounded-full'
31
- }
32
- },
33
19
  props: {
34
- label: String,
35
- active: {
36
- type: Boolean,
37
- default: false
38
- },
39
- disabled: {
40
- type: Boolean,
41
- default: false
42
- },
43
- size: {
44
- type: String,
45
- default: 'big',
46
- validator: (value) => sizes.indexOf(value) !== -1
47
- }
20
+ small: Boolean,
21
+ active: Boolean,
22
+ color: {
23
+ type: String,
24
+ required: false,
25
+ default: '#5DB883'
26
+ }
27
+ },
28
+ model: {
29
+ prop: "active",
30
+ event: "toggle"
48
31
  },
49
32
  methods: {
50
- change() {
51
- if (!this.disabled) {
52
- this.$emit('update:active', !this.active)
53
- this.$emit('change', !this.active)
54
- }
33
+ toggle: function() {
34
+ this.$emit('toggle', !this.active)
55
35
  }
56
36
  }
57
37
  }
58
38
  </script>
59
39
 
60
40
  <style scoped>
61
- /*
62
- @TODO - Fix the apply error
63
- https://www.dropbox.com/s/83vwthcdvdt5t97/Screen%20Shot%202022-01-06%20at%2011.49.00%20AM.png?dl=0
64
-
65
- .ps-switch {
66
- width: 46px;
41
+ .switch-button-control {
42
+ display: flex;
43
+ flex-direction: row;
44
+ align-items: center;
67
45
  }
68
- .ps-switch-small {
69
- width: 30px;
46
+ .switch-button-control .switch-button {
47
+ height: 24px;
48
+ width: calc(24px * 2);
49
+ background-color: #A2ACB7;
50
+ border: 2px solid #A2ACB7;
51
+ border-radius: 24px;
52
+ transition: all 0.3s ease-in-out;
53
+ cursor: pointer;
70
54
  }
71
- .toggle-bg:after {
72
- content: '';
73
- @apply psui-absolute psui-bg-white psui-border-gray-40 psui-rounded-full psui-h-5 psui-w-5 psui-transition;
55
+ .switch-button-control .switch-button-small {
56
+ height: 16px;
57
+ width: calc(16px * 2);
58
+ background-color: #A2ACB7;
59
+ border: 2px solid #A2ACB7;
60
+ border-radius: 16px;
61
+ transition: all 0.3s ease-in-out;
62
+ cursor: pointer;
74
63
  }
75
- .toggle-bg:after + .ps-switch-small {
76
- content: '';
77
- @apply psui-absolute psui-bg-white psui-border-gray-40 psui-rounded-full psui-h-2 psui-w-2 psui-transition;
64
+ .switch-button-control .switch-button .button {
65
+ height: calc(24px - (2 * 2px));
66
+ width: calc(24px - (2 * 2px));
67
+ border-radius: calc(24px - (2 * 2px));
68
+ background:#F3F6F9;
69
+ transition: all 0.3s ease-in-out;
78
70
  }
79
-
80
- input:checked + .toggle-bg:after + .ps-switch-small {
81
- transform: translateX(100%);
82
- position: absolute;
83
- left: 2px;
84
- @apply border-white;
71
+ .switch-button-control .switch-button-small .button {
72
+ height: calc(16px - (2 * 2px));
73
+ width: calc(16px - (2 * 2px));
74
+ border-radius: calc(16px - (2 * 2px));
75
+ background:#F3F6F9;
76
+ transition: all 0.3s ease-in-out;
85
77
  }
86
-
87
- input:checked + .toggle-bg:after {
88
- transform: translateX(100%);
89
- position: absolute;
90
- left: 4px;
91
- @apply border-white;
78
+ .switch-button-control .switch-button.enabled {
79
+ background-color: var(--color);
80
+ border: 2px solid var(--color);
92
81
  }
93
-
94
- input:checked + .toggle-bg {
95
- @apply psui-bg-green-20 psui-border-green-20;
96
- } */
97
- </style>
82
+ .switch-button-control .switch-button-small.enabled {
83
+ background-color: var(--color);
84
+ border: 2px solid var(--color);
85
+ }
86
+ .switch-button-control .switch-button.enabled .button {
87
+ background: white;
88
+ transform: translateX(calc(calc(24px - (2 * 2px)) + (2 *2px)));
89
+ }
90
+ .switch-button-control .switch-button-small.enabled .button {
91
+ background: white;
92
+ transform: translateX(calc(calc(16px - (2 * 2px)) + (2 *2px)));
93
+ }
94
+ .switch-button-control .switch-button-label {
95
+ margin-left: 10px;
96
+ }
97
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <table :class='cssAlign' class='table psui-w-full psui-border-2 psui-border-gray-10' >
3
+ <thead v-if="header">
4
+ <th
5
+ v-for="head in header"
6
+ :key="head"
7
+ class='psui-bg-gray-10 psui-text-gray-80 psui-capitalize psui-font-bold'
8
+ >
9
+ {{ head }}
10
+ </th>
11
+ </thead>
12
+ <tbody v-if="type === 'simple'">
13
+ <tr v-for="(dt, index) in data" :key="index">
14
+ <td v-for="(head, cellRow) in header" :key="cellRow">
15
+ {{ data[index][head] }}
16
+ </td>
17
+ </tr>
18
+ </tbody>
19
+ <slot v-else></slot>
20
+ <tfoot v-if="footer">
21
+ <th
22
+ v-for="ft in footer"
23
+ :key="ft"
24
+ class='psui-bg-gray-10 psui-text-gray-80'
25
+ >
26
+ {{ ft }}
27
+ </th>
28
+ </tfoot>
29
+ </table>
30
+ </template>
31
+
32
+ <script>
33
+ export const type = ['simple', 'rich']
34
+ export const alignment = ['center', 'right', 'left']
35
+
36
+ export default {
37
+ name: 'PsDataTable',
38
+ props: {
39
+ type: {
40
+ type: String,
41
+ required: true,
42
+ validator: (value) => {
43
+ return ['simple', 'rich'].indexOf(value) !== -1
44
+ },
45
+ },
46
+ header: {
47
+ type: Array,
48
+ required: true,
49
+ },
50
+ data: {
51
+ type: Array,
52
+ required: true
53
+ },
54
+ footer: {
55
+ type: Array,
56
+ },
57
+ align: {
58
+ type: String,
59
+ default: 'left',
60
+ validator: (value) => {
61
+ return ['center', 'right', 'left'].indexOf(value) !== -1
62
+ }
63
+ },
64
+ cssStyle: {
65
+ type: String,
66
+ default: 'psui-text-gray-60'
67
+ }
68
+ },
69
+ computed: {
70
+ cssAlign() {
71
+ if (this.align === 'right') return `psui-text-right ${this.cssStyle}`
72
+ if (this.align === 'center') return `psui-text-center ${this.cssStyle}`
73
+ return `psui-text-left ${this.cssStyle}`
74
+ },
75
+ },
76
+ }
77
+ </script>
78
+
79
+ <style scoped>
80
+
81
+ .table th,
82
+ .table td,
83
+ .table tr {
84
+ height: 40px;
85
+ border: 1px solid #e6ecf2;
86
+ padding: 11px 16px;
87
+ }
88
+
89
+ </style>
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <tbody v-if="data">
3
+ <tr v-for="(dt, index) in data" :key="index" >
4
+ <td v-for="(el, elIndex) in dt" :key="elIndex" class="psui-px-4 psui-py-2">
5
+ <div class="psui-flex psui-gap-1 psui-items-center">
6
+ <span class="psui-text-gray-80">
7
+ {{ el[Object.keys(el)[1]].toFixed(3) }}
8
+ </span>
9
+ <div
10
+ class="psui-flex psui-items-center"
11
+ :class="
12
+ el[Object.keys(el)[1]] >= 0
13
+ ? 'psui-text-green-70'
14
+ : 'psui-text-red-70'
15
+ "
16
+ >
17
+ <i v-if="el[Object.keys(el)[1]] >= 0" class="material-icons">arrow_upward</i>
18
+ <i v-else class="material-icons">arrow_downward</i>
19
+ <span>
20
+ {{
21
+ (
22
+ (el[Object.keys(el)[1]] / el[Object.keys(el)[0]]) *
23
+ 100
24
+ ).toFixed(2)
25
+ }}%
26
+ </span>
27
+ </div>
28
+ </div>
29
+ <span class="psui-text-gray-50">{{
30
+ el[Object.keys(el)[0]].toFixed(6)
31
+ }}</span>
32
+ </td>
33
+ </tr>
34
+ </tbody>
35
+ </template>
36
+
37
+ <script>
38
+ export default {
39
+ name: "PsDataTableItem",
40
+ props: {
41
+ data: {
42
+ type: Array,
43
+ required: true,
44
+ default: () => {
45
+ return []
46
+ },
47
+ },
48
+ },
49
+ }
50
+ </script>
51
+
52
+ <style scoped>
53
+ .material-icons {
54
+ font-size: 15px;
55
+ margin-bottom: 2px;
56
+ }
57
+ </style>