@djcali570/component-lib 0.1.94 → 0.1.96

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.
package/README.md CHANGED
@@ -1,65 +1,9 @@
1
- # Svelte library
1
+ # Svelte Component library
2
2
 
3
- Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
3
+ 0.1.95
4
4
 
5
- Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
5
+ - Updated dropdown so onUpdate runs when dropdown is cleared
6
6
 
7
- ## Creating a project
7
+ 0.1.96
8
8
 
9
- If you're seeing this, you've probably already done this step. Congrats!
10
-
11
- ```sh
12
- # create a new project in the current directory
13
- npx sv create
14
-
15
- # create a new project in my-app
16
- npx sv create my-app
17
- ```
18
-
19
- To recreate this project with the same configuration:
20
-
21
- ```sh
22
- # recreate this project
23
- pnpm dlx sv create --template library --types ts --add prettier eslint sveltekit-adapter="adapter:node" devtools-json --install pnpm component-lib-restored
24
- ```
25
-
26
- ## Developing
27
-
28
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
29
-
30
- ```sh
31
- npm run dev
32
-
33
- # or start the server and open the app in a new browser tab
34
- npm run dev -- --open
35
- ```
36
-
37
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
38
-
39
- ## Building
40
-
41
- To build your library:
42
-
43
- ```sh
44
- npm pack
45
- ```
46
-
47
- To create a production version of your showcase app:
48
-
49
- ```sh
50
- npm run build
51
- ```
52
-
53
- You can preview the production build with `npm run preview`.
54
-
55
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
56
-
57
- ## Publishing
58
-
59
- 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/)).
60
-
61
- To publish your library to [npm](https://www.npmjs.com):
62
-
63
- ```sh
64
- npm publish
65
- ```
9
+ - Fixed issue with dropdown and using derived state.
@@ -108,23 +108,37 @@
108
108
  );
109
109
  }
110
110
  function selectItem(item: DropDownItem) {
111
+ // Set all bound values
112
+ value = item.value;
111
113
  valueKey = item.id ?? '';
112
114
  extraValue = item.extraValue ?? '';
113
- value = item.value;
115
+
116
+ // Notify parent
114
117
  onUpdate(valueKey, value, extraValue);
118
+
119
+ // Close dropdown
115
120
  showDropdown = false;
116
121
  }
122
+
117
123
  function validateInput() {
118
- const matchedItem = dropdownItems.find((item) => {
119
- return item.value.toLowerCase() === value.toLowerCase(); // Add return statement
120
- });
121
- if (!matchedItem) {
122
- // Clear input if the entered value is not in the list
123
- value = '';
124
- } else if (value !== matchedItem.value) {
125
- // Set the inputText to the matched item's value if it's different
124
+ const matchedItem = dropdownItems.find(
125
+ (item) => item.value.toLowerCase() === value.toLowerCase()
126
+ );
127
+
128
+ if (matchedItem) {
129
+ // Valid match: sync values
126
130
  value = matchedItem.value;
131
+ valueKey = matchedItem.id ?? '';
132
+ extraValue = matchedItem.extraValue ?? '';
133
+ } else {
134
+ // No match: clear all
135
+ value = '';
136
+ valueKey = '';
137
+ extraValue = '';
127
138
  }
139
+
140
+ // Always notify parent of the current state
141
+ onUpdate(valueKey, value, extraValue);
128
142
  }
129
143
  </script>
130
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djcali570/component-lib",
3
- "version": "0.1.94",
3
+ "version": "0.1.96",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",