@flightlesslabs/dodo-ui 0.7.2 → 0.9.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 (138) hide show
  1. package/dist/index.d.ts +18 -2
  2. package/dist/index.js +11 -0
  3. package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte +126 -0
  4. package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte.d.ts +18 -0
  5. package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte +79 -0
  6. package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte.d.ts +21 -0
  7. package/dist/stories/components/Form/NumericInput/NumericInput.svelte +161 -0
  8. package/dist/stories/components/Form/NumericInput/NumericInput.svelte.d.ts +69 -0
  9. package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +84 -0
  10. package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte.d.ts +18 -0
  11. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +27 -6
  12. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +5 -3
  13. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +7 -1
  14. package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte +16 -1
  15. package/dist/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte +59 -0
  16. package/dist/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte.d.ts +18 -0
  17. package/dist/stories/components/Form/Select/Events/Events.stories.svelte +27 -0
  18. package/dist/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte +54 -0
  19. package/dist/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte.d.ts +18 -0
  20. package/dist/stories/components/Form/Select/Positions/Positions.stories.svelte +83 -0
  21. package/dist/stories/components/Form/Select/Positions/Positions.stories.svelte.d.ts +18 -0
  22. package/dist/stories/components/Form/Select/Select.svelte +110 -123
  23. package/dist/stories/components/Form/Select/Select.svelte.d.ts +22 -3
  24. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +27 -0
  25. package/dist/stories/components/Form/TextInput/TextInput.svelte +5 -3
  26. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +10 -1
  27. package/dist/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte +28 -0
  28. package/dist/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte.d.ts +18 -0
  29. package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte +51 -0
  30. package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte.d.ts +22 -0
  31. package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +129 -0
  32. package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte.d.ts +81 -0
  33. package/dist/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte +46 -0
  34. package/dist/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte.d.ts +18 -0
  35. package/dist/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte +27 -0
  36. package/dist/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte.d.ts +18 -0
  37. package/dist/stories/components/Layout/Menu/DynamicMenu/Options/OptionFormat.mdx +72 -0
  38. package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte.d.ts +1 -1
  39. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte +23 -4
  40. package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte.d.ts +13 -2
  41. package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +115 -0
  42. package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte.d.ts +18 -0
  43. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.d.ts +13 -0
  44. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.js +26 -0
  45. package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
  46. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
  47. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.d.ts +51 -0
  48. package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js +96 -0
  49. package/dist/stories/developer tools/helpers/logger/index.mdx +63 -0
  50. package/dist/stories/developer tools/helpers/logger/logger.d.ts +24 -0
  51. package/dist/stories/developer tools/helpers/logger/logger.js +31 -0
  52. package/package.json +15 -17
  53. package/src/lib/index.ts +33 -0
  54. package/src/lib/stories/Home.mdx +59 -0
  55. package/src/lib/stories/assets/dark-theme-toggle.png +0 -0
  56. package/src/lib/stories/components/Form/Button/Button.stories.svelte +61 -0
  57. package/src/lib/stories/components/Form/Button/Color/Color.stories.svelte +43 -0
  58. package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +36 -0
  59. package/src/lib/stories/components/Form/Button/IconButton/IconButton.stories.svelte +43 -0
  60. package/src/lib/stories/components/Form/Button/Roundness/Roundness.stories.svelte +23 -0
  61. package/src/lib/stories/components/Form/Button/Size/Size.stories.svelte +16 -0
  62. package/src/lib/stories/components/Form/Button/Variant/Variant.stories.svelte +18 -0
  63. package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +28 -0
  64. package/src/lib/stories/components/Form/Label/Label.stories.svelte +13 -0
  65. package/src/lib/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
  66. package/src/lib/stories/components/Form/Message/Message.stories.svelte +27 -0
  67. package/src/lib/stories/components/Form/Message/Size/Size.stories.svelte +22 -0
  68. package/src/lib/stories/components/Form/NumericInput/Events/Events.stories.svelte +134 -0
  69. package/src/lib/stories/components/Form/NumericInput/NumericInput.stories.svelte +84 -0
  70. package/src/lib/stories/components/Form/NumericInput/NumericInput.svelte +286 -0
  71. package/src/lib/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +87 -0
  72. package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +132 -0
  73. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +59 -0
  74. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +15 -3
  75. package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  76. package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  77. package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  78. package/src/lib/stories/components/Form/Select/Customize/Customize.stories.svelte +139 -0
  79. package/src/lib/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte +63 -0
  80. package/src/lib/stories/components/Form/Select/Events/Events.stories.svelte +174 -0
  81. package/src/lib/stories/components/Form/Select/Options/OptionFormat.mdx +40 -0
  82. package/src/lib/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte +58 -0
  83. package/src/lib/stories/components/Form/Select/Positions/Positions.stories.svelte +87 -0
  84. package/src/lib/stories/components/Form/Select/Roundness/Roundness.stories.svelte +32 -0
  85. package/src/lib/stories/components/Form/Select/Select.stories.svelte +121 -0
  86. package/src/lib/stories/components/Form/Select/Select.svelte +166 -146
  87. package/src/lib/stories/components/Form/Select/Size/Size.stories.svelte +28 -0
  88. package/src/lib/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte +43 -0
  89. package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +125 -0
  90. package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  91. package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  92. package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +43 -0
  93. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +18 -3
  94. package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  95. package/src/lib/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte +30 -0
  96. package/src/lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte +56 -0
  97. package/src/lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +262 -0
  98. package/src/lib/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte +48 -0
  99. package/src/lib/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte +29 -0
  100. package/src/lib/stories/components/Layout/Menu/DynamicMenu/Options/OptionFormat.mdx +72 -0
  101. package/src/lib/stories/components/Layout/Menu/Menu.stories.svelte +69 -0
  102. package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte +34 -0
  103. package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +1 -1
  104. package/src/lib/stories/components/Layout/Menu/MenuItem/Size/Size.stories.svelte +16 -0
  105. package/src/lib/stories/components/Layout/Menu/MenuItem/Type/Type.stories.svelte +21 -0
  106. package/src/lib/stories/components/Layout/Menu/Size/Size.stories.svelte +37 -0
  107. package/src/lib/stories/components/Layout/Paper/Color/Color.stories.svelte +63 -0
  108. package/src/lib/stories/components/Layout/Paper/Paper.stories.svelte +50 -0
  109. package/src/lib/stories/components/Layout/Paper/Roundness/Roundness.stories.svelte +25 -0
  110. package/src/lib/stories/components/Layout/Paper/Shadow/Shadow.stories.svelte +24 -0
  111. package/src/lib/stories/components/Layout/Separator/Color/Color.stories.svelte +19 -0
  112. package/src/lib/stories/components/Layout/Separator/Separator.stories.svelte +30 -0
  113. package/src/lib/stories/developer tools/Intro.mdx +9 -0
  114. package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.stories.svelte +53 -0
  115. package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte +43 -3
  116. package/src/lib/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +121 -0
  117. package/src/lib/stories/developer tools/components/DynamicInput/Size/Size.stories.svelte +17 -0
  118. package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +38 -0
  119. package/src/lib/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
  120. package/src/lib/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
  121. package/src/lib/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
  122. package/src/lib/stories/developer tools/components/Popper/Popper.stories.svelte +124 -0
  123. package/src/lib/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte +64 -0
  124. package/src/lib/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte +92 -0
  125. package/src/lib/stories/developer tools/components/Popper/Positions/Positions.stories.svelte +114 -0
  126. package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +25 -0
  127. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +30 -0
  128. package/src/lib/stories/developer tools/directives/clickOutside/index.mdx +25 -0
  129. package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.ts +27 -0
  130. package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
  131. package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
  132. package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.ts +156 -0
  133. package/src/lib/stories/developer tools/helpers/logger/index.mdx +63 -0
  134. package/src/lib/stories/developer tools/helpers/logger/logger.ts +46 -0
  135. package/src/lib/stories/developer tools/philosophy/Colors/Colors.mdx +43 -0
  136. package/src/lib/stories/developer tools/philosophy/Colors/Colors.stories.svelte +22 -0
  137. package/src/lib/stories/developer tools/philosophy/Colors/Opacity.stories.svelte +11 -0
  138. package/src/lib/stories/developer tools/philosophy/Themes.mdx +23 -0
