mertani-web-toolkit 0.1.37 → 0.1.38

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 (171) hide show
  1. package/README.md +60 -60
  2. package/dist/components/Button/Button.svelte +198 -198
  3. package/dist/components/Button/button.css +94 -94
  4. package/dist/components/HeaderContent/HeaderContent.svelte +45 -45
  5. package/dist/components/Icon/Icon.svelte +124 -124
  6. package/dist/components/Icon/IconLibrary.svelte +199 -199
  7. package/dist/components/Illustration/Illustration.svelte +77 -77
  8. package/dist/components/Illustration/IllustrationLibrary.svelte +290 -290
  9. package/dist/components/Illustration/co-Disconnect1.svelte +29 -29
  10. package/dist/components/Illustration/co-Disconnect2.svelte +25 -25
  11. package/dist/components/Illustration/co-EmptyState1.svelte +28 -28
  12. package/dist/components/Illustration/co-EmptyState2.svelte +21 -21
  13. package/dist/components/Illustration/co-EmptyState3.svelte +17 -17
  14. package/dist/components/Illustration/co-ErrorNetwork1.svelte +18 -18
  15. package/dist/components/Illustration/co-ErrorNetwork2.svelte +15 -15
  16. package/dist/components/Illustration/co-LogOut1.svelte +14 -14
  17. package/dist/components/Illustration/co-LogOut2.svelte +13 -13
  18. package/dist/components/Illustration/co-LogOut3.svelte +12 -12
  19. package/dist/components/Illustration/co-RTO1.svelte +23 -23
  20. package/dist/components/Illustration/co-RTO2.svelte +26 -26
  21. package/dist/components/Illustration/co-ServerError1.svelte +38 -38
  22. package/dist/components/Illustration/co-ServerError2.svelte +25 -25
  23. package/dist/components/Illustration/co-ServerError3.svelte +25 -25
  24. package/dist/components/Illustration/def-BlankBoxEmpty.svelte +14 -14
  25. package/dist/components/Illustration/def-BubbleChat.svelte +14 -14
  26. package/dist/components/Illustration/def-CheckSuccess.svelte +24 -24
  27. package/dist/components/Illustration/def-CompanyBuilding.svelte +13 -13
  28. package/dist/components/Illustration/def-ErrorCloud.svelte +20 -20
  29. package/dist/components/Illustration/def-GlassCupCoffeeTea.svelte +15 -15
  30. package/dist/components/Illustration/def-ImageGallery.svelte +18 -18
  31. package/dist/components/Illustration/def-LocationNavigation.svelte +17 -17
  32. package/dist/components/Illustration/def-PaperFile.svelte +14 -14
  33. package/dist/components/Illustration/def-PaymentCard.svelte +14 -14
  34. package/dist/components/Illustration/def-QRScanCode.svelte +12 -12
  35. package/dist/components/Illustration/def-Searching.svelte +19 -19
  36. package/dist/components/Illustration/def-ShoppingBag.svelte +20 -20
  37. package/dist/components/Illustration/def-SleepCloud.svelte +16 -16
  38. package/dist/components/Illustration/def-warning.svelte +17 -17
  39. package/dist/components/Table/Table.svelte +496 -484
  40. package/dist/components/Table/TableBadge.svelte +45 -45
  41. package/dist/components/Table/TablePagination.svelte +282 -282
  42. package/dist/components/Table/TableShimmer.svelte +46 -46
  43. package/dist/components/Tabs/Tabs.svelte +33 -33
  44. package/dist/components/inputs/MultiSelectInput/MultiSelectInput.css +249 -249
  45. package/dist/components/inputs/MultiSelectInput/MultiSelectInput.svelte +600 -600
  46. package/dist/components/inputs/Radio/Radio.css +49 -49
  47. package/dist/components/inputs/Radio/Radio.svelte +203 -203
  48. package/dist/components/inputs/Segmented/Segmented.css +114 -114
  49. package/dist/components/inputs/Segmented/Segmented.svelte +209 -209
  50. package/dist/components/inputs/SelectInput/SelectInput.css +171 -171
  51. package/dist/components/inputs/SelectInput/SelectInput.svelte +460 -460
  52. package/dist/components/inputs/Steppers/Steppers.css +152 -152
  53. package/dist/components/inputs/Steppers/Steppers.svelte +259 -259
  54. package/dist/components/inputs/TextInput/TextInput.css +210 -210
  55. package/dist/components/inputs/TextInput/TextInput.svelte +412 -412
  56. package/dist/components/inputs/TextareaInput/TextareaInput.css +127 -127
  57. package/dist/components/inputs/TextareaInput/TextareaInput.svelte +326 -326
  58. package/dist/icons/BsActivity.svelte +2 -2
  59. package/dist/icons/BsArrow90degLeft.svelte +5 -5
  60. package/dist/icons/BsArrow90degRight.svelte +5 -5
  61. package/dist/icons/BsArrowDownCircle.svelte +5 -5
  62. package/dist/icons/BsArrowRepeat.svelte +3 -3
  63. package/dist/icons/BsArrowReturnLeft.svelte +2 -2
  64. package/dist/icons/BsArrowRightShort.svelte +2 -2
  65. package/dist/icons/BsArrowUpCircle.svelte +5 -5
  66. package/dist/icons/BsBarChart.svelte +2 -2
  67. package/dist/icons/BsBarChartLine.svelte +2 -2
  68. package/dist/icons/BsBatteryHalf.svelte +3 -3
  69. package/dist/icons/BsBoxArrowInRight.svelte +3 -3
  70. package/dist/icons/BsBoxArrowLeft.svelte +6 -6
  71. package/dist/icons/BsBoxArrowRight.svelte +6 -6
  72. package/dist/icons/BsBoxArrowUpRight.svelte +6 -6
  73. package/dist/icons/BsCalendar.svelte +5 -5
  74. package/dist/icons/BsCalendar3.svelte +6 -6
  75. package/dist/icons/BsCalendar4.svelte +5 -5
  76. package/dist/icons/BsCameraVideoOff.svelte +5 -5
  77. package/dist/icons/BsCheck2Circle.svelte +3 -3
  78. package/dist/icons/BsCheckCircle.svelte +6 -6
  79. package/dist/icons/BsCheckCircleFill.svelte +5 -5
  80. package/dist/icons/BsCheckLg.svelte +2 -2
  81. package/dist/icons/BsCheckSquare.svelte +6 -6
  82. package/dist/icons/BsChevronDown.svelte +2 -2
  83. package/dist/icons/BsChevronLeft.svelte +2 -2
  84. package/dist/icons/BsChevronRight.svelte +2 -2
  85. package/dist/icons/BsChevronUp.svelte +2 -2
  86. package/dist/icons/BsClock.svelte +6 -6
  87. package/dist/icons/BsClockHistory.svelte +7 -7
  88. package/dist/icons/BsCopy.svelte +5 -5
  89. package/dist/icons/BsDashLg.svelte +2 -2
  90. package/dist/icons/BsDownload.svelte +3 -3
  91. package/dist/icons/BsExclamationCircle.svelte +6 -6
  92. package/dist/icons/BsExclamationOctagonFill.svelte +5 -5
  93. package/dist/icons/BsExclamationTriangle.svelte +6 -6
  94. package/dist/icons/BsEye.svelte +3 -3
  95. package/dist/icons/BsFileText.svelte +3 -3
  96. package/dist/icons/BsFilter.svelte +2 -2
  97. package/dist/icons/BsFloppy.svelte +6 -6
  98. package/dist/icons/BsFullscreen.svelte +5 -5
  99. package/dist/icons/BsFullscreenExit.svelte +5 -5
  100. package/dist/icons/BsGear.svelte +6 -6
  101. package/dist/icons/BsGrid.svelte +2 -2
  102. package/dist/icons/BsGrid3x3Gap.svelte +2 -2
  103. package/dist/icons/BsHdd.svelte +3 -3
  104. package/dist/icons/BsImage.svelte +6 -6
  105. package/dist/icons/BsInfoCircle.svelte +6 -6
  106. package/dist/icons/BsInputPrefix.svelte +3 -3
  107. package/dist/icons/BsLayoutSidebar.svelte +2 -2
  108. package/dist/icons/BsList.svelte +2 -2
  109. package/dist/icons/BsMap.svelte +5 -5
  110. package/dist/icons/BsNut.svelte +6 -6
  111. package/dist/icons/BsPencil.svelte +5 -5
  112. package/dist/icons/BsPlusLg.svelte +2 -2
  113. package/dist/icons/BsSearch.svelte +5 -5
  114. package/dist/icons/BsSliders2Vertical.svelte +2 -2
  115. package/dist/icons/BsTextCenter.svelte +2 -2
  116. package/dist/icons/BsTextLeft.svelte +2 -2
  117. package/dist/icons/BsTextRight.svelte +2 -2
  118. package/dist/icons/BsThreeDots.svelte +2 -2
  119. package/dist/icons/BsThreeDotsVertical.svelte +2 -2
  120. package/dist/icons/BsTrash.svelte +3 -3
  121. package/dist/icons/BsTypeBold.svelte +2 -2
  122. package/dist/icons/BsTypeItalic.svelte +2 -2
  123. package/dist/icons/BsTypeUnderline.svelte +2 -2
  124. package/dist/icons/BsUpload.svelte +3 -3
  125. package/dist/icons/BsViewStacked.svelte +2 -2
  126. package/dist/icons/BsXCircle.svelte +6 -6
  127. package/dist/icons/BsXCircleFill.svelte +5 -5
  128. package/dist/icons/BsXLg.svelte +3 -3
  129. package/dist/icons/BsXSquare.svelte +6 -6
  130. package/dist/icons/ChevronDown.svelte +52 -52
  131. package/dist/icons/CoGarisLurus.svelte +13 -13
  132. package/dist/icons/CoLink.svelte +13 -13
  133. package/dist/icons/CoPadi.svelte +13 -13
  134. package/dist/icons/CoPalawija.svelte +17 -17
  135. package/dist/icons/CoTebu.svelte +17 -17
  136. package/dist/icons/GearTwo.svelte +26 -26
  137. package/dist/icons/Logout.svelte +15 -15
  138. package/dist/icons/MsArrowRange.svelte +13 -13
  139. package/dist/icons/MsControlCamera.svelte +13 -13
  140. package/dist/icons/MsGarageDoor.svelte +13 -13
  141. package/dist/icons/MsGarageHome.svelte +13 -13
  142. package/dist/icons/MsGraph1.svelte +13 -13
  143. package/dist/icons/MsGridOn.svelte +13 -13
  144. package/dist/icons/MsHighDensity.svelte +13 -13
  145. package/dist/icons/MsRoute.svelte +13 -13
  146. package/dist/icons/MsSpatialSpeaker.svelte +13 -13
  147. package/dist/icons/Sim_B_Bagi.svelte +9 -9
  148. package/dist/icons/Sim_B_Bagi_Sadap.svelte +10 -10
  149. package/dist/icons/Sim_B_Intake_Bendung.svelte +22 -22
  150. package/dist/icons/Sim_B_Sadap.svelte +9 -9
  151. package/dist/icons/Sim_Box_Tersier.svelte +17 -17
  152. package/dist/icons/Sim_Freetext.svelte +11 -11
  153. package/dist/icons/Sim_Gorong2.svelte +26 -26
  154. package/dist/icons/Sim_Jembatan.svelte +20 -20
  155. package/dist/icons/Sim_Petak_Tersier.svelte +17 -17
  156. package/dist/icons/Sim_Saluran_Pembuang.svelte +14 -14
  157. package/dist/icons/Sim_Saluran_Primer.svelte +15 -15
  158. package/dist/icons/Sim_Saluran_Sekunder.svelte +15 -15
  159. package/dist/icons/Sim_Saluran_Tersier.svelte +15 -15
  160. package/dist/icons/Sim_Subskema.svelte +16 -16
  161. package/dist/icons/Sim_Syphon.svelte +39 -39
  162. package/dist/icons/Sim_Talang.svelte +18 -18
  163. package/dist/icons/Sim_Terowongan.svelte +41 -41
  164. package/dist/icons/User.svelte +20 -20
  165. package/dist/icons/Window.svelte +6 -6
  166. package/dist/layouts/IMS/IMSLayout1/IMSLayout1.css +2 -2
  167. package/dist/layouts/IMS/IMSLayout1/IMSLayout1.svelte +38 -38
  168. package/dist/layouts/IMS/IMSLayout1/components/ImsHeader.svelte +20 -20
  169. package/dist/layouts/IMS/IMSLayout1/components/ImsSidebar.svelte +469 -469
  170. package/dist/themes/mertani.json +104 -104
  171. package/package.json +80 -79
