@policystudio/policy-studio-ui-vue 1.0.18 → 1.0.22

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 (66) hide show
  1. package/.eslintrc.js +67 -0
  2. package/.storybook/main.js +11 -2
  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} +16720 -17120
  8. package/package.json +32 -19
  9. package/postcss.config.js +2 -0
  10. package/src/assets/images/check-checkbox-button.svg +1 -0
  11. package/src/assets/images/radio-checked-button.svg +1 -0
  12. package/src/assets/scss/base.scss +6 -5
  13. package/src/assets/scss/components/PsInput.scss +89 -0
  14. package/src/components/accordion/PsAccordion.vue +40 -0
  15. package/src/components/accordion/PsAccordionItem.vue +102 -0
  16. package/src/components/badges-and-tags/PsChartLegend.vue +128 -0
  17. package/src/components/badges-and-tags/PsClimateZoneBadge.vue +18 -0
  18. package/src/components/badges-and-tags/PsCostEffectBar.vue +114 -0
  19. package/src/components/badges-and-tags/PsHighlightRippleDot.vue +78 -0
  20. package/src/components/badges-and-tags/PsMiniTag.vue +46 -0
  21. package/src/components/badges-and-tags/PsProgressBar.vue +0 -0
  22. package/src/components/buttons/PsButton.vue +36 -13
  23. package/src/components/chips/PsChips.vue +154 -0
  24. package/src/components/controls/PsCheckbox.vue +30 -17
  25. package/src/components/controls/PsDraggable.vue +174 -3
  26. package/src/components/controls/PsRadioButton.vue +67 -60
  27. package/src/components/controls/PsSlider.vue +13 -12
  28. package/src/components/controls/PsSwitch.vue +76 -76
  29. package/src/components/datatable/PsDataTable.vue +89 -0
  30. package/src/components/datatable/PsDataTableItem.vue +57 -0
  31. package/src/components/forms/PsDropdown.vue +196 -0
  32. package/src/components/forms/PsInput.vue +122 -99
  33. package/src/components/notifications/PsDialog.vue +37 -18
  34. package/src/components/tabs/PsTabHeader.vue +20 -21
  35. package/src/components/tooltip/PsDialogTooltip.vue +79 -0
  36. package/src/components/tooltip/PsRichTooltip.vue +44 -0
  37. package/src/components/tooltip/PsTooltip.vue +118 -0
  38. package/src/components/ui/PsIcon.vue +128 -0
  39. package/src/index.js +53 -24
  40. package/src/stories/Accordion.stories.js +41 -0
  41. package/src/stories/Button.stories.js +11 -11
  42. package/src/stories/ChartLegend.stories.js +16 -0
  43. package/src/stories/Checkbox.stories.js +21 -14
  44. package/src/stories/Chips.stories.js +55 -0
  45. package/src/stories/ClimateZoneBadge.stories.js +24 -0
  46. package/src/stories/Colors.stories.mdx +35 -35
  47. package/src/stories/CostEffectBar.stories.js +23 -0
  48. package/src/stories/Datatable.stories.js +50 -0
  49. package/src/stories/Dialog.stories.js +150 -17
  50. package/src/stories/Draggable.stories.js +22 -0
  51. package/src/stories/Dropdown.stories.js +32 -0
  52. package/src/stories/HighlightRippleDot.stories.js +16 -0
  53. package/src/stories/Input.stories.js +46 -15
  54. package/src/stories/MiniTag.stories.js +46 -0
  55. package/src/stories/ProgressBar.stories.js +23 -0
  56. package/src/stories/RadioButton.stories.js +25 -9
  57. package/src/stories/Slider.stories.js +9 -9
  58. package/src/stories/Swith.stories.js +10 -10
  59. package/src/stories/TabHeader.stories.js +9 -9
  60. package/src/stories/Toast.stories.js +13 -13
  61. package/src/stories/Toggle.stories.js +12 -13
  62. package/src/stories/Tooltip.stories.js +114 -0
  63. package/src/util/GeneralFunctions.js +22 -0
  64. package/src/util/imageLoader.js +50 -0
  65. package/tailwind.config.js +82 -45
  66. package/src/assets/scss/tailwind.scss +0 -61088