@@ -0,0 +1,20 @@
1
+ import { Source } from '@storybook/blocks';
2
+
3
+ # cleanNumericString
4
+
5
+ Cleans the input string by removing all characters except numeric digits (0-9) and a single decimal point.
6
+ Only the first decimal point is retained; all subsequent dots are removed.
7
+
8
+ ---
9
+
10
+ ## Basic Usage
11
+
12
+ <Source
13
+ dark
14
+ language="ts"
15
+ code={`
16
+ import { cleanNumericString } from '@flightlesslabs/dodo-ui';
17
+
18
+ const result = cleanNumericString("abc123.45.67def"); // result === "123.4567"
19
+ `}
20
+ />
@@ -0,0 +1,71 @@
1
+ import { Source } from '@storybook/blocks';
2
+
3
+ # isValidNumberValue
4
+
5
+ Utility function to validate whether a string is a valid number based on customizable settings including minimum, maximum, decimal places, and allowance of negative numbers.
6
+
7
+ ---
8
+
9
+ ## Basic Usage
10
+
11
+ Validates a string as a number with default settings (no decimals allowed, no negatives allowed, strict checking):
12
+
13
+ <Source
14
+ dark
15
+ language="ts"
16
+ code={`
17
+ import { isValidNumberValue } from '@flightlesslabs/dodo-ui';
18
+
19
+ const result = isValidNumberValue("123");
20
+ console.log(result); // true
21
+ `}
22
+ />
23
+
24
+ ---
25
+
26
+ ## With Settings
27
+
28
+ Customize validation rules:
29
+
30
+ - `min` — minimum allowed value (inclusive)
31
+ - `max` — maximum allowed value (inclusive)
32
+ - `allowNegativeValues` — whether negatives are allowed
33
+ - `decimalPlaces` — max decimal places allowed
34
+ - `log` — enable detailed logging
35
+ - `strict` — Strict checking, Full text - keep it enabled, Partial text - keep it disabled
36
+
37
+ <Source
38
+ dark
39
+ language="ts"
40
+ code={`
41
+ import { isValidNumberValue } from '@flightlesslabs/dodo-ui';
42
+
43
+ const result1 = isValidNumberValue("123.456", { decimalPlaces: 3, log: true });
44
+ const result2 = isValidNumberValue("-50", { allowNegativeValues: true, min: -100 });
45
+ const result3 = isValidNumberValue("200", { max: 150 });
46
+
47
+ const result4 = isValidNumberValue("-", { allowNegativeValues: true });
48
+ const result5 = isValidNumberValue("-", { allowNegativeValues: true, strict: false });
49
+
50
+ console.log(result1); // true
51
+ console.log(result2); // true
52
+ console.log(result3); // false (exceeds max)
53
+ console.log(result4); // false (fails in strict check)
54
+ console.log(result5); // true (pass in strict check)
55
+ `}
56
+ />
57
+
58
+ ---
59
+
60
+ ## Type Definition
61
+
62
+ ```ts
63
+ export type IsValidNumberValueSettings = {
64
+ min?: number;
65
+ max?: number;
66
+ allowNegativeValues?: boolean;
67
+ decimalPlaces?: number;
68
+ log?: boolean;
69
+ strict?: boolean;
70
+ };
71
+ ```
@@ -0,0 +1,51 @@
1
+ export type IsValidNumberValueSettings = {
2
+ /**
3
+ * Minimum allowed numeric value (inclusive).
4
+ */
5
+ min?: number;
6
+ /**
7
+ * Maximum allowed numeric value (inclusive).
8
+ */
9
+ max?: number;
10
+ /**
11
+ * Whether negative numbers are allowed.
12
+ * Defaults to false.
13
+ */
14
+ allowNegativeValues?: boolean;
15
+ /**
16
+ * Maximum allowed decimal places.
17
+ * Defaults to 0 (no decimals allowed).
18
+ */
19
+ decimalPlaces?: number;
20
+ /**
21
+ * Whether to enable logging.
22
+ * Defaults to false.
23
+ */
24
+ log?: boolean;
25
+ /**
26
+ * Strict checking, Full text - keep it enabled, Partial text - keep it disabled
27
+ * Defaults to true.
28
+ */
29
+ strict?: boolean;
30
+ };
31
+ /**
32
+ * Validates whether a string represents a valid number based on provided settings.
33
+ *
34
+ * @param value - The string to validate as a number.
35
+ * @param settings - Optional validation settings.
36
+ * @param settings.min - Minimum allowed value (inclusive).
37
+ * @param settings.max - Maximum allowed value (inclusive).
38
+ * @param settings.allowNegativeValues - Whether negative numbers are allowed.
39
+ * @param settings.decimalPlaces - Maximum allowed decimal places.
40
+ * @param settings.log - Whether to enable detailed logging.
41
+ * @param settings.strict - Whether to enable Strict checking, Full text - keep it enabled, Partial text - keep it disabled
42
+ *
43
+ * @returns True if the value is a valid number according to the settings; otherwise false.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * isValidNumberValue("123.45", { decimalPlaces: 2, log: true });
48
+ * isValidNumberValue("-50", { allowNegativeValues: true, min: -100 });
49
+ * ```
50
+ */
51
+ export default function isValidNumberValue(value: string, settings?: IsValidNumberValueSettings): boolean;
@@ -0,0 +1,96 @@
1
+ import createLogger from '../../logger/logger.js';
2
+ /**
3
+ * Checks if the input string is a valid numeric string.
4
+ * Allows integers, decimals, negative numbers, and scientific notation.
5
+ *
6
+ * @param str - Input string to validate.
7
+ * @returns True if string is numeric, false otherwise.
8
+ */
9
+ function isNumericString(str) {
10
+ if (typeof str !== 'string')
11
+ return false;
12
+ const trimmed = str.trim();
13
+ if (trimmed === '')
14
+ return false;
15
+ const num = Number(trimmed);
16
+ return !isNaN(num) && isFinite(num);
17
+ }
18
+ /**
19
+ * Validates whether a string represents a valid number based on provided settings.
20
+ *
21
+ * @param value - The string to validate as a number.
22
+ * @param settings - Optional validation settings.
23
+ * @param settings.min - Minimum allowed value (inclusive).
24
+ * @param settings.max - Maximum allowed value (inclusive).
25
+ * @param settings.allowNegativeValues - Whether negative numbers are allowed.
26
+ * @param settings.decimalPlaces - Maximum allowed decimal places.
27
+ * @param settings.log - Whether to enable detailed logging.
28
+ * @param settings.strict - Whether to enable Strict checking, Full text - keep it enabled, Partial text - keep it disabled
29
+ *
30
+ * @returns True if the value is a valid number according to the settings; otherwise false.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * isValidNumberValue("123.45", { decimalPlaces: 2, log: true });
35
+ * isValidNumberValue("-50", { allowNegativeValues: true, min: -100 });
36
+ * ```
37
+ */
38
+ export default function isValidNumberValue(value, settings) {
39
+ const allowNegativeValues = settings?.allowNegativeValues || false;
40
+ const decimalPlaces = settings?.decimalPlaces || 0;
41
+ const valueFormatted = value.trim();
42
+ const log = settings?.log || false;
43
+ const logger = createLogger({
44
+ label: 'isValidNumberValue',
45
+ show: log,
46
+ });
47
+ const min = settings?.min;
48
+ const max = settings?.max;
49
+ const strict = settings?.strict === false ? false : true;
50
+ logger.info(`Validating value: "${valueFormatted}"`);
51
+ if (strict && !isNumericString(valueFormatted)) {
52
+ logger.warn('Invalid input: strict checking is enaabled and the text failed the checks');
53
+ return false;
54
+ }
55
+ if (valueFormatted === '') {
56
+ logger.info('Valid input: Blank value');
57
+ return true;
58
+ }
59
+ if (allowNegativeValues && valueFormatted === '-') {
60
+ logger.info(`Valid input: Single '-' sign allowed as a negative placeholder.`);
61
+ return true;
62
+ }
63
+ if (!decimalPlaces && valueFormatted.includes('.')) {
64
+ logger.warn('Invalid input: Decimals not allowed');
65
+ return false;
66
+ }
67
+ const dotCount = (valueFormatted.match(/\./g) || []).length;
68
+ if (dotCount > 1) {
69
+ logger.warn('Invalid input: More than one decimal point detected.');
70
+ return false;
71
+ }
72
+ const parts = valueFormatted.split('.');
73
+ if (parts[1]?.length > decimalPlaces) {
74
+ logger.warn(`Invalid input: Number has ${parts[1].length} decimal places, exceeding the allowed limit of ${decimalPlaces}.`);
75
+ return false;
76
+ }
77
+ if (!isNumericString(valueFormatted)) {
78
+ logger.warn('Invalid input: String is not a valid number.');
79
+ return false;
80
+ }
81
+ const numericValue = Number(valueFormatted);
82
+ if (!allowNegativeValues && numericValue < 0) {
83
+ logger.warn('Invalid input: Negative numbers are not allowed.');
84
+ return false;
85
+ }
86
+ if (min !== undefined && numericValue < min) {
87
+ logger.warn(`Invalid input: Number ${numericValue} is less than the minimum allowed value of ${min}.`);
88
+ return false;
89
+ }
90
+ if (max !== undefined && numericValue > max) {
91
+ logger.warn(`Invalid input: Number ${numericValue} exceeds the maximum allowed value of ${max}.`);
92
+ return false;
93
+ }
94
+ logger.info('Validation passed: Input is a valid number according to the provided settings.');
95
+ return true;
96
+ }
@@ -0,0 +1,63 @@
1
+ import { Source } from '@storybook/blocks';
2
+
3
+ # Logger Utility
4
+
5
+ A customizable logger function that supports:
6
+
7
+ - Log levels (`info`, `warn`, `error`)
8
+ - Optional labels
9
+ - A `show` flag to toggle logging
10
+ - Console output with timestamps
11
+
12
+ ## Import
13
+
14
+ Import the logger creation function:
15
+
16
+ <Source dark language="ts" code={`import { createLogger } from '@flightlesslabs/dodo-ui';`} />
17
+
18
+ ## Basic Usage
19
+
20
+ Create a logger and log different types of messages:
21
+
22
+ <Source
23
+ dark
24
+ language="ts"
25
+ code={`const logger = createLogger({
26
+ label: 'AuthService',
27
+ });
28
+
29
+ logger.info('User logged in');
30
+ logger.warn('Token is about to expire');
31
+ logger.error('Login failed', new Error('Invalid credentials'));
32
+ `}
33
+ />
34
+
35
+ ## Disable Logging
36
+
37
+ You can use the \`show\` flag to completely silence the logger (e.g., in production):
38
+
39
+ <Source
40
+ dark
41
+ language="ts"
42
+ code={`const logger = createLogger({
43
+ show: false,
44
+ });
45
+
46
+ logger.info('This will not be logged');
47
+ `}
48
+ />
49
+
50
+ ## Level Filtering
51
+
52
+ The logger will only show messages **at or above** the configured `level`:
53
+
54
+ <Source
55
+ dark
56
+ language="ts"
57
+ code={`const logger = createLogger();
58
+
59
+ logger.info('This will NOT show');
60
+ logger.warn('This WILL show');
61
+ logger.error('This WILL show');
62
+ `}
63
+ />
@@ -0,0 +1,24 @@
1
+ export type LogLevel = 'info' | 'warn' | 'error';
2
+ export interface LoggerOptions {
3
+ /**
4
+ * Optional label to prefix log entries.
5
+ */
6
+ label?: string;
7
+ /**
8
+ * Whether to actually show logs.
9
+ * Defaults to true.
10
+ */
11
+ show?: boolean;
12
+ }
13
+ /**
14
+ * Formats the log message with timestamp, label, and level.
15
+ */
16
+ export declare function formatPrefix(level: LogLevel, label?: string): string;
17
+ /**
18
+ * Creates a logger that logs every call unless disabled by show=false.
19
+ */
20
+ export default function createLogger(options?: LoggerOptions): {
21
+ info: (msg: unknown, ...optionalParams: unknown[]) => void;
22
+ warn: (msg: unknown, ...optionalParams: unknown[]) => void;
23
+ error: (msg: unknown, ...optionalParams: unknown[]) => void;
24
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Formats the log message with timestamp, label, and level.
3
+ */
4
+ export function formatPrefix(level, label) {
5
+ const timestamp = new Date().toISOString();
6
+ const labelPart = label ? `[${label}]` : '';
7
+ return `[${timestamp}] ${labelPart} [${level.toUpperCase()}]`;
8
+ }
9
+ /**
10
+ * Creates a logger that logs every call unless disabled by show=false.
11
+ */
12
+ export default function createLogger(options = {}) {
13
+ const { label, show = true } = options;
14
+ function shouldLog() {
15
+ return show;
16
+ }
17
+ return {
18
+ info: (msg, ...optionalParams) => {
19
+ if (shouldLog())
20
+ console.info(formatPrefix('info', label), msg, ...optionalParams);
21
+ },
22
+ warn: (msg, ...optionalParams) => {
23
+ if (shouldLog())
24
+ console.warn(formatPrefix('warn', label), msg, ...optionalParams);
25
+ },
26
+ error: (msg, ...optionalParams) => {
27
+ if (shouldLog())
28
+ console.error(formatPrefix('error', label), msg, ...optionalParams);
29
+ },
30
+ };
31
+ }
package/package.json CHANGED
@@ -1,19 +1,6 @@
1
1
  {
2
2
  "name": "@flightlesslabs/dodo-ui",
3
- "version": "0.7.2",
4
- "scripts": {
5
- "build": "vite build && pnpm run prepack",
6
- "preview": "vite preview",
7
- "prepare": "svelte-kit sync || echo ''",
8
- "prepack": "svelte-kit sync && svelte-package && publint",
9
- "svelte-check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10
- "format": "prettier --write .",
11
- "lint": "prettier --check . && eslint .",
12
- "dev": "storybook dev -p 6006",
13
- "build-storybook": "storybook build && touch ./storybook-static/.nojekyll",
14
- "check": "pnpm run svelte-check && eslint . && pnpm run lint",
15
- "check:fix": "pnpm run svelte-check && eslint . && pnpm run format"
16
- },
3
+ "version": "0.9.0",
17
4
  "homepage": "https://flightlesslabs.github.io/dodo-ui",
18
5
  "repository": {
19
6
  "type": "git",
@@ -70,7 +57,7 @@
70
57
  "eslint": "^9.27.0",
71
58
  "eslint-config-prettier": "^10.1.5",
72
59
  "eslint-plugin-svelte": "^3.9.0",
73
- "globals": "^16.1.0",
60
+ "globals": "^16.2.0",
74
61
  "playwright": "^1.52.0",
75
62
  "prettier": "^3.5.3",
76
63
  "prettier-plugin-svelte": "^3.4.0",
@@ -78,7 +65,7 @@
78
65
  "sass": "^1.89.0",
79
66
  "storybook": "^8.6.14",
80
67
  "storybook-dark-mode": "^4.0.2",
81
- "svelte": "^5.32.1",
68
+ "svelte": "^5.33.2",
82
69
  "svelte-check": "^4.2.1",
83
70
  "svelte-preprocess": "^6.0.3",
84
71
  "typescript": "^5.8.3",
@@ -95,5 +82,16 @@
95
82
  },
96
83
  "dependencies": {
97
84
  "@iconify/svelte": "^5.0.0"
85
+ },
86
+ "scripts": {
87
+ "build": "vite build && pnpm run prepack",
88
+ "preview": "vite preview",
89
+ "svelte-check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
90
+ "format": "prettier --write .",
91
+ "lint": "prettier --check . && eslint .",
92
+ "dev": "storybook dev -p 6006",
93
+ "build-storybook": "storybook build && touch ./storybook-static/.nojekyll",
94
+ "check": "pnpm run svelte-check && eslint . && pnpm run lint",
95
+ "check:fix": "pnpm run svelte-check && eslint . && pnpm run format"
98
96
  }
99
- }
97
+ }
package/src/lib/index.ts CHANGED
@@ -14,6 +14,20 @@ export type { ComponentWeight } from './types/weight.js';
14
14
 
15
15
  export type { PositionY, PositionX } from './types/position.js';
16
16
 
17
+ /** developer tools: helpers: logger */
18
+ export { default as createLogger } from '$lib/stories/developer tools/helpers/logger/logger.js';
19
+ export type {
20
+ LogLevel,
21
+ LoggerOptions,
22
+ } from '$lib/stories/developer tools/helpers/logger/logger.js';
23
+
24
+ /** developer tools: helpers: Numbers: isValidNumberValue */
25
+ export { default as isValidNumberValue } from '$lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js';
26
+ export type { IsValidNumberValueSettings } from '$lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js';
27
+
28
+ /** developer tools: helpers: Numbers: cleanNumericString */
29
+ export { default as cleanNumericString } from '$lib/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.js';
30
+
17
31
  /** developer tools: directives: clickOutside */
18
32
  export { clickOutside } from '$lib/stories/developer tools/directives/clickOutside/clickOutside.js';
19
33
 
@@ -32,6 +46,7 @@ export type {
32
46
  DynamicInputProps,
33
47
  DynamicInputClickEvent,
34
48
  DynamicInputFocusEvent,
49
+ DynamicInputKeyboardEvent,
35
50
  } from '$lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte';
36
51
 
37
52
  /** developer tools: components: Popper */
@@ -57,6 +72,7 @@ export type {
57
72
  TextInputFocusEvent,
58
73
  TextInputClipboardEvent,
59
74
  TextInputInputEvent,
75
+ TextInputKeyboardEvent,
60
76
  TextInputProps,
61
77
  } from '$lib/stories/components/Form/TextInput/TextInput.svelte';
62
78
 
@@ -79,6 +95,18 @@ export type { FormControlProps } from '$lib/stories/components/Form/FormControl/
79
95
  export { default as Message } from '$lib/stories/components/Form/Message/Message.svelte';
80
96
  export type { MessageProps } from '$lib/stories/components/Form/Message/Message.svelte';
81
97
 
98
+ /** Form: Select */
99
+ export { default as Select } from '$lib/stories/components/Form/Select/Select.svelte';
100
+ export type {
101
+ SelectOption,
102
+ SelectDropdownArrowPosition,
103
+ SelectProps,
104
+ } from '$lib/stories/components/Form/Select/Select.svelte';
105
+
106
+ /** Form: NumericInput */
107
+ export { default as NumericInput } from '$lib/stories/components/Form/NumericInput/NumericInput.svelte';
108
+ export type { NumericInputProps } from '$lib/stories/components/Form/NumericInput/NumericInput.svelte';
109
+
82
110
  /** Layout: Paper */
83
111
  export { default as Paper } from '$lib/stories/components/Layout/Paper/Paper.svelte';
84
112
  export type { PaperColor, PaperProps } from '$lib/stories/components/Layout/Paper/Paper.svelte';
@@ -98,3 +126,8 @@ export type {
98
126
  MenuItemType,
99
127
  MenuItemProps,
100
128
  } from '$lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte';
129
+ export { default as DynamicMenu } from '$lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte';
130
+ export type {
131
+ DynamicMenuItemOption,
132
+ DynamicMenuProps,
133
+ } from '$lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte';
@@ -0,0 +1,59 @@
1
+ import { Source } from '@storybook/blocks';
2
+ import item from '../../../package.json?raw';
3
+
4
+ <main style={{ textAlign: 'center' }}>
5
+
6
+ <img src="dodo-circle-6.png" style={{ width: 200, height: 'auto' }} />
7
+
8
+ # Dodo UI
9
+
10
+ <h3 style={{ fontWeight: 500 }}>v{JSON.parse(item)?.version}</h3>
11
+
12
+ <h3 style={{ fontWeight: 400 }}>An open-source, opinionated UI framework for Svelte.</h3>
13
+
14
+ ### [Github](https://github.com/flightlesslabs/dodo-ui) - [npm](https://www.npmjs.com/package/@flightlesslabs/dodo-ui)
15
+
16
+ </main>
17
+
18
+ <br />
19
+ <br />
20
+
21
+ ## Install
22
+
23
+ pnpm
24
+
25
+ <Source
26
+ dark
27
+ language="bash"
28
+ code={`
29
+ pnpm add @flightlesslabs/dodo-ui
30
+ `}
31
+ />
32
+
33
+ npm
34
+
35
+ <Source
36
+ dark
37
+ language="bash"
38
+ code={`
39
+ npm i @flightlesslabs/dodo-ui
40
+ `}
41
+ />
42
+
43
+ ## Use it!
44
+
45
+ Lets import [Button](?path=/docs/components-form-button--docs) component. Checkout documentation for [Button](?path=/docs/components-form-button--docs)
46
+
47
+ <Source
48
+ dark
49
+ language="js"
50
+ code={`
51
+ import { Button } '@flightlesslabs/dodo-ui';
52
+ `}
53
+ />
54
+
55
+ ## Explore more
56
+
57
+ - [Dark Theme](?path=/docs/developer-tools-philosophy-themes--docs#dark-theme)
58
+ - [Colors](?path=/docs/developer-tools-philosophy-colors--docs)
59
+ - [Adjust Color Opacity](?path=/docs/developer-tools-philosophy-colors--docs#adjusting-opacity)
@@ -0,0 +1,61 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Button, { buttonTypeArray } from './Button.svelte';
4
+ import type { StoryBookArgTypes } from '$lib/storybook-types.js';
5
+ import { componentRoundnessArray } from '$lib/types/roundness.js';
6
+ import { componentColorArray } from '$lib/types/colors.js';
7
+ import { componentWeightArray } from '$lib/types/weight.js';
8
+ import { componentSizeArray } from '$lib/types/size.js';
9
+
10
+ export const storyButtonArgTypes: StoryBookArgTypes = {
11
+ type: {
12
+ control: { type: 'select' },
13
+ options: buttonTypeArray,
14
+ },
15
+ color: {
16
+ control: { type: 'select' },
17
+ options: componentColorArray,
18
+ },
19
+ variant: {
20
+ control: { type: 'select' },
21
+ options: componentWeightArray,
22
+ },
23
+ roundness: {
24
+ control: { type: 'select' },
25
+ options: componentRoundnessArray,
26
+ },
27
+ size: {
28
+ control: { type: 'select' },
29
+ options: componentSizeArray,
30
+ },
31
+ };
32
+
33
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
34
+ const { Story } = defineMeta({
35
+ component: Button,
36
+ tags: ['autodocs'],
37
+ argTypes: storyButtonArgTypes,
38
+ });
39
+ </script>
40
+
41
+ <!-- Button with default style -->
42
+ <Story name="Primary">Click me!</Story>
43
+
44
+ <!-- Button with border around it -->
45
+ <Story name="Outline" args={{ outline: true, variant: 'text' }}>Click me!</Story>
46
+
47
+ <Story name="Disabled" args={{ disabled: true }}>Click me!</Story>
48
+
49
+ <!-- Form submit button -->
50
+ <Story name="Sumbit Button" args={{ type: 'submit' }}>Submit Form</Story>
51
+
52
+ <!-- Form submit button -->
53
+ <Story name="Full width Button" args={{ fullWidth: true }}>Click me!</Story>
54
+
55
+ <!-- Anchor Link styled like a Button -->
56
+ <Story
57
+ name="Link Button"
58
+ args={{ href: 'https://www.w3schools.com/tags/tag_a.asp', target: '_blank' }}
59
+ >
60
+ Link
61
+ </Story>
@@ -0,0 +1,43 @@
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Button from '../Button.svelte';
4
+ import { storyButtonArgTypes } from '../Button.stories.svelte';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
+ const { Story } = defineMeta({
8
+ component: Button,
9
+ tags: ['autodocs'],
10
+ argTypes: storyButtonArgTypes,
11
+ });
12
+ </script>
13
+
14
+ <Story name="Primary">Click me!</Story>
15
+ <Story name="Secondary" args={{ color: 'secondary' }}>Click me!</Story>
16
+ <Story name="Neutral" args={{ color: 'neutral' }}>Click me!</Story>
17
+ <Story name="Safe" args={{ color: 'safe' }}>Click me!</Story>
18
+ <Story name="Warning" args={{ color: 'warning' }}>Click me!</Story>
19
+ <Story name="Danger" args={{ color: 'danger' }}>Click me!</Story>
20
+
21
+ <Story name="Primary Text" args={{ color: 'primary', variant: 'text' }}>Click me!</Story>
22
+ <Story name="Secondary Text" args={{ color: 'secondary', variant: 'text' }}>Click me!</Story>
23
+ <Story name="Neutral Text" args={{ color: 'neutral', variant: 'text' }}>Click me!</Story>
24
+ <Story name="Safe Text" args={{ color: 'safe', variant: 'text' }}>Click me!</Story>
25
+ <Story name="Warning Text" args={{ color: 'warning', variant: 'text' }}>Click me!</Story>
26
+ <Story name="Danger Text" args={{ color: 'danger', variant: 'text' }}>Click me!</Story>
27
+
28
+ <Story name="Primary Outline" args={{ variant: 'text', outline: true }}>Click me!</Story>
29
+ <Story name="Secondary Outline" args={{ color: 'secondary', variant: 'text', outline: true }}>
30
+ Click me!
31
+ </Story>
32
+ <Story name="Neutral Outline" args={{ color: 'neutral', variant: 'text', outline: true }}>
33
+ Click me!
34
+ </Story>
35
+ <Story name="Safe Outline" args={{ color: 'safe', variant: 'text', outline: true }}>
36
+ Click me!
37
+ </Story>
38
+ <Story name="Warning Outline" args={{ color: 'warning', variant: 'text', outline: true }}>
39
+ Click me!
40
+ </Story>
41
+ <Story name="Danger Outline" args={{ color: 'danger', variant: 'text', outline: true }}>
42
+ Click me!
43
+ </Story>