package/README.md CHANGED
@@ -1,60 +1,60 @@
1
- # Svelte library
2
-
3
- Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
-
5
- Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
-
7
- 📘 **Documentation:** [storybook.mertani.com](https://storybook.mertani.com/)
8
-
9
- ## Creating a project
10
-
11
- If you're seeing this, you've probably already done this step. Congrats!
12
-
13
- ```sh
14
- # create a new project in the current directory
15
- npx sv create
16
-
17
- # create a new project in my-app
18
- npx sv create my-app
19
- ```
20
-
21
- ## Developing
22
-
23
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
24
-
25
- ```sh
26
- npm run dev
27
-
28
- # or start the server and open the app in a new browser tab
29
- npm run dev -- --open
30
- ```
31
-
32
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
33
-
34
- ## Building
35
-
36
- To build your library:
37
-
38
- ```sh
39
- npm pack
40
- ```
41
-
42
- To create a production version of your showcase app:
43
-
44
- ```sh
45
- npm run build
46
- ```
47
-
48
- You can preview the production build with `npm run preview`.
49
-
50
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
51
-
52
- ## Publishing
53
-
54
- Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
55
-
56
- To publish your library to [npm](https://www.npmjs.com):
57
-
58
- ```sh
59
- npm publish
60
- ```
1
+ # Svelte library
2
+
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
+
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
+
7
+ 📘 **Documentation:** [storybook.mertani.com](https://storybook.mertani.com/)
8
+
9
+ ## Creating a project
10
+
11
+ If you're seeing this, you've probably already done this step. Congrats!
12
+
13
+ ```sh
14
+ # create a new project in the current directory
15
+ npx sv create
16
+
17
+ # create a new project in my-app
18
+ npx sv create my-app
19
+ ```
20
+
21
+ ## Developing
22
+
23
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
24
+
25
+ ```sh
26
+ npm run dev
27
+
28
+ # or start the server and open the app in a new browser tab
29
+ npm run dev -- --open
30
+ ```
31
+
32
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
33
+
34
+ ## Building
35
+
36
+ To build your library:
37
+
38
+ ```sh
39
+ npm pack
40
+ ```
41
+
42
+ To create a production version of your showcase app:
43
+
44
+ ```sh
45
+ npm run build
46
+ ```
47
+
48
+ You can preview the production build with `npm run preview`.
49
+
50
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
51
+
52
+ ## Publishing
53
+
54
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
55
+
56
+ To publish your library to [npm](https://www.npmjs.com):
57
+
58
+ ```sh
59
+ npm publish
60
+ ```
@@ -1,198 +1,198 @@
1
- <script lang="ts">
2
- import './button.css';
3
- import { Icon } from '../../index.js';
4
- import type { TIconName } from '../../icons/index.js';
5
- import type { HTMLButtonAttributes } from 'svelte/elements';
6
-
7
- interface Props extends Omit<HTMLButtonAttributes, 'type'> {
8
- // ===Styles===
9
- type?: 'solid' | 'outline';
10
- size?: 48 | 40 | 32;
11
- backgroundColor?: string;
12
- textColor?: string;
13
- borderColor?: string;
14
- loaderColor?: string;
15
- icon?: TIconName;
16
- iconColor?: string;
17
- iconPosition?: 'left' | 'right';
18
- borderRadius?: number;
19
- boxShadow?: string;
20
-
21
- // ===Properties===
22
- // Data
23
- label?: string;
24
-
25
- // Events
26
- onclick?: () => void;
27
- onmouseenter?: () => void;
28
-
29
- // Additional Actions
30
- isLoading?: boolean;
31
- isShow?: boolean;
32
- disabled?: boolean;
33
- tooltip?: string;
34
-
35
- // Any
36
- class?: string;
37
- style?: string;
38
- }
39
-
40
- const {
41
- // ===Styles===
42
- type = 'solid',
43
- size = 40,
44
- backgroundColor = 'var(--color-bg-act-primary)',
45
- textColor = '',
46
- borderColor = 'var(--color-bg-act-primary)',
47
- loaderColor = '',
48
- icon,
49
- iconColor = '',
50
- iconPosition = 'right',
51
- borderRadius,
52
- boxShadow = '',
53
-
54
- // ===Properties===
55
- // Data
56
- label = 'Button',
57
-
58
- // Additional Actions
59
- isLoading = false,
60
- isShow = true,
61
- disabled = false,
62
- tooltip = '',
63
-
64
- class: className = '',
65
- style: customStyle = '',
66
- onclick,
67
- onmouseenter,
68
- ...props
69
- }: Props = $props();
70
-
71
- // Size mapping untuk height dan padding
72
- const sizeConfig = $derived(() => {
73
- switch (size) {
74
- case 48:
75
- return { height: '48px', padding: '10px 24px', fontSize: '18px', borderRadius: '8px' };
76
- case 40:
77
- return { height: '40px', padding: '8px 16px', fontSize: '16px', borderRadius: '8px' };
78
- case 32:
79
- return { height: '32px', padding: '6px 12px', fontSize: '14px', borderRadius: '6px' };
80
- default:
81
- return { height: '40px', padding: '8px 16px', fontSize: '16px', borderRadius: '8px' };
82
- }
83
- });
84
-
85
- // Computed styles
86
- const buttonStyles = $derived(() => {
87
- const styles: string[] = [];
88
-
89
- // Size styles
90
- styles.push(`height: ${sizeConfig().height};`);
91
- styles.push(`padding: ${sizeConfig().padding};`);
92
- styles.push(`font-size: ${sizeConfig().fontSize};`);
93
- styles.push(`border-radius: ${sizeConfig().borderRadius};`);
94
-
95
- if (borderRadius) {
96
- styles.push(`border-radius: ${borderRadius}px;`);
97
- }
98
-
99
- if (type === 'solid') {
100
- if (backgroundColor) {
101
- styles.push(`--btn-background-color: ${backgroundColor};`);
102
- styles.push(`--hover-btn-background-color: ${backgroundColor};`);
103
- styles.push(`--active-btn-background-color: ${backgroundColor};`);
104
- }
105
- if (textColor) {
106
- styles.push(`--btn-color: ${textColor};`);
107
- }
108
- if (borderColor) {
109
- styles.push(`--btn-border-color: ${borderColor};`);
110
- }
111
- } else if (type === 'outline') {
112
- if (backgroundColor) {
113
- styles.push(`--btn-background-color: transparent;`);
114
- styles.push(`--hover-btn-background-color: ${backgroundColor};`);
115
- }
116
- if (textColor) {
117
- styles.push(`--btn-color: ${textColor};`);
118
- }
119
- if (borderColor) {
120
- styles.push(`--btn-border-color: ${borderColor};`);
121
- } else if (textColor) {
122
- styles.push(`--btn-border-color: ${textColor};`);
123
- }
124
- }
125
-
126
- if (boxShadow) {
127
- styles.push(`box-shadow: ${boxShadow};`);
128
- }
129
-
130
- if (customStyle) {
131
- styles.push(customStyle);
132
- }
133
-
134
- return styles.join(' ');
135
- });
136
-
137
- const buttonClasses = $derived(() => {
138
- const classes = ['btn', `btn-${type}`, `hover:bg-[${backgroundColor}]`];
139
-
140
- if (isLoading) {
141
- classes.push('btn-loading');
142
- }
143
-
144
- if (disabled) {
145
- classes.push('btn-disabled');
146
- }
147
-
148
- if (className) {
149
- classes.push(className);
150
- }
151
-
152
- return classes.join(' ');
153
- });
154
-
155
- function handleClick() {
156
- if (!disabled && !isLoading && onclick) {
157
- onclick();
158
- }
159
- }
160
-
161
- function handleMouseEnter() {
162
- if (!disabled && !isLoading && onmouseenter) {
163
- onmouseenter();
164
- }
165
- }
166
- </script>
167
-
168
- {#if isShow}
169
- <button
170
- type="button"
171
- class={buttonClasses()}
172
- style={buttonStyles()}
173
- disabled={disabled || isLoading}
174
- onclick={handleClick}
175
- onmouseenter={handleMouseEnter}
176
- title={tooltip || ''}
177
- {...props}
178
- >
179
- {#if isLoading}
180
- <span
181
- class="btn-loader"
182
- style={loaderColor
183
- ? `border-top-color: ${loaderColor}; border-right-color: ${loaderColor};`
184
- : ''}
185
- ></span>
186
- {:else if icon && iconPosition === 'left'}
187
- <Icon name={icon} color={iconColor || 'currentColor'} width={16} height={16} />
188
- {/if}
189
-
190
- {#if label}
191
- <span class="btn-label">{label}</span>
192
- {/if}
193
-
194
- {#if !isLoading && icon && iconPosition === 'right'}
195
- <Icon name={icon} color={iconColor || 'currentColor'} width={16} height={16} />
196
- {/if}
197
- </button>
198
- {/if}
1
+ <script lang="ts">
2
+ import './button.css';
3
+ import { Icon } from '../../index.js';
4
+ import type { TIconName } from '../../icons/index.js';
5
+ import type { HTMLButtonAttributes } from 'svelte/elements';
6
+
7
+ interface Props extends Omit<HTMLButtonAttributes, 'type'> {
8
+ // ===Styles===
9
+ type?: 'solid' | 'outline';
10
+ size?: 48 | 40 | 32;
11
+ backgroundColor?: string;
12
+ textColor?: string;
13
+ borderColor?: string;
14
+ loaderColor?: string;
15
+ icon?: TIconName;
16
+ iconColor?: string;
17
+ iconPosition?: 'left' | 'right';
18
+ borderRadius?: number;
19
+ boxShadow?: string;
20
+
21
+ // ===Properties===
22
+ // Data
23
+ label?: string;
24
+
25
+ // Events
26
+ onclick?: () => void;
27
+ onmouseenter?: () => void;
28
+
29
+ // Additional Actions
30
+ isLoading?: boolean;
31
+ isShow?: boolean;
32
+ disabled?: boolean;
33
+ tooltip?: string;
34
+
35
+ // Any
36
+ class?: string;
37
+ style?: string;
38
+ }
39
+
40
+ const {
41
+ // ===Styles===
42
+ type = 'solid',
43
+ size = 40,
44
+ backgroundColor = 'var(--color-bg-act-primary)',
45
+ textColor = '',
46
+ borderColor = 'var(--color-bg-act-primary)',
47
+ loaderColor = '',
48
+ icon,
49
+ iconColor = '',
50
+ iconPosition = 'right',
51
+ borderRadius,
52
+ boxShadow = '',
53
+
54
+ // ===Properties===
55
+ // Data
56
+ label = 'Button',
57
+
58
+ // Additional Actions
59
+ isLoading = false,
60
+ isShow = true,
61
+ disabled = false,
62
+ tooltip = '',
63
+
64
+ class: className = '',
65
+ style: customStyle = '',
66
+ onclick,
67
+ onmouseenter,
68
+ ...props
69
+ }: Props = $props();
70
+
71
+ // Size mapping untuk height dan padding
72
+ const sizeConfig = $derived(() => {
73
+ switch (size) {
74
+ case 48:
75
+ return { height: '48px', padding: '10px 24px', fontSize: '18px', borderRadius: '8px' };
76
+ case 40:
77
+ return { height: '40px', padding: '8px 16px', fontSize: '16px', borderRadius: '8px' };
78
+ case 32:
79
+ return { height: '32px', padding: '6px 12px', fontSize: '14px', borderRadius: '6px' };
80
+ default:
81
+ return { height: '40px', padding: '8px 16px', fontSize: '16px', borderRadius: '8px' };
82
+ }
83
+ });
84
+
85
+ // Computed styles
86
+ const buttonStyles = $derived(() => {
87
+ const styles: string[] = [];
88
+
89
+ // Size styles
90
+ styles.push(`height: ${sizeConfig().height};`);
91
+ styles.push(`padding: ${sizeConfig().padding};`);
92
+ styles.push(`font-size: ${sizeConfig().fontSize};`);
93
+ styles.push(`border-radius: ${sizeConfig().borderRadius};`);
94
+
95
+ if (borderRadius) {
96
+ styles.push(`border-radius: ${borderRadius}px;`);
97
+ }
98
+
99
+ if (type === 'solid') {
100
+ if (backgroundColor) {
101
+ styles.push(`--btn-background-color: ${backgroundColor};`);
102
+ styles.push(`--hover-btn-background-color: ${backgroundColor};`);
103
+ styles.push(`--active-btn-background-color: ${backgroundColor};`);
104
+ }
105
+ if (textColor) {
106
+ styles.push(`--btn-color: ${textColor};`);
107
+ }
108
+ if (borderColor) {
109
+ styles.push(`--btn-border-color: ${borderColor};`);
110
+ }
111
+ } else if (type === 'outline') {
112
+ if (backgroundColor) {
113
+ styles.push(`--btn-background-color: transparent;`);
114
+ styles.push(`--hover-btn-background-color: ${backgroundColor};`);
115
+ }
116
+ if (textColor) {
117
+ styles.push(`--btn-color: ${textColor};`);
118
+ }
119
+ if (borderColor) {
120
+ styles.push(`--btn-border-color: ${borderColor};`);
121
+ } else if (textColor) {
122
+ styles.push(`--btn-border-color: ${textColor};`);
123
+ }
124
+ }
125
+
126
+ if (boxShadow) {
127
+ styles.push(`box-shadow: ${boxShadow};`);
128
+ }
129
+
130
+ if (customStyle) {
131
+ styles.push(customStyle);
132
+ }
133
+
134
+ return styles.join(' ');
135
+ });
136
+
137
+ const buttonClasses = $derived(() => {
138
+ const classes = ['btn', `btn-${type}`, `hover:bg-[${backgroundColor}]`];
139
+
140
+ if (isLoading) {
141
+ classes.push('btn-loading');
142
+ }
143
+
144
+ if (disabled) {
145
+ classes.push('btn-disabled');
146
+ }
147
+
148
+ if (className) {
149
+ classes.push(className);
150
+ }
151
+
152
+ return classes.join(' ');
153
+ });
154
+
155
+ function handleClick() {
156
+ if (!disabled && !isLoading && onclick) {
157
+ onclick();
158
+ }
159
+ }
160
+
161
+ function handleMouseEnter() {
162
+ if (!disabled && !isLoading && onmouseenter) {
163
+ onmouseenter();
164
+ }
165
+ }
166
+ </script>
167
+
168
+ {#if isShow}
169
+ <button
170
+ type="button"
171
+ class={buttonClasses()}
172
+ style={buttonStyles()}
173
+ disabled={disabled || isLoading}
174
+ onclick={handleClick}
175
+ onmouseenter={handleMouseEnter}
176
+ title={tooltip || ''}
177
+ {...props}
178
+ >
179
+ {#if isLoading}
180
+ <span
181
+ class="btn-loader"
182
+ style={loaderColor
183
+ ? `border-top-color: ${loaderColor}; border-right-color: ${loaderColor};`
184
+ : ''}
185
+ ></span>
186
+ {:else if icon && iconPosition === 'left'}
187
+ <Icon name={icon} color={iconColor || 'currentColor'} width={16} height={16} />
188
+ {/if}
189
+
190
+ {#if label}
191
+ <span class="btn-label">{label}</span>
192
+ {/if}
193
+
194
+ {#if !isLoading && icon && iconPosition === 'right'}
195
+ <Icon name={icon} color={iconColor || 'currentColor'} width={16} height={16} />
196
+ {/if}
197
+ </button>
198
+ {/if}