@@ -1,17 +1,15 @@
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
5
+ class="checkbox"
6
+ type="radio"
7
+ :checked="isChecked"
8
+ :value="value"
9
+ @change="$emit('change', $event.target.value)"
10
+ />
11
+ <span class="checkmark" :class="{ 'checkmark-small': small }"></span>
12
+ </label>
15
13
  </template>
16
14
 
17
15
  <script>
@@ -20,84 +18,93 @@ export default {
20
18
  props: {
21
19
  label: {
22
20
  type: String,
23
- required: true
21
+ default: '',
22
+ required: true,
23
+ },
24
+ modelValue: {
25
+ default: '',
24
26
  },
25
27
  value: {
26
- required: true
27
- }
28
+ type: String,
29
+ default: undefined,
30
+ },
31
+ small: {
32
+ type: Boolean,
33
+ default: false,
34
+ },
28
35
  },
29
- data() {
30
- return {
31
- id: ''
32
- }
36
+ model: {
37
+ prop: 'modelValue',
38
+ event: 'change',
33
39
  },
34
40
  computed: {
35
- childValue: {
36
- get () {
37
- return this.value
38
- },
39
- set (newValue) {
40
- this.$emit('input', newValue )
41
- }
42
- }
41
+ isChecked() {
42
+ return this.modelValue == this.value
43
+ },
43
44
  },
44
- mounted() {
45
- this.id = 'teste'
46
- }
47
45
  }
48
46
  </script>
49
47
 
50
48
  <style scoped>
51
- .form-control {
49
+ .wrapper {
52
50
  display: block;
53
51
  position: relative;
54
- padding-left: 35px;
52
+ padding-left: 32px;
55
53
  cursor: pointer;
56
54
  -webkit-user-select: none;
57
55
  -moz-user-select: none;
58
56
  -ms-user-select: none;
59
57
  user-select: none;
60
58
  }
61
-
62
- .form-control input {
59
+ .wrapper input {
63
60
  position: absolute;
64
61
  opacity: 0;
65
62
  cursor: pointer;
63
+ height: 0;
64
+ width: 0;
66
65
  }
67
-
68
- .radio-button {
66
+ .checkmark {
69
67
  position: absolute;
70
68
  top: 0;
71
69
  left: 0;
72
- height: 20px;
73
- width: 20px;
74
- background-color: #FFF;
75
- border: 2px solid #A2ACB7;
70
+ height: 24px;
71
+ width: 24px;
76
72
  border-radius: 50%;
73
+ background-color: white;
74
+ border: 2px solid #a2acb7;
77
75
  }
78
-
79
- .form-control input:checked ~ .radio-button {
80
- background-color: #FFF;
81
- border: 2px solid #64B5CE;
76
+ .checkmark-small {
77
+ top: 3px;
78
+ height: 18px !important;
79
+ width: 18px !important;
82
80
  }
83
-
84
- .radio-button:after {
85
- content: "";
81
+ .wrapper input:checked ~ .checkmark {
82
+ background-color: white;
83
+ border-color: #64b5ce;
84
+ border-width: 2px;
85
+ }
86
+ .checkmark:after {
87
+ content: '';
86
88
  position: absolute;
87
89
  display: none;
88
90
  }
89
-
90
- .form-control input:checked ~ .radio-button:after {
91
+ .wrapper input:checked ~ .checkmark:after {
91
92
  display: block;
92
93
  }
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;
94
+ .wrapper .checkmark:after {
95
+ top: 4px;
96
+ left: 4px;
97
+ width: 12px;
98
+ height: 12px;
99
+ border-radius: 50%;
100
+ background: #64b5ce;
101
+ }
102
+ .wrapper .checkmark-small:after {
103
+ top: 3px;
104
+ left: 3px;
105
+ width: 8px;
106
+ height: 8px;
107
+ border-radius: 50%;
108
+ background: #64b5ce;
101
109
  }
102
-
103
- </style>
110
+ </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>