freemium-ui 2.0.119 → 2.0.121
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/.github/workflows/automated-version-bump.yml +280 -0
- package/lib/index.cjs.js +34 -22
- package/lib/index.js +34 -22
- package/lib/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
name: Automated Version Bump and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version_type:
|
|
7
|
+
description: 'Version bump type'
|
|
8
|
+
required: true
|
|
9
|
+
default: 'patch'
|
|
10
|
+
type: choice
|
|
11
|
+
options:
|
|
12
|
+
- patch
|
|
13
|
+
- minor
|
|
14
|
+
- major
|
|
15
|
+
push:
|
|
16
|
+
branches:
|
|
17
|
+
- main
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
pull-requests: write
|
|
22
|
+
packages: write
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
create-version-pr:
|
|
26
|
+
name: Create Version Bump PR
|
|
27
|
+
runs-on: fw-shared
|
|
28
|
+
if: github.event_name == 'workflow_dispatch'
|
|
29
|
+
|
|
30
|
+
steps:
|
|
31
|
+
- name: Checkout code
|
|
32
|
+
uses: actions/checkout@v4
|
|
33
|
+
with:
|
|
34
|
+
fetch-depth: 0
|
|
35
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
36
|
+
persist-credentials: true
|
|
37
|
+
|
|
38
|
+
- name: Setup Node.js
|
|
39
|
+
uses: actions/setup-node@v4
|
|
40
|
+
with:
|
|
41
|
+
node-version: '18'
|
|
42
|
+
registry-url: 'https://registry.npmjs.org'
|
|
43
|
+
cache: 'npm'
|
|
44
|
+
|
|
45
|
+
- name: Configure Git
|
|
46
|
+
run: |
|
|
47
|
+
git config --local user.email "survey-serv-ci@users.noreply.github.com"
|
|
48
|
+
git config --local user.name "Survey Serv Release Bot"
|
|
49
|
+
git config --local url."https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
|
|
50
|
+
|
|
51
|
+
- name: Get current version
|
|
52
|
+
id: current_version
|
|
53
|
+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
|
54
|
+
|
|
55
|
+
- name: Create feature branch
|
|
56
|
+
id: branch
|
|
57
|
+
run: |
|
|
58
|
+
BRANCH_NAME="version-bump-$(date +'%Y%m%d-%H%M%S')"
|
|
59
|
+
git checkout -b $BRANCH_NAME
|
|
60
|
+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
|
61
|
+
|
|
62
|
+
- name: Bump version
|
|
63
|
+
id: version_bump
|
|
64
|
+
run: |
|
|
65
|
+
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
|
|
66
|
+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
67
|
+
echo "Bumped version from ${{ steps.current_version.outputs.version }} to $NEW_VERSION"
|
|
68
|
+
|
|
69
|
+
- name: Generate changes summary
|
|
70
|
+
id: changes
|
|
71
|
+
run: |
|
|
72
|
+
# Get commits since last tag for release notes
|
|
73
|
+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
74
|
+
if [ -z "$LAST_TAG" ]; then
|
|
75
|
+
CHANGES=$(git log --pretty=format:"- [%s](https://github.com/${{ github.repository }}/commit/%H)" --no-merges | head -10)
|
|
76
|
+
RELEASE_TYPE="Initial Release"
|
|
77
|
+
else
|
|
78
|
+
CHANGES=$(git log $LAST_TAG..HEAD --pretty=format:"- [%s](https://github.com/${{ github.repository }}/commit/%H)" --no-merges | head -10)
|
|
79
|
+
RELEASE_TYPE="Update"
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
echo "changes<<EOF" >> $GITHUB_OUTPUT
|
|
83
|
+
echo "$CHANGES" >> $GITHUB_OUTPUT
|
|
84
|
+
echo "EOF" >> $GITHUB_OUTPUT
|
|
85
|
+
|
|
86
|
+
echo "release_type<<EOF" >> $GITHUB_OUTPUT
|
|
87
|
+
echo "$RELEASE_TYPE" >> $GITHUB_OUTPUT
|
|
88
|
+
echo "EOF" >> $GITHUB_OUTPUT
|
|
89
|
+
|
|
90
|
+
- name: Commit version bump
|
|
91
|
+
run: |
|
|
92
|
+
git add package.json package-lock.json
|
|
93
|
+
git commit -m "chore: bump version to ${{ steps.version_bump.outputs.new_version }}
|
|
94
|
+
|
|
95
|
+
Version: ${{ steps.current_version.outputs.version }} → ${{ steps.version_bump.outputs.new_version }}
|
|
96
|
+
Type: ${{ github.event.inputs.version_type }}
|
|
97
|
+
|
|
98
|
+
Ready for automated publish after merge"
|
|
99
|
+
|
|
100
|
+
- name: Push feature branch
|
|
101
|
+
run: git push origin ${{ steps.branch.outputs.branch_name }}
|
|
102
|
+
|
|
103
|
+
- name: Create Pull Request
|
|
104
|
+
run: |
|
|
105
|
+
PR_URL=$(gh pr create \
|
|
106
|
+
--title "chore(release): bump version to ${{ steps.version_bump.outputs.new_version }}" \
|
|
107
|
+
--body "## Automated Version Bump: ${{ steps.version_bump.outputs.new_version }}
|
|
108
|
+
|
|
109
|
+
**Initiated by:** @${{ github.actor }}
|
|
110
|
+
**Workflow run:** [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
111
|
+
**Trigger:** Manual workflow dispatch
|
|
112
|
+
|
|
113
|
+
### Changes:
|
|
114
|
+
- **Version**: ${{ steps.current_version.outputs.version }} → ${{ steps.version_bump.outputs.new_version }}
|
|
115
|
+
- **Type**: ${{ github.event.inputs.version_type }}
|
|
116
|
+
|
|
117
|
+
### Recent commits:
|
|
118
|
+
${{ steps.changes.outputs.changes }}
|
|
119
|
+
|
|
120
|
+
### After Merge - Automatic Actions:
|
|
121
|
+
- npm package published
|
|
122
|
+
- Git tag created
|
|
123
|
+
- GitHub release created
|
|
124
|
+
|
|
125
|
+
**Merge this PR to trigger automated publishing!**" \
|
|
126
|
+
--head ${{ steps.branch.outputs.branch_name }} \
|
|
127
|
+
--base main)
|
|
128
|
+
|
|
129
|
+
echo "Pull request created: $PR_URL"
|
|
130
|
+
echo "Review and merge to complete: $PR_URL"
|
|
131
|
+
env:
|
|
132
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
133
|
+
|
|
134
|
+
publish-after-merge:
|
|
135
|
+
name: Publish After PR Merge
|
|
136
|
+
runs-on: fw-shared
|
|
137
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
138
|
+
|
|
139
|
+
steps:
|
|
140
|
+
- name: Checkout code
|
|
141
|
+
uses: actions/checkout@v4
|
|
142
|
+
with:
|
|
143
|
+
fetch-depth: 0
|
|
144
|
+
|
|
145
|
+
- name: Setup Node.js
|
|
146
|
+
uses: actions/setup-node@v4
|
|
147
|
+
with:
|
|
148
|
+
node-version: '18'
|
|
149
|
+
registry-url: 'https://registry.npmjs.org'
|
|
150
|
+
cache: 'npm'
|
|
151
|
+
|
|
152
|
+
- name: Check if this is a version bump commit
|
|
153
|
+
id: check_version
|
|
154
|
+
run: |
|
|
155
|
+
COMMIT_MSG=$(git log -1 --pretty=%s)
|
|
156
|
+
echo "Latest commit message: $COMMIT_MSG"
|
|
157
|
+
|
|
158
|
+
# Check commit message patterns (including merge commit messages)
|
|
159
|
+
COMMIT_MATCH=false
|
|
160
|
+
if echo "$COMMIT_MSG" | grep -q "chore: bump version to\|chore(release): bump version to\|Version Bump to\|bump version"; then
|
|
161
|
+
COMMIT_MATCH=true
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Check the PR branch pattern in merge commit
|
|
165
|
+
PR_BRANCH_MATCH=false
|
|
166
|
+
if echo "$COMMIT_MSG" | grep -q "version-bump-[0-9]"; then
|
|
167
|
+
PR_BRANCH_MATCH=true
|
|
168
|
+
echo "Version bump branch pattern detected in merge"
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
echo "Commit message match: $COMMIT_MATCH"
|
|
172
|
+
echo "PR branch match: $PR_BRANCH_MATCH"
|
|
173
|
+
|
|
174
|
+
if [ "$COMMIT_MATCH" = true ] || [ "$PR_BRANCH_MATCH" = true ]; then
|
|
175
|
+
echo "is_version_bump=true" >> $GITHUB_OUTPUT
|
|
176
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
177
|
+
echo "version=v$VERSION" >> $GITHUB_OUTPUT
|
|
178
|
+
echo "✅ Version bump detected: $VERSION"
|
|
179
|
+
echo "Reason: Commit=$COMMIT_MATCH, Branch=$PR_BRANCH_MATCH"
|
|
180
|
+
else
|
|
181
|
+
echo "is_version_bump=false" >> $GITHUB_OUTPUT
|
|
182
|
+
echo "❌ Not a version bump commit, skipping publish"
|
|
183
|
+
echo "Commit message: $COMMIT_MSG"
|
|
184
|
+
echo "No version bump indicators found"
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
- name: Install dependencies and build
|
|
188
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
189
|
+
run: |
|
|
190
|
+
npm ci
|
|
191
|
+
npm run build
|
|
192
|
+
|
|
193
|
+
- name: Publish to npm
|
|
194
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
195
|
+
run: |
|
|
196
|
+
echo "Publishing to npm..."
|
|
197
|
+
npm publish
|
|
198
|
+
echo "Successfully published to npm!"
|
|
199
|
+
env:
|
|
200
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
201
|
+
|
|
202
|
+
- name: Create Git tag
|
|
203
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
204
|
+
run: |
|
|
205
|
+
git config --local user.email "survey-serv-ci@users.noreply.github.com"
|
|
206
|
+
git config --local user.name "Survey Serv Release Bot"
|
|
207
|
+
git tag ${{ steps.check_version.outputs.version }}
|
|
208
|
+
git push origin ${{ steps.check_version.outputs.version }}
|
|
209
|
+
echo "Git tag created and pushed!"
|
|
210
|
+
|
|
211
|
+
- name: Cleanup version bump branch
|
|
212
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
213
|
+
run: |
|
|
214
|
+
# Extract branch name from merge commit message
|
|
215
|
+
COMMIT_MSG=$(git log -1 --pretty=%s)
|
|
216
|
+
echo "Commit message: $COMMIT_MSG"
|
|
217
|
+
|
|
218
|
+
# Extract branch name (e.g., version-bump-20250810-084452)
|
|
219
|
+
BRANCH_NAME=$(echo "$COMMIT_MSG" | grep -o 'version-bump-[0-9]\{8\}-[0-9]\{6\}' | head -1)
|
|
220
|
+
|
|
221
|
+
if [ -n "$BRANCH_NAME" ]; then
|
|
222
|
+
echo "Attempting to delete branch: $BRANCH_NAME"
|
|
223
|
+
|
|
224
|
+
# Delete the remote branch
|
|
225
|
+
if git push origin --delete "$BRANCH_NAME" 2>/dev/null; then
|
|
226
|
+
echo "✅ Successfully deleted remote branch: $BRANCH_NAME"
|
|
227
|
+
else
|
|
228
|
+
echo "⚠️ Branch $BRANCH_NAME may have been already deleted or doesn't exist"
|
|
229
|
+
fi
|
|
230
|
+
else
|
|
231
|
+
echo "ℹ️ Could not extract version bump branch name from commit message"
|
|
232
|
+
echo "Commit message was: $COMMIT_MSG"
|
|
233
|
+
fi
|
|
234
|
+
env:
|
|
235
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
236
|
+
|
|
237
|
+
- name: Generate release notes
|
|
238
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
239
|
+
id: release_notes
|
|
240
|
+
run: |
|
|
241
|
+
# Get commits since last tag (excluding current)
|
|
242
|
+
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
243
|
+
|
|
244
|
+
if [ -z "$LAST_TAG" ]; then
|
|
245
|
+
CHANGES=$(git log --pretty=format:"- [%s](https://github.com/${{ github.repository }}/commit/%H)" --no-merges HEAD^)
|
|
246
|
+
RELEASE_TYPE="Initial Release"
|
|
247
|
+
else
|
|
248
|
+
CHANGES=$(git log $LAST_TAG..HEAD^ --pretty=format:"- [%s](https://github.com/${{ github.repository }}/commit/%H)" --no-merges)
|
|
249
|
+
RELEASE_TYPE="Update"
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
# Create release notes
|
|
253
|
+
cat > release_notes.md << EOF
|
|
254
|
+
## $RELEASE_TYPE
|
|
255
|
+
|
|
256
|
+
### Changes in this version:
|
|
257
|
+
$CHANGES
|
|
258
|
+
|
|
259
|
+
### Installation:
|
|
260
|
+
\`\`\`bash
|
|
261
|
+
npm install freemium-ui@${{ steps.check_version.outputs.version }}
|
|
262
|
+
\`\`\`
|
|
263
|
+
|
|
264
|
+
### Links:
|
|
265
|
+
- [npm Package](https://www.npmjs.com/package/freemium-ui)
|
|
266
|
+
- [Documentation](https://github.com/${{ github.repository }}/blob/main/README.md)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
*This release was automatically generated by GitHub Actions*
|
|
270
|
+
EOF
|
|
271
|
+
|
|
272
|
+
- name: Create GitHub Release
|
|
273
|
+
if: steps.check_version.outputs.is_version_bump == 'true'
|
|
274
|
+
run: |
|
|
275
|
+
gh release create ${{ steps.check_version.outputs.version }} \
|
|
276
|
+
--title "Release ${{ steps.check_version.outputs.version }}" \
|
|
277
|
+
--notes-file release_notes.md
|
|
278
|
+
echo "GitHub release created!"
|
|
279
|
+
env:
|
|
280
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/lib/index.cjs.js
CHANGED
|
@@ -3879,6 +3879,7 @@ className:`input-helper ${t.className??""}`.trim()},t.children),ym=xr.textarea`
|
|
|
3879
3879
|
min-width: 2.5rem;
|
|
3880
3880
|
`,wm=xr.input`
|
|
3881
3881
|
flex: 1;
|
|
3882
|
+
min-width: 0;
|
|
3882
3883
|
border: unset;
|
|
3883
3884
|
outline: unset;
|
|
3884
3885
|
padding: unset;
|
|
@@ -3903,6 +3904,7 @@ className:`input-helper ${t.className??""}`.trim()},t.children),ym=xr.textarea`
|
|
|
3903
3904
|
`,Cm=xr.div`
|
|
3904
3905
|
display: flex;
|
|
3905
3906
|
flex: 1;
|
|
3907
|
+
min-width: 0;
|
|
3906
3908
|
gap: 4px;
|
|
3907
3909
|
font-family: ${({theme:e})=>e.typography.fontFamily};
|
|
3908
3910
|
font-size: ${({theme:e})=>e.typography.primary.fontSize};
|
|
@@ -4786,33 +4788,43 @@ disabled:!!t.disabled,showTick:h}):e.createElement(bb,{key:o,value:a||o,
|
|
|
4786
4788
|
disabled:!!t.disabled,showTick:h},f(t,"list-item")))
|
|
4787
4789
|
})))))))))),w&&z&&e.createElement(gm,null,z))
|
|
4788
4790
|
},yb=({itemIdentifier:t="id",label:n,id:r,items:o=[],placeholder:a,readOnly:i=!1,disabled:l=!1,isRequired:c=!1,hideClear:s=!1,itemToString:u,name:d,filterKey:h,width:f,customValues:p,onCustomValueAdd:m,itemComponent:v,emptyItemsText:g,getCustomMessage:y,style:b,onChange:w,useComboboxProps:C,isErrored:M,errorText:z,defaultSelectedItem:x,isMenuLoading:E,clearInputOnselect:S=!1})=>{
|
|
4789
|
-
const _=pr(),[H,D]=e.useState(o),
|
|
4791
|
+
const _=pr(),[H,D]=e.useState(o),A=e.useRef(null),[L,V]=e.useState((()=>{
|
|
4792
|
+
if("undefined"!=typeof window)return{
|
|
4793
|
+
addEventListener:window.addEventListener.bind(window),
|
|
4794
|
+
removeEventListener:window.removeEventListener.bind(window),document,
|
|
4795
|
+
Node:window.Node}}));e.useEffect((()=>{const e=A.current;if(e){
|
|
4796
|
+
const t=e.getRootNode()
|
|
4797
|
+
;if(t!==document&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const e=t;V({
|
|
4798
|
+
addEventListener:e.addEventListener?.bind(e)||document.addEventListener.bind(document),
|
|
4799
|
+
removeEventListener:e.removeEventListener?.bind(e)||document.removeEventListener.bind(document),
|
|
4800
|
+
document:e.ownerDocument||document,Node:window.Node})}}}),[])
|
|
4801
|
+
;const{isOpen:k,selectedItem:T,getToggleButtonProps:R,getLabelProps:P,getMenuProps:I,openMenu:O,highlightedIndex:N,setHighlightedIndex:F,setInputValue:$,inputValue:B,getItemProps:j,getInputProps:U}=Tl({
|
|
4790
4802
|
id:r,selectedItem:x,items:H,onSelectedItemChange:({selectedItem:e})=>{
|
|
4791
4803
|
w?.(e??null)},onIsOpenChange:({isOpen:e})=>{
|
|
4792
|
-
if(e&&(""===
|
|
4793
|
-
|
|
4804
|
+
if(e&&(""===B||T&&h&&(B||"").toLowerCase()===`${T?.[h||t]||""}`.toLowerCase()))D(o),
|
|
4805
|
+
F(T?o.indexOf(T):-1);else{const t=T?u(T):"";T&&!e&&t!==B&&$(t)}e||D(o),S&&$("")
|
|
4794
4806
|
},onInputValueChange:({inputValue:e})=>{
|
|
4795
|
-
|
|
4796
|
-
},itemToString:e=>e?u(e,"downshift"):"",...C}),
|
|
4797
|
-
;return e.createElement(Kp,{width:f},e.createElement(Ro,{
|
|
4798
|
-
className:"input-label",...
|
|
4799
|
-
},n,n&&c&&e.createElement(Io,null,"*")),e.createElement(Em,{
|
|
4807
|
+
k&&(""===e||T&&h&&(e||"").toLowerCase()===`${T?.[h||t]||""}`.toLowerCase())?D(o):D((n=>n.filter((n=>!e||("string"==typeof n?n:n?.[h||t]).toLowerCase().includes(e.toLowerCase())))))
|
|
4808
|
+
},itemToString:e=>e?u(e,"downshift"):"",environment:L,...C}),Y=!l&&!i&&k
|
|
4809
|
+
;return e.createElement(Kp,{width:f,ref:A},e.createElement(Ro,{
|
|
4810
|
+
className:"input-label",...P({disabled:l,readOnly:i})
|
|
4811
|
+
},n,n&&c&&e.createElement(Io,null,"*")),e.createElement(Em,{...U({name:d,
|
|
4800
4812
|
readOnly:i,disabled:l}),placeholder:a,
|
|
4801
|
-
endAdornment:e.createElement(em,null,!l&&!i&&!s&&
|
|
4802
|
-
"aria-label":"close",onClick:e=>{
|
|
4813
|
+
endAdornment:e.createElement(em,null,!l&&!i&&!s&&T&&e.createElement(Oo,{
|
|
4814
|
+
"aria-label":"close",onClick:e=>{$(""),w?.(null),O(),e.stopPropagation()},
|
|
4803
4815
|
style:{borderRadius:"50%"}},e.createElement(so,{fill:_.colors.text.primary
|
|
4804
|
-
})),e.createElement(Oo,{...
|
|
4805
|
-
})},e.createElement(Gp,{$isOpen:
|
|
4806
|
-
}))),style:b}),!i&&!l&&e.createElement(Zp,{className:"ItemsContainer",$isOpen:
|
|
4807
|
-
...
|
|
4808
|
-
},E?e.createElement(Qp,null,e.createElement(Lm,null)):e.createElement(e.Fragment,null,
|
|
4809
|
-
onClick:e=>{e.stopPropagation(),m&&m({inputValue:
|
|
4810
|
-
},y?.(
|
|
4811
|
-
},g||"No items")),
|
|
4812
|
-
;return e.createElement(e.Fragment,{key:o},v?v(n,{isHilighted:
|
|
4813
|
-
isSelected:
|
|
4814
|
-
$isHilighted:
|
|
4815
|
-
},u(n),
|
|
4816
|
+
})),e.createElement(Oo,{...R({disabled:l,readOnly:i,"aria-label":"toggle-button"
|
|
4817
|
+
})},e.createElement(Gp,{$isOpen:Y,fill:_.colors.text.primary,width:8,height:8
|
|
4818
|
+
}))),style:b}),!i&&!l&&e.createElement(Zp,{className:"ItemsContainer",$isOpen:k,
|
|
4819
|
+
...I({disabled:l,readOnly:i})
|
|
4820
|
+
},E?e.createElement(Qp,null,e.createElement(Lm,null)):e.createElement(e.Fragment,null,k&&0===H.length&&e.createElement(e.Fragment,null,p?e.createElement(Xp,null,e.createElement(Jp,{
|
|
4821
|
+
onClick:e=>{e.stopPropagation(),m&&m({inputValue:B,customValues:!0}),$("")}
|
|
4822
|
+
},y?.(B)||"Click to add")):e.createElement(Xp,{readOnly:!0
|
|
4823
|
+
},g||"No items")),k&&H.map(((n,r)=>{const o="string"==typeof n?n:n?.[t]
|
|
4824
|
+
;return e.createElement(e.Fragment,{key:o},v?v(n,{isHilighted:N===r,
|
|
4825
|
+
isSelected:T===n,key:o,...j({item:n,index:r})}):e.createElement(Xp,{
|
|
4826
|
+
$isHilighted:N===r,$isSelected:T===n,key:o,...j({item:n,index:r})
|
|
4827
|
+
},u(n),T===n&&e.createElement(vo,{fill:_.colors.common.accent})))
|
|
4816
4828
|
})))),M&&z&&e.createElement(gm,null,z))
|
|
4817
4829
|
},bb=e.forwardRef((({children:t,showTick:n=!0,...r},o)=>{const a=pr()
|
|
4818
4830
|
;return e.createElement(lm,{className:"SelectItem",...r,ref:o
|
package/lib/index.js
CHANGED
|
@@ -3840,6 +3840,7 @@ className:`input-helper ${e.className??""}`.trim()},e.children),Fm=Ur.textarea`
|
|
|
3840
3840
|
min-width: 2.5rem;
|
|
3841
3841
|
`,Bm=Ur.input`
|
|
3842
3842
|
flex: 1;
|
|
3843
|
+
min-width: 0;
|
|
3843
3844
|
border: unset;
|
|
3844
3845
|
outline: unset;
|
|
3845
3846
|
padding: unset;
|
|
@@ -3864,6 +3865,7 @@ className:`input-helper ${e.className??""}`.trim()},e.children),Fm=Ur.textarea`
|
|
|
3864
3865
|
`,jm=Ur.div`
|
|
3865
3866
|
display: flex;
|
|
3866
3867
|
flex: 1;
|
|
3868
|
+
min-width: 0;
|
|
3867
3869
|
gap: 4px;
|
|
3868
3870
|
font-family: ${({theme:e})=>e.typography.fontFamily};
|
|
3869
3871
|
font-size: ${({theme:e})=>e.typography.primary.fontSize};
|
|
@@ -4813,33 +4815,43 @@ disabled:!!e.disabled,showTick:h}):t.createElement(Wb,{key:o,value:a||o,
|
|
|
4813
4815
|
disabled:!!e.disabled,showTick:h},p(e,"list-item")))
|
|
4814
4816
|
})))))))))),w&&M&&t.createElement(Nm,null,M))
|
|
4815
4817
|
},Yb=({itemIdentifier:e="id",label:n,id:r,items:o=[],placeholder:a,readOnly:i=!1,disabled:l=!1,isRequired:c=!1,hideClear:s=!1,itemToString:u,name:d,filterKey:h,width:p,customValues:f,onCustomValueAdd:m,itemComponent:v,emptyItemsText:g,getCustomMessage:y,style:b,onChange:w,useComboboxProps:C,isErrored:z,errorText:M,defaultSelectedItem:x,isMenuLoading:E,clearInputOnselect:S=!1})=>{
|
|
4816
|
-
const _=Tr(),[H,D]=t.useState(o),
|
|
4818
|
+
const _=Tr(),[H,D]=t.useState(o),A=t.useRef(null),[L,V]=t.useState((()=>{
|
|
4819
|
+
if("undefined"!=typeof window)return{
|
|
4820
|
+
addEventListener:window.addEventListener.bind(window),
|
|
4821
|
+
removeEventListener:window.removeEventListener.bind(window),document,
|
|
4822
|
+
Node:window.Node}}));t.useEffect((()=>{const e=A.current;if(e){
|
|
4823
|
+
const t=e.getRootNode()
|
|
4824
|
+
;if(t!==document&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const e=t;V({
|
|
4825
|
+
addEventListener:e.addEventListener?.bind(e)||document.addEventListener.bind(document),
|
|
4826
|
+
removeEventListener:e.removeEventListener?.bind(e)||document.removeEventListener.bind(document),
|
|
4827
|
+
document:e.ownerDocument||document,Node:window.Node})}}}),[])
|
|
4828
|
+
;const{isOpen:k,selectedItem:T,getToggleButtonProps:P,getLabelProps:I,getMenuProps:R,openMenu:O,highlightedIndex:N,setHighlightedIndex:F,setInputValue:$,inputValue:B,getItemProps:j,getInputProps:U}=nc({
|
|
4817
4829
|
id:r,selectedItem:x,items:H,onSelectedItemChange:({selectedItem:e})=>{
|
|
4818
4830
|
w?.(e??null)},onIsOpenChange:({isOpen:t})=>{
|
|
4819
|
-
if(t&&(""===
|
|
4820
|
-
|
|
4831
|
+
if(t&&(""===B||T&&h&&(B||"").toLowerCase()===`${T?.[h||e]||""}`.toLowerCase()))D(o),
|
|
4832
|
+
F(T?o.indexOf(T):-1);else{const e=T?u(T):"";T&&!t&&e!==B&&$(e)}t||D(o),S&&$("")
|
|
4821
4833
|
},onInputValueChange:({inputValue:t})=>{
|
|
4822
|
-
|
|
4823
|
-
},itemToString:e=>e?u(e,"downshift"):"",...C}),
|
|
4824
|
-
;return t.createElement(vm,{width:p},t.createElement(na,{
|
|
4825
|
-
className:"input-label",...
|
|
4826
|
-
},n,n&&c&&t.createElement(oa,null,"*")),t.createElement(Gm,{
|
|
4834
|
+
k&&(""===t||T&&h&&(t||"").toLowerCase()===`${T?.[h||e]||""}`.toLowerCase())?D(o):D((n=>n.filter((n=>!t||("string"==typeof n?n:n?.[h||e]).toLowerCase().includes(t.toLowerCase())))))
|
|
4835
|
+
},itemToString:e=>e?u(e,"downshift"):"",environment:L,...C}),Y=!l&&!i&&k
|
|
4836
|
+
;return t.createElement(vm,{width:p,ref:A},t.createElement(na,{
|
|
4837
|
+
className:"input-label",...I({disabled:l,readOnly:i})
|
|
4838
|
+
},n,n&&c&&t.createElement(oa,null,"*")),t.createElement(Gm,{...U({name:d,
|
|
4827
4839
|
readOnly:i,disabled:l}),placeholder:a,
|
|
4828
|
-
endAdornment:t.createElement(zm,null,!l&&!i&&!s&&
|
|
4829
|
-
"aria-label":"close",onClick:e=>{
|
|
4840
|
+
endAdornment:t.createElement(zm,null,!l&&!i&&!s&&T&&t.createElement(aa,{
|
|
4841
|
+
"aria-label":"close",onClick:e=>{$(""),w?.(null),O(),e.stopPropagation()},
|
|
4830
4842
|
style:{borderRadius:"50%"}},t.createElement(Ao,{fill:_.colors.text.primary
|
|
4831
|
-
})),t.createElement(aa,{...
|
|
4832
|
-
})},t.createElement(mm,{$isOpen:
|
|
4833
|
-
}))),style:b}),!i&&!l&&t.createElement(ym,{className:"ItemsContainer",$isOpen:
|
|
4834
|
-
...
|
|
4835
|
-
},E?t.createElement(Cm,null,t.createElement(Qm,null)):t.createElement(t.Fragment,null,
|
|
4836
|
-
onClick:e=>{e.stopPropagation(),m&&m({inputValue:
|
|
4837
|
-
},y?.(
|
|
4838
|
-
},g||"No items")),
|
|
4839
|
-
;return t.createElement(t.Fragment,{key:o},v?v(n,{isHilighted:
|
|
4840
|
-
isSelected:
|
|
4841
|
-
$isHilighted:
|
|
4842
|
-
},u(n),
|
|
4843
|
+
})),t.createElement(aa,{...P({disabled:l,readOnly:i,"aria-label":"toggle-button"
|
|
4844
|
+
})},t.createElement(mm,{$isOpen:Y,fill:_.colors.text.primary,width:8,height:8
|
|
4845
|
+
}))),style:b}),!i&&!l&&t.createElement(ym,{className:"ItemsContainer",$isOpen:k,
|
|
4846
|
+
...R({disabled:l,readOnly:i})
|
|
4847
|
+
},E?t.createElement(Cm,null,t.createElement(Qm,null)):t.createElement(t.Fragment,null,k&&0===H.length&&t.createElement(t.Fragment,null,f?t.createElement(bm,null,t.createElement(wm,{
|
|
4848
|
+
onClick:e=>{e.stopPropagation(),m&&m({inputValue:B,customValues:!0}),$("")}
|
|
4849
|
+
},y?.(B)||"Click to add")):t.createElement(bm,{readOnly:!0
|
|
4850
|
+
},g||"No items")),k&&H.map(((n,r)=>{const o="string"==typeof n?n:n?.[e]
|
|
4851
|
+
;return t.createElement(t.Fragment,{key:o},v?v(n,{isHilighted:N===r,
|
|
4852
|
+
isSelected:T===n,key:o,...j({item:n,index:r})}):t.createElement(bm,{
|
|
4853
|
+
$isHilighted:N===r,$isSelected:T===n,key:o,...j({item:n,index:r})
|
|
4854
|
+
},u(n),T===n&&t.createElement(Io,{fill:_.colors.common.accent})))
|
|
4843
4855
|
})))),z&&M&&t.createElement(Nm,null,M))
|
|
4844
4856
|
},Wb=t.forwardRef((({children:e,showTick:n=!0,...r},o)=>{const a=Tr()
|
|
4845
4857
|
;return t.createElement(Dm,{className:"SelectItem",...r,ref:o
|
package/lib/package.json
CHANGED