@box/combobox-with-api 0.25.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.
- package/LICENSE +379 -0
- package/chunks/dynamic-loading-tree.js +423 -0
- package/esm/index.js +8 -0
- package/esm/lib/components/combobox-with-api/combobox-with-api-container.js +47 -0
- package/esm/lib/components/combobox-with-api/combobox-with-api-error.js +26 -0
- package/esm/lib/components/combobox-with-api/combobox-with-api.js +37 -0
- package/esm/lib/components/combobox-with-api/messages.js +10 -0
- package/esm/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.js +207 -0
- package/esm/lib/components/combobox-with-api-pagination/index.js +4 -0
- package/esm/lib/components/combobox-with-api-pagination/messages.js +34 -0
- package/esm/lib/components/combobox-with-api-pagination/request.js +6 -0
- package/esm/lib/components/combobox-with-api-pagination/use-async-list.js +137 -0
- package/esm/lib/components/combobox-with-api-pagination/utils/is-abort-error.js +13 -0
- package/esm/lib/components/combobox-with-api-pagination/utils/use-controllable-state.js +40 -0
- package/esm/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.js +87 -0
- package/esm/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.js +125 -0
- package/esm/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.js +10 -0
- package/esm/lib/components/combobox-with-api-tree-view/index.js +4 -0
- package/esm/lib/components/combobox-with-api-tree-view/tree-utils.js +26 -0
- package/i18n/bn-IN.js +10 -0
- package/i18n/bn-IN.properties +16 -0
- package/i18n/da-DK.js +10 -0
- package/i18n/da-DK.properties +16 -0
- package/i18n/de-DE.js +10 -0
- package/i18n/de-DE.properties +16 -0
- package/i18n/en-AU.js +10 -0
- package/i18n/en-AU.properties +16 -0
- package/i18n/en-CA.js +10 -0
- package/i18n/en-CA.properties +16 -0
- package/i18n/en-GB.js +10 -0
- package/i18n/en-GB.properties +16 -0
- package/i18n/en-US.js +10 -0
- package/i18n/en-US.properties +16 -0
- package/i18n/en-x-pseudo.js +10 -0
- package/i18n/en-x-pseudo.properties +16 -0
- package/i18n/es-419.js +10 -0
- package/i18n/es-419.properties +16 -0
- package/i18n/es-ES.js +10 -0
- package/i18n/es-ES.properties +16 -0
- package/i18n/fi-FI.js +10 -0
- package/i18n/fi-FI.properties +16 -0
- package/i18n/fr-CA.js +10 -0
- package/i18n/fr-CA.properties +16 -0
- package/i18n/fr-FR.js +10 -0
- package/i18n/fr-FR.properties +16 -0
- package/i18n/hi-IN.js +10 -0
- package/i18n/hi-IN.properties +16 -0
- package/i18n/it-IT.js +10 -0
- package/i18n/it-IT.properties +16 -0
- package/i18n/ja-JP.js +10 -0
- package/i18n/ja-JP.properties +16 -0
- package/i18n/json/src/lib/components/combobox-with-api/messages.json +1 -0
- package/i18n/json/src/lib/components/combobox-with-api-pagination/messages.json +1 -0
- package/i18n/ko-KR.js +10 -0
- package/i18n/ko-KR.properties +16 -0
- package/i18n/nb-NO.js +10 -0
- package/i18n/nb-NO.properties +16 -0
- package/i18n/nl-NL.js +10 -0
- package/i18n/nl-NL.properties +16 -0
- package/i18n/pl-PL.js +10 -0
- package/i18n/pl-PL.properties +16 -0
- package/i18n/pt-BR.js +10 -0
- package/i18n/pt-BR.properties +16 -0
- package/i18n/ru-RU.js +10 -0
- package/i18n/ru-RU.properties +16 -0
- package/i18n/sv-SE.js +10 -0
- package/i18n/sv-SE.properties +16 -0
- package/i18n/tr-TR.js +10 -0
- package/i18n/tr-TR.properties +16 -0
- package/i18n/zh-CN.js +10 -0
- package/i18n/zh-CN.properties +16 -0
- package/i18n/zh-TW.js +10 -0
- package/i18n/zh-TW.properties +16 -0
- package/package.json +55 -0
- package/styles/combobox-with-api-error.css +1 -0
- package/styles/combobox-with-api-pagination.css +1 -0
- package/styles/dynamic-loading-tree.css +1 -0
- package/types/index.d.ts +4 -0
- package/types/lib/components/combobox-with-api/combobox-with-api-container.d.ts +3 -0
- package/types/lib/components/combobox-with-api/combobox-with-api-error.d.ts +3 -0
- package/types/lib/components/combobox-with-api/combobox-with-api.d.ts +3 -0
- package/types/lib/components/combobox-with-api/messages.d.ts +8 -0
- package/types/lib/components/combobox-with-api/stories/shared.d.ts +8 -0
- package/types/lib/components/combobox-with-api/types.d.ts +39 -0
- package/types/lib/components/combobox-with-api-pagination/combobox-with-api-pagination.d.ts +17 -0
- package/types/lib/components/combobox-with-api-pagination/index.d.ts +2 -0
- package/types/lib/components/combobox-with-api-pagination/messages.d.ts +38 -0
- package/types/lib/components/combobox-with-api-pagination/request.d.ts +7 -0
- package/types/lib/components/combobox-with-api-pagination/stories/shared.d.ts +38 -0
- package/types/lib/components/combobox-with-api-pagination/types.d.ts +49 -0
- package/types/lib/components/combobox-with-api-pagination/use-async-list.d.ts +63 -0
- package/types/lib/components/combobox-with-api-pagination/utils/is-abort-error.d.ts +1 -0
- package/types/lib/components/combobox-with-api-pagination/utils/use-controllable-state.d.ts +8 -0
- package/types/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.d.ts +28 -0
- package/types/lib/components/combobox-with-api-tree-view/combobox-with-api-tree-view.d.ts +21 -0
- package/types/lib/components/combobox-with-api-tree-view/dynamic-loading-tree.d.ts +23 -0
- package/types/lib/components/combobox-with-api-tree-view/index.d.ts +3 -0
- package/types/lib/components/combobox-with-api-tree-view/stories/mock-api-response.d.ts +11 -0
- package/types/lib/components/combobox-with-api-tree-view/stories/shared.d.ts +26 -0
- package/types/lib/components/combobox-with-api-tree-view/tree-utils.d.ts +22 -0
- package/types/lib/components/combobox-with-api-tree-view/types.d.ts +60 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = Nie można wczytać wyników. Kliknij, aby spróbować ponownie.
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = Wyczyść wprowadzone dane i wybór
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = Wczytaj ponownie
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = Błąd
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = Nie udało się wczytać opcji
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = Wczytywanie...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = Wczytywanie kolejnych...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = Brak wyników
|
package/i18n/pt-BR.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "Não foi possível carregar os resultados. Clique para tentar novamente.",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "Limpar entrada e seleção",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "Recarregar",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "Erro",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "Falha ao carregar opções",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "Carregando...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "Carregando mais...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "Nenhum resultado encontrado"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = Não foi possível carregar os resultados. Clique para tentar novamente.
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = Limpar entrada e seleção
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = Recarregar
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = Erro
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = Falha ao carregar opções
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = Carregando...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = Carregando mais...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = Nenhum resultado encontrado
|
package/i18n/ru-RU.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "Не удалось загрузить результаты. Нажмите, чтобы повторить попытку.",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "Очистить ввод и выбор",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "Перезагрузить",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "Ошибка",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "Не удалось загрузить параметры",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "Загрузка...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "Загрузка больше...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "Результаты не найдены"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = Не удалось загрузить результаты. Нажмите, чтобы повторить попытку.
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = Очистить ввод и выбор
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = Перезагрузить
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = Ошибка
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = Не удалось загрузить параметры
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = Загрузка...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = Загрузка больше...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = Результаты не найдены
|
package/i18n/sv-SE.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "Det gick inte att läsa in resultat. Klicka för att försöka igen.",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "Rensa indata val",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "Läsa in igen",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "Fel",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "Det gick inte att läsa in tillval",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "Läser in...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "Läser in mer...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "Inga resultat hittades"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = Det gick inte att läsa in resultat. Klicka för att försöka igen.
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = Rensa indata val
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = Läsa in igen
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = Fel
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = Det gick inte att läsa in tillval
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = Läser in...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = Läser in mer...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = Inga resultat hittades
|
package/i18n/tr-TR.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "Sonuçlar yüklenemedi. Tekrar denemek için tıklayın.",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "Giriş ve seçimi temizle",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "Yeniden Yükle",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "Hata",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "Seçenekler yüklenemedi",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "Yükleniyor...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "Daha fazlası yükleniyor...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "Hiçbir sonuç bulunamadı"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = Sonuçlar yüklenemedi. Tekrar denemek için tıklayın.
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = Giriş ve seçimi temizle
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = Yeniden Yükle
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = Hata
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = Seçenekler yüklenemedi
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = Yükleniyor...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = Daha fazlası yükleniyor...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = Hiçbir sonuç bulunamadı
|
package/i18n/zh-CN.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "无法加载结果。单击以重试。",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "清除输入和选择",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "重新加载",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "错误",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "无法加载选项",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "正在加载...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "加载更多...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "未找到结果"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = 无法加载结果。单击以重试。
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = 清除输入和选择
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = 重新加载
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = 错误
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = 无法加载选项
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = 正在加载...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = 加载更多...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = 未找到结果
|
package/i18n/zh-TW.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"comboboxWithApi.apiError": "無法載入結果。按一下以重試。",
|
|
3
|
+
"comboboxWithApiPagination.clearButtonAriaLabel": "清除輸入和選擇",
|
|
4
|
+
"comboboxWithApiPagination.errorAction": "重新載入",
|
|
5
|
+
"comboboxWithApiPagination.errorIconLabel": "錯誤",
|
|
6
|
+
"comboboxWithApiPagination.errorMessage": "載入選項失敗",
|
|
7
|
+
"comboboxWithApiPagination.loadingAriaLabel": "正在載入...",
|
|
8
|
+
"comboboxWithApiPagination.loadingMoreAriaLabel": "正在載入更多...",
|
|
9
|
+
"comboboxWithApiPagination.noResults": "找不到結果"
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Error message displayed as combobox item when an API failed and the suggestions could not load
|
|
2
|
+
comboboxWithApi.apiError = 無法載入結果。按一下以重試。
|
|
3
|
+
# Aria label for the clear button visible at the end of the combobox. When clicked, it will clear all text in the input, as well as the current selection.
|
|
4
|
+
comboboxWithApiPagination.clearButtonAriaLabel = 清除輸入和選擇
|
|
5
|
+
# Error message displayed resembling button that calls to action to reload the results
|
|
6
|
+
comboboxWithApiPagination.errorAction = 重新載入
|
|
7
|
+
# Aria-label text for the error icon in the loading results error message
|
|
8
|
+
comboboxWithApiPagination.errorIconLabel = 錯誤
|
|
9
|
+
# Error message displayed as inline notice that informs the user that the options failed to load
|
|
10
|
+
comboboxWithApiPagination.errorMessage = 載入選項失敗
|
|
11
|
+
# Visually hidden aria-label text for the loading spinner
|
|
12
|
+
comboboxWithApiPagination.loadingAriaLabel = 正在載入...
|
|
13
|
+
# Visually hidden aria-label text for the loading spinner show when loading more results from infinite scrolling list
|
|
14
|
+
comboboxWithApiPagination.loadingMoreAriaLabel = 正在載入更多...
|
|
15
|
+
# Message displayed when no results are found in the combobox
|
|
16
|
+
comboboxWithApiPagination.noResults = 找不到結果
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@box/combobox-with-api",
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@ariakit/react": "0.4.15",
|
|
6
|
+
"@box/blueprint-web": "^7.8.0",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.16.0",
|
|
8
|
+
"lodash": "^4.17.15",
|
|
9
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
10
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
11
|
+
"react-intl": "^6.4.2"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@box/tree": "^0.38.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@box/blueprint-web": "^9.18.6",
|
|
18
|
+
"@box/blueprint-web-assets": "^4.34.0",
|
|
19
|
+
"@box/storybook-utils": "^0.8.3",
|
|
20
|
+
"react": "^18.3.0",
|
|
21
|
+
"react-dom": "^18.3.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepare": "yarn nx run combobox-with-api:prepare"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"directory": "dist",
|
|
29
|
+
"registry": "https://registry.npmjs.org"
|
|
30
|
+
},
|
|
31
|
+
"main": "./esm/index.js",
|
|
32
|
+
"module": "./esm/index.js",
|
|
33
|
+
"types": "./types/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"require": "./esm/index.js",
|
|
37
|
+
"import": "./esm/index.js",
|
|
38
|
+
"types": "./types/index.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./*": {
|
|
41
|
+
"require": "./esm/*",
|
|
42
|
+
"import": "./esm/*",
|
|
43
|
+
"types": "./types/*"
|
|
44
|
+
},
|
|
45
|
+
"./i18n/*": {
|
|
46
|
+
"require": "./i18n/*",
|
|
47
|
+
"import": "./i18n/*"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": [
|
|
51
|
+
"**/*.css"
|
|
52
|
+
],
|
|
53
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
54
|
+
"gitHead": "79df9d03b4f09ec7f33ee7195e9654b9123c55d4"
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_1ozsi_1{display:flex;gap:var(--space-1);justify-content:center}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_1m7se_1{display:flex;gap:var(--space-1);justify-content:center}._disabled_1m7se_7._disabled_1m7se_7{opacity:unset}._highlightOptionText_1m7se_11 [data-user-value]{font-weight:700;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none}._highlightOptionText_1m7se_11 [data-autocomplete-value]{color:var(--text-text-on-light-secondary)}._highlightOptionText_1m7se_11._selected_1m7se_23,._highlightOptionText_1m7se_11._selected_1m7se_23 span{color:var(--text-text-on-light);font-weight:700;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none}._option_1m7se_34:nth-last-child(1 of._option_1m7se_34){scroll-margin-block-end:var(--space-12)}._errorComboboxOption_1m7se_38[role=option]{display:flex;align-items:center;justify-content:center}._errorComboboxOption_1m7se_38[role=option] ._errorComboboxOptionText_1m7se_43{display:flex;gap:var(--space-1);align-items:center}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._container_sdpm3_1{font-weight:400;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none;display:flex;flex-direction:column}._container_sdpm3_1._disabled_sdpm3_12{opacity:.1}._container_sdpm3_1 ._label_sdpm3_15{font-weight:700;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none;flex:0 0 fit-content;color:var(--text-text-on-light);overflow-wrap:break-word}._container_sdpm3_1 ._label_sdpm3_15:not(._hiddenLabel_sdpm3_27){margin-block-end:var(--space-2)}._container_sdpm3_1 ._comboboxContainer_sdpm3_30{position:relative;display:flex;flex-wrap:wrap;gap:var(--space-2);overflow-y:auto;background-color:var(--surface-dropdown-surface);border-top:var(--blueprint-combobox-border-top-width, var(--border-1)) solid var(--blueprint-combobox-border-color, var(--border-input-border));border-right:var(--blueprint-combobox-border-right-width, var(--border-1)) solid var(--blueprint-combobox-border-color, var(--border-input-border));border-bottom:var(--blueprint-combobox-border-bottom-width, var(--border-1)) solid var(--blueprint-combobox-border-color, var(--border-input-border));border-left:var(--blueprint-combobox-border-left-width, var(--border-1)) solid var(--blueprint-combobox-border-color, var(--border-input-border));border-radius:var(--blueprint-combobox-input-radius, var(--radius-2));box-shadow:var(--innershadow-1);padding-block:calc((40px - var(--space-5)) / 2 - var(--border-1));padding-inline:var(--space-3)}._container_sdpm3_1 ._comboboxContainer_sdpm3_30._withComboboxButtons_sdpm3_46{padding-inline-end:var(--space-10)}._container_sdpm3_1 ._comboboxContainer_sdpm3_30:not(:disabled):has(input:focus){background-color:var(--surface-dropdown-surface-focus);border:var(--border-2),solid,var(--outline-focus-on-light);padding-block:calc((40px - var(--space-5)) / 2 - var(--border-2))}._container_sdpm3_1 ._comboboxContainer_sdpm3_30:not(:disabled)._error_sdpm3_54,._container_sdpm3_1 ._comboboxContainer_sdpm3_30:not(:disabled):has([aria-invalid=true]){background-color:var(--surface-dropdown-surface-error);border-top:var(--blueprint-combobox-border-error-top-width, var(--border-2)) solid var(--border-input-border-error);border-right:var(--blueprint-combobox-border-error-right-width, var(--border-2)) solid var(--border-input-border-error);border-bottom:var(--blueprint-combobox-border-error-bottom-width, var(--border-2)) solid var(--border-input-border-error);border-left:var(--blueprint-combobox-border-error-left-width, var(--border-2)) solid var(--border-input-border-error);padding-block:calc((40px - var(--space-5)) / 2 - var(--border-2))}._container_sdpm3_1 ._comboboxContainer_sdpm3_30 ._textInputWrapper_sdpm3_62{display:flex;flex:content;gap:var(--space-2);align-items:center}._container_sdpm3_1 ._comboboxContainer_sdpm3_30 ._textInputWrapper_sdpm3_62 ._textInput_sdpm3_62{font-weight:400;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none;width:100%;height:var(--space-5);padding:0;color:var(--text-text-on-light);background-color:transparent;border:none;outline:none}._container_sdpm3_1 ._comboboxContainer_sdpm3_30 ._textInputWrapper_sdpm3_62 ._errorIcon_sdpm3_84 path{fill:var(--icon-icon-error-on-light)}._container_sdpm3_1 ._comboboxContainer_sdpm3_30 ._textInputWrapper_sdpm3_62 ._comboboxButtons_sdpm3_87{position:absolute;top:var(--space-2);right:var(--space-2);display:flex;align-items:center}._container_sdpm3_1 ._comboboxContainer_sdpm3_30._withChips_sdpm3_94{max-height:calc(2 * var(--space-2) + 3 * var(--space-6));padding-block:calc((40px - var(--space-7)) / 2 - var(--border-1))}._container_sdpm3_1 ._comboboxContainer_sdpm3_30._withChips_sdpm3_94:not(:disabled)._error_sdpm3_54{padding-block:calc((40px - var(--space-7)) / 2 - var(--border-2))}._container_sdpm3_1 ._comboboxContainer_sdpm3_30._withChips_sdpm3_94:not(:disabled):has(input:focus){padding-block:calc((40px - var(--space-7)) / 2 - var(--border-2))}._container_sdpm3_1 ._inlineError_sdpm3_104{margin-block-start:var(--space-2)}._popover_sdpm3_108{font-weight:400;font-size:.875rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1.25rem;letter-spacing:.01875rem;text-transform:none;text-decoration:none;z-index:380;max-height:min(var(--popover-available-height, 36px),200px);overflow:auto;background-color:var(--surface-menu-surface);border:var(--border-1) solid var(--border-card-border);border-radius:var(--radius-3);padding-block:var(--space-3);padding-inline:var(--space-3);box-shadow:var(--dropshadow-3)}._popover_sdpm3_108 ul{padding-inline-start:0}._popover_sdpm3_108 ._option_sdpm3_134{position:relative;box-sizing:border-box;width:100%;overflow-wrap:break-word;border:var(--border-2) solid transparent;border-radius:var(--radius-3);outline:none;cursor:pointer;-webkit-user-select:none;user-select:none;padding-block:var(--space-2);padding-inline:var(--space-2)}._popover_sdpm3_108 ._option_sdpm3_134[aria-disabled]{opacity:.1}._popover_sdpm3_108 ._option_sdpm3_134[data-active-item]:not([aria-disabled]){background-color:var(--surface-menu-surface-focus);border:var(--border-2) solid var(--outline-focus-on-light)}._popover_sdpm3_108 ._option_sdpm3_134:hover{background-color:var(--surface-menu-surface-hover)}._popover_sdpm3_108 ._option_sdpm3_134 ._indicator_sdpm3_157{position:absolute;top:0;left:var(--space-2);display:flex;align-items:center;justify-content:center;height:var(--size-9)}._popover_sdpm3_108 ._option_sdpm3_134 ._indicator_sdpm3_157 ._indicatorIcon_sdpm3_166 path{fill:var(--icon-icon-on-light)}._popover_sdpm3_108 ._optionWithIndicator_sdpm3_169{padding-inline:var(--space-10) var(--space-2)}._popover_sdpm3_108 ._loadingIndicator_sdpm3_172{position:unset}._popover_sdpm3_108 ._noResultOption_sdpm3_175{width:90vw;color:var(--text-text-on-light);text-align:center;-webkit-user-select:none;user-select:none}._popover_sdpm3_108 ._treeContainer_sdpm3_181{width:90vw}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './lib/components/combobox-with-api-pagination';
|
|
2
|
+
export * from './lib/components/combobox-with-api-tree-view';
|
|
3
|
+
export { ComboboxWithApiContainer as ComboboxWithApi } from './lib/components/combobox-with-api/combobox-with-api-container';
|
|
4
|
+
export { type ComboboxWithApiContainerProps as ComboboxWithApiProps } from './lib/components/combobox-with-api/types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OptionValue } from '@box/blueprint-web';
|
|
2
|
+
import { ComboboxWithApiContainerProps } from './types';
|
|
3
|
+
export declare const ComboboxWithApiContainer: <Multiple extends boolean, FreeInput extends boolean, T extends OptionValue>(props: ComboboxWithApiContainerProps<Multiple, FreeInput, T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OptionValue } from '@box/blueprint-web';
|
|
2
|
+
import { ComboboxWithApiProps } from './types';
|
|
3
|
+
export declare const ComboboxWithApi: <Multiple extends boolean, FreeInput extends boolean, T extends OptionValue>(props: ComboboxWithApiProps<Multiple, FreeInput, T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OptionValue } from '@box/blueprint-web';
|
|
2
|
+
import { ComboboxWithApiContainerProps, ComboboxWithApiProps } from '../types';
|
|
3
|
+
export type ContainerTemplateProps = Omit<ComboboxWithApiContainerProps<true, false, OptionValue>, 'value' | 'onValueChange'>;
|
|
4
|
+
export declare const defaultContainerTemplateProps: ContainerTemplateProps;
|
|
5
|
+
export declare const ContainerTemplate: (props: ContainerTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type ComponentTemplateProps = Omit<ComboboxWithApiProps<true, false, OptionValue>, 'value' | 'onValueChange'>;
|
|
7
|
+
export declare const defaultComponentTemplateProps: ComponentTemplateProps;
|
|
8
|
+
export declare const ComponentTemplate: (props: ComponentTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComboboxProps, OptionValue } from '@box/blueprint-web';
|
|
2
|
+
export type ComboboxWithApiProps<Multiple extends boolean, FreeInput extends boolean, T extends OptionValue> = Omit<ComboboxProps<Multiple, FreeInput, T>, 'error' | 'hideSelectedOptions'> & Required<Pick<ComboboxProps<Multiple, FreeInput, T>, 'value' | 'onValueChange' | 'loadingAriaLabel'>> & {
|
|
3
|
+
/**
|
|
4
|
+
* Displays error state
|
|
5
|
+
*/
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Displays empty state
|
|
9
|
+
*/
|
|
10
|
+
isEmpty?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Displays loading state
|
|
13
|
+
*/
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Function called when user clicks try again in error state
|
|
17
|
+
*/
|
|
18
|
+
onTryAgain: () => void;
|
|
19
|
+
};
|
|
20
|
+
export type ComboboxWithApiContainerProps<Multiple extends boolean, FreeInput extends boolean, T extends OptionValue> = Omit<ComboboxWithApiProps<Multiple, FreeInput, T>, 'options' | 'onTryAgain'> & {
|
|
21
|
+
/**
|
|
22
|
+
* Debounce time in ms for the fetcher call. Defaults to 250ms.
|
|
23
|
+
*/
|
|
24
|
+
debounceTime?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Function to fetch options for the Combobox
|
|
27
|
+
*/
|
|
28
|
+
fetcher: (inputValue: string) => Promise<T[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Boolean to show a dropdown option for text input
|
|
31
|
+
*/
|
|
32
|
+
includeTextInputOption?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type ComboboxWithApiErrorProps = {
|
|
35
|
+
/**
|
|
36
|
+
* onClick function for the try again button
|
|
37
|
+
*/
|
|
38
|
+
onTryAgain: () => void;
|
|
39
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseOptionType } from './types';
|
|
2
|
+
export declare const ComboboxWithApiPagination: import('react').ForwardRefExoticComponent<{
|
|
3
|
+
defaultFetcher(input: import('./types').PaginationQueryInput): Promise<import('./types').FetcherResponse<BaseOptionType>>;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
includeTextInputOption?: boolean;
|
|
6
|
+
noResultMessage?: import('react').ReactElement | string;
|
|
7
|
+
onInputValueChange?: (inputValue: string) => void;
|
|
8
|
+
multiselect?: boolean;
|
|
9
|
+
onValueChange?: (selectedOptions: BaseOptionType[]) => void;
|
|
10
|
+
value?: BaseOptionType[];
|
|
11
|
+
defaultValue?: BaseOptionType[];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
loadingAriaLabel?: string;
|
|
14
|
+
portalElement?: HTMLElement | (() => HTMLElement);
|
|
15
|
+
experimentalVirtualization?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
} & import('@box/blueprint-web').Labelable & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
loadingResultsErrorAction: {
|
|
3
|
+
defaultMessage: string;
|
|
4
|
+
description: string;
|
|
5
|
+
id: string;
|
|
6
|
+
};
|
|
7
|
+
loadingResultsErrorMessage: {
|
|
8
|
+
defaultMessage: string;
|
|
9
|
+
description: string;
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
loadingResultsErrorIconLabel: {
|
|
13
|
+
defaultMessage: string;
|
|
14
|
+
description: string;
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
loadingAriaLabel: {
|
|
18
|
+
defaultMessage: string;
|
|
19
|
+
description: string;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
loadingMoreAriaLabel: {
|
|
23
|
+
defaultMessage: string;
|
|
24
|
+
description: string;
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
noResults: {
|
|
28
|
+
defaultMessage: string;
|
|
29
|
+
description: string;
|
|
30
|
+
id: string;
|
|
31
|
+
};
|
|
32
|
+
clearButtonAriaLabel: {
|
|
33
|
+
defaultMessage: string;
|
|
34
|
+
description: string;
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export default messages;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
import { ComboboxWithApiPagination } from '../combobox-with-api-pagination';
|
|
3
|
+
import { BaseOptionType, PaginationQueryInput } from '../types';
|
|
4
|
+
interface FetcherResponse {
|
|
5
|
+
marker?: string;
|
|
6
|
+
options: BaseOptionType[];
|
|
7
|
+
}
|
|
8
|
+
declare const combineSpanTextContent: (text: string) => (_content: string, element: HTMLElement) => boolean;
|
|
9
|
+
interface MockFetcherProps extends PaginationQueryInput {
|
|
10
|
+
options?: BaseOptionType[];
|
|
11
|
+
delay?: number;
|
|
12
|
+
failOnLoadMore?: boolean;
|
|
13
|
+
failOnLoadMoreTimes?: number;
|
|
14
|
+
}
|
|
15
|
+
declare const findState: (name: string) => BaseOptionType;
|
|
16
|
+
declare const mockFetcher: ({ delay, signal, searchInput, marker, failOnLoadMore, failOnLoadMoreTimes, options, }: MockFetcherProps) => Promise<FetcherResponse>;
|
|
17
|
+
declare const mockRejectedFetcher: ({ delay }: MockFetcherProps) => Promise<FetcherResponse>;
|
|
18
|
+
declare const defaultArgs: {
|
|
19
|
+
label: string;
|
|
20
|
+
defaultFetcher: ({ ...options }: PaginationQueryInput) => Promise<FetcherResponse>;
|
|
21
|
+
portalElement: () => HTMLElement;
|
|
22
|
+
multiselect: false;
|
|
23
|
+
};
|
|
24
|
+
declare const withoutDisplayValueArgs: {
|
|
25
|
+
defaultFetcher: ({ ...options }: {
|
|
26
|
+
[x: string]: any;
|
|
27
|
+
}) => Promise<FetcherResponse>;
|
|
28
|
+
label: string;
|
|
29
|
+
portalElement: () => HTMLElement;
|
|
30
|
+
multiselect: false;
|
|
31
|
+
};
|
|
32
|
+
type Story = StoryObj<typeof ComboboxWithApiPagination>;
|
|
33
|
+
declare function getComboboxElements({ canvasElement }: Parameters<Story['play']>[0]): {
|
|
34
|
+
input: HTMLElement;
|
|
35
|
+
listbox: HTMLElement;
|
|
36
|
+
readonly loadingIndicator: HTMLElement;
|
|
37
|
+
};
|
|
38
|
+
export { findState, mockFetcher, mockRejectedFetcher, combineSpanTextContent, defaultArgs, getComboboxElements, withoutDisplayValueArgs, };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Labelable } from '@box/blueprint-web';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export interface PaginationQueryInput {
|
|
4
|
+
marker?: string;
|
|
5
|
+
searchInput?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Abort signal that will be used to cancel the request in your fetching function
|
|
8
|
+
*/
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export interface TreeQueryInput extends PaginationQueryInput {
|
|
12
|
+
onlySelectableOptions?: boolean;
|
|
13
|
+
level?: number;
|
|
14
|
+
ancestorId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FetcherResponse<T> {
|
|
17
|
+
marker?: string;
|
|
18
|
+
options: T[];
|
|
19
|
+
}
|
|
20
|
+
export interface BaseOptionType {
|
|
21
|
+
displayValue?: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TreeAncestor {
|
|
25
|
+
id: string;
|
|
26
|
+
displayName: string;
|
|
27
|
+
level: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TreeOptionType extends BaseOptionType {
|
|
30
|
+
level: number;
|
|
31
|
+
ancestors?: TreeAncestor[];
|
|
32
|
+
selectable: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type ComboboxWithApiPaginationProps<T extends BaseOptionType> = {
|
|
35
|
+
defaultFetcher(input: PaginationQueryInput): Promise<FetcherResponse<T>>;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
includeTextInputOption?: boolean;
|
|
38
|
+
noResultMessage?: ReactElement | string;
|
|
39
|
+
onInputValueChange?: (inputValue: string) => void;
|
|
40
|
+
multiselect?: boolean;
|
|
41
|
+
onValueChange?: (selectedOptions: T[]) => void;
|
|
42
|
+
value?: T[];
|
|
43
|
+
defaultValue?: T[];
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
loadingAriaLabel?: string;
|
|
46
|
+
portalElement?: HTMLElement | (() => HTMLElement);
|
|
47
|
+
experimentalVirtualization?: boolean;
|
|
48
|
+
className?: string;
|
|
49
|
+
} & Labelable;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { RequestStates } from './request';
|
|
2
|
+
interface AsyncListOptions<T, C> {
|
|
3
|
+
/** A function that loads the data for the items in the list. */
|
|
4
|
+
load: AsyncListLoadFunction<T, C>;
|
|
5
|
+
}
|
|
6
|
+
type AsyncListLoadFunction<T, C> = (state: AsyncListLoadOptions<T, C>) => AsyncListStateUpdate<T, C> | Promise<AsyncListStateUpdate<T, C>>;
|
|
7
|
+
interface AsyncListLoadOptions<T, C> {
|
|
8
|
+
/** The items currently in the list. */
|
|
9
|
+
items: T[];
|
|
10
|
+
/** The pagination marker returned from the last page load. */
|
|
11
|
+
marker?: C;
|
|
12
|
+
/** The current request state of the list. */
|
|
13
|
+
requestState?: RequestStates;
|
|
14
|
+
/** The current filter text used to perform server side filtering. */
|
|
15
|
+
searchInput?: string;
|
|
16
|
+
/** An abort signal used to notify the load function that the request has been aborted. */
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
interface AsyncListStateUpdate<T, C> {
|
|
20
|
+
/** The new items to append to the list. */
|
|
21
|
+
items: Iterable<T>;
|
|
22
|
+
/** The pagination marker to be used for the next page load. */
|
|
23
|
+
marker?: C;
|
|
24
|
+
/** The updated filter text for the list. */
|
|
25
|
+
searchInput?: string;
|
|
26
|
+
}
|
|
27
|
+
declare enum ActionTypes {
|
|
28
|
+
LOAD_MORE = "LOAD_MORE",
|
|
29
|
+
RELOAD = "RELOAD",
|
|
30
|
+
SEARCH = "SEARCH",
|
|
31
|
+
SET_ERROR = "SET_ERROR",
|
|
32
|
+
SET_LOADING = "SET_LOADING"
|
|
33
|
+
}
|
|
34
|
+
interface AsyncListData<T> {
|
|
35
|
+
/** If loading data failed, then this contains the error that occurred. */
|
|
36
|
+
hasError: boolean;
|
|
37
|
+
/** Whether marker is expecting a next page. */
|
|
38
|
+
hasNextPage: boolean;
|
|
39
|
+
/** Whether data is populated. */
|
|
40
|
+
isEmpty: boolean;
|
|
41
|
+
/** Whether request is in a loading state. */
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
/** Wether all options are hidden and a loading indicator is all that appears */
|
|
44
|
+
isReloading: boolean;
|
|
45
|
+
/** The items in the list. */
|
|
46
|
+
items: T[];
|
|
47
|
+
/** Loads the next page of data in the list. */
|
|
48
|
+
loadMore(): void;
|
|
49
|
+
/** Reloads the data in the list. */
|
|
50
|
+
reload(): void;
|
|
51
|
+
/** Return the last action used in the reducer. */
|
|
52
|
+
requestInitiator: ActionTypes;
|
|
53
|
+
/** The current filter text. */
|
|
54
|
+
searchInput: string;
|
|
55
|
+
/** Sets the filter text. */
|
|
56
|
+
search(searchInput: string): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Manages state for an immutable async loaded list data structure, and provides convenience methods to
|
|
60
|
+
* update the data over time. Manages request states and pagination.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): AsyncListData<T>;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface UseControllableStateParams<T> {
|
|
3
|
+
prop?: T | undefined;
|
|
4
|
+
defaultProp?: T | undefined;
|
|
5
|
+
onChange?: (state: T) => void;
|
|
6
|
+
}
|
|
7
|
+
declare function useControllableState<T>({ prop, defaultProp, onChange }: UseControllableStateParams<T>): readonly [T, React.Dispatch<React.SetStateAction<T>>];
|
|
8
|
+
export { useControllableState };
|
package/types/lib/components/combobox-with-api-pagination/utils/use-intersection-observer.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type IntersectionObserverHookArgs = Omit<IntersectionObserverInit, 'root'>;
|
|
2
|
+
export type IntersectionObserverHookRefCallbackNode = Element | null;
|
|
3
|
+
export type IntersectionObserverHookRefCallback = (node: IntersectionObserverHookRefCallbackNode) => void;
|
|
4
|
+
export type IntersectionObserverHookRootRefCallbackNode = IntersectionObserverInit['root'];
|
|
5
|
+
export type IntersectionObserverHookRootRefCallback = (node: IntersectionObserverHookRootRefCallbackNode) => void;
|
|
6
|
+
export type IntersectionObserverHookResult = [
|
|
7
|
+
IntersectionObserverHookRefCallback,
|
|
8
|
+
{
|
|
9
|
+
entry: IntersectionObserverEntry | undefined;
|
|
10
|
+
rootRef: IntersectionObserverHookRootRefCallback;
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
export interface CachedIntersectionObserver {
|
|
14
|
+
observe: (node: Element, callback: (entry: IntersectionObserverEntry) => void) => void;
|
|
15
|
+
unobserve: (node: Element) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function createObserverCache(): {
|
|
18
|
+
getObserver: ({ root, rootMargin, threshold }: IntersectionObserverInit) => CachedIntersectionObserver;
|
|
19
|
+
};
|
|
20
|
+
export type TrackVisibilityHookArgs = IntersectionObserverHookArgs;
|
|
21
|
+
export type TrackVisibilityHookResult = [
|
|
22
|
+
IntersectionObserverHookResult[0],
|
|
23
|
+
IntersectionObserverHookResult[1] & {
|
|
24
|
+
isVisible: boolean;
|
|
25
|
+
wasEverVisible: boolean;
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
export declare function useTrackVisibility(args?: IntersectionObserverHookArgs): TrackVisibilityHookResult;
|