@lowdefy/blocks-native 0.0.0-experimental-20261019052246
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 +201 -0
- package/README.md +10 -0
- package/dist/blocks/ActivityTimeline/ActivityTimeline.js +477 -0
- package/dist/blocks/ActivityTimeline/CommentBody.js +174 -0
- package/dist/blocks/ActivityTimeline/CommentItem.js +300 -0
- package/dist/blocks/ActivityTimeline/EditBox.js +143 -0
- package/dist/blocks/ActivityTimeline/LineText.js +71 -0
- package/dist/blocks/ActivityTimeline/RailIcon.js +41 -0
- package/dist/blocks/ActivityTimeline/RailRow.js +74 -0
- package/dist/blocks/ActivityTimeline/ReactionPicker.js +68 -0
- package/dist/blocks/ActivityTimeline/ReactionPills.js +112 -0
- package/dist/blocks/ActivityTimeline/ThreadCard.js +159 -0
- package/dist/blocks/ActivityTimeline/TimelineMarkdownRenderer.js +48 -0
- package/dist/blocks/ActivityTimeline/buildTimelineRows.js +194 -0
- package/dist/blocks/ActivityTimeline/describeEvent.js +61 -0
- package/dist/blocks/ActivityTimeline/describeGap.js +71 -0
- package/dist/blocks/ActivityTimeline/fillTemplate.js +84 -0
- package/dist/blocks/ActivityTimeline/fillText.js +38 -0
- package/dist/blocks/ActivityTimeline/formatRelativeTime.js +68 -0
- package/dist/blocks/ActivityTimeline/getActor.js +41 -0
- package/dist/blocks/ActivityTimeline/getCommentMenuActions.js +85 -0
- package/dist/blocks/ActivityTimeline/getCommentView.js +72 -0
- package/dist/blocks/ActivityTimeline/getTimelineColors.js +71 -0
- package/dist/blocks/ActivityTimeline/getToneColor.js +49 -0
- package/dist/blocks/ActivityTimeline/getVisibleReplies.js +36 -0
- package/dist/blocks/ActivityTimeline/isThreadShown.js +28 -0
- package/dist/blocks/ActivityTimeline/joinList.js +21 -0
- package/dist/blocks/ActivityTimeline/meta.js +314 -0
- package/dist/blocks/ActivityTimeline/parseTimelineHref.js +43 -0
- package/dist/blocks/ActivityTimeline/selectEventRule.js +69 -0
- package/dist/blocks/ActivityTimeline/summariseEvents.js +51 -0
- package/dist/blocks/ActivityTimeline/toPlainText.js +32 -0
- package/dist/blocks/ActivityTimeline/toTime.js +36 -0
- package/dist/blocks/ActivityTimeline/toTimelineMarkdown.js +57 -0
- package/dist/blocks/ActivityTimeline/toggleReaction.js +74 -0
- package/dist/blocks/ActivityTimeline/useNow.js +24 -0
- package/dist/blocks/AgentChat/AgentChat.js +726 -0
- package/dist/blocks/AgentChat/AssistantMessage.js +243 -0
- package/dist/blocks/AgentChat/ChatComposer.js +401 -0
- package/dist/blocks/AgentChat/ChatError.js +129 -0
- package/dist/blocks/AgentChat/ChatSkeleton.js +97 -0
- package/dist/blocks/AgentChat/ReasoningDisclosure.js +125 -0
- package/dist/blocks/AgentChat/ThinkingIndicator.js +103 -0
- package/dist/blocks/AgentChat/ThreadsSheet.js +347 -0
- package/dist/blocks/AgentChat/ToolApprovalCard.js +190 -0
- package/dist/blocks/AgentChat/ToolCallRow.js +187 -0
- package/dist/blocks/AgentChat/ToolDetail.js +137 -0
- package/dist/blocks/AgentChat/UserMessage.js +84 -0
- package/dist/blocks/AgentChat/WelcomeView.js +100 -0
- package/dist/blocks/AgentChat/createAgentTransport.js +74 -0
- package/dist/blocks/AgentChat/describeToolPart.js +133 -0
- package/dist/blocks/AgentChat/getChatSeed.js +44 -0
- package/dist/blocks/AgentChat/getFirstExchange.js +43 -0
- package/dist/blocks/AgentChat/getMessageSegments.js +73 -0
- package/dist/blocks/AgentChat/getMessageText.js +25 -0
- package/dist/blocks/AgentChat/getPageStateUpdates.js +47 -0
- package/dist/blocks/AgentChat/getProvisionalTitle.js +32 -0
- package/dist/blocks/AgentChat/getReadableRows.js +157 -0
- package/dist/blocks/AgentChat/getThreadEndpoints.js +54 -0
- package/dist/blocks/AgentChat/getToolIcon.js +110 -0
- package/dist/blocks/AgentChat/humanizeToolName.js +30 -0
- package/dist/blocks/AgentChat/messageParts.js +86 -0
- package/dist/blocks/AgentChat/meta.js +530 -0
- package/dist/blocks/AgentChat/mintConversationId.js +29 -0
- package/dist/blocks/AgentChat/replayableMessages.js +62 -0
- package/dist/blocks/AgentChat/showMessageMenu.js +49 -0
- package/dist/blocks/AgentChat/summarizeToolInput.js +36 -0
- package/dist/blocks/AgentChat/summarizeToolOutput.js +49 -0
- package/dist/blocks/AgentChat/useAgentEvents.js +218 -0
- package/dist/blocks/AgentChat/useChatDictation.js +151 -0
- package/dist/blocks/AgentChat/useChatThreads.js +450 -0
- package/dist/blocks/AgentChat/useFollowScroll.js +80 -0
- package/dist/blocks/AgentChat/useThinkingMessage.js +77 -0
- package/dist/blocks/Alert/Alert.js +167 -0
- package/dist/blocks/Alert/meta.js +200 -0
- package/dist/blocks/Avatar/Avatar.js +49 -0
- package/dist/blocks/Avatar/AvatarCircle.js +111 -0
- package/dist/blocks/Avatar/AvatarPhoto.js +70 -0
- package/dist/blocks/Avatar/AvatarStack.js +87 -0
- package/dist/blocks/Avatar/getAvatarColor.js +84 -0
- package/dist/blocks/Avatar/getAvatarImage.js +95 -0
- package/dist/blocks/Avatar/getInitials.js +51 -0
- package/dist/blocks/Avatar/meta.js +57 -0
- package/dist/blocks/Box/Box.js +118 -0
- package/dist/blocks/Box/getRubberBand.js +29 -0
- package/dist/blocks/Box/getSwipeDirection.js +45 -0
- package/dist/blocks/Box/isSwipeGesture.js +41 -0
- package/dist/blocks/Box/meta.js +46 -0
- package/dist/blocks/Box/useSwipeGesture.js +113 -0
- package/dist/blocks/Button/Button.js +136 -0
- package/dist/blocks/Button/getButtonColors.js +216 -0
- package/dist/blocks/Button/meta.js +137 -0
- package/dist/blocks/Card/Card.js +185 -0
- package/dist/blocks/Card/meta.js +203 -0
- package/dist/blocks/ChipSelector/Chip.js +178 -0
- package/dist/blocks/ChipSelector/ChipSelector.js +311 -0
- package/dist/blocks/ChipSelector/EdgeFade.js +68 -0
- package/dist/blocks/ChipSelector/getChipColors.js +88 -0
- package/dist/blocks/ChipSelector/getFadeRanges.js +55 -0
- package/dist/blocks/ChipSelector/getOverscrollSwipe.js +44 -0
- package/dist/blocks/ChipSelector/getScrollTarget.js +41 -0
- package/dist/blocks/ChipSelector/meta.js +156 -0
- package/dist/blocks/Composer/Composer.js +501 -0
- package/dist/blocks/Composer/MentionTextInput.js +91 -0
- package/dist/blocks/Composer/SuggestionList.js +163 -0
- package/dist/blocks/Composer/applyDisplayEdit.js +81 -0
- package/dist/blocks/Composer/convertSpokenMentions.js +234 -0
- package/dist/blocks/Composer/createMentionPattern.js +40 -0
- package/dist/blocks/Composer/findTrigger.js +51 -0
- package/dist/blocks/Composer/getSendState.js +38 -0
- package/dist/blocks/Composer/getSpokenMentionWords.js +35 -0
- package/dist/blocks/Composer/indexSpokenNames.js +50 -0
- package/dist/blocks/Composer/insertLink.js +36 -0
- package/dist/blocks/Composer/insertMention.js +43 -0
- package/dist/blocks/Composer/matchSpokenName.js +88 -0
- package/dist/blocks/Composer/meta.js +212 -0
- package/dist/blocks/Composer/parseMentionValue.js +55 -0
- package/dist/blocks/Composer/placeDictation.js +51 -0
- package/dist/blocks/Composer/rankMentions.js +51 -0
- package/dist/blocks/Composer/replaceRange.js +48 -0
- package/dist/blocks/Composer/segmentText.js +78 -0
- package/dist/blocks/Composer/shiftOffset.js +37 -0
- package/dist/blocks/Composer/snapSelection.js +37 -0
- package/dist/blocks/Composer/useMentionEditor.js +381 -0
- package/dist/blocks/Composer/withPartial.js +50 -0
- package/dist/blocks/DateSelector/DateSelector.js +250 -0
- package/dist/blocks/DateSelector/formatDateValue.js +34 -0
- package/dist/blocks/DateSelector/getDateMenuActions.js +96 -0
- package/dist/blocks/DateSelector/meta.js +109 -0
- package/dist/blocks/DateSelector/toBoundDate.js +40 -0
- package/dist/blocks/DateSelector/toPickerDate.js +31 -0
- package/dist/blocks/DateSelector/toUtcDay.js +25 -0
- package/dist/blocks/Divider/Divider.js +159 -0
- package/dist/blocks/Divider/meta.js +108 -0
- package/dist/blocks/Empty/Empty.js +107 -0
- package/dist/blocks/Empty/meta.js +61 -0
- package/dist/blocks/Icon/Icon.js +41 -0
- package/dist/blocks/Icon/meta.js +80 -0
- package/dist/blocks/Illustration/Illustration.js +154 -0
- package/dist/blocks/Illustration/IllustrationLayer.js +105 -0
- package/dist/blocks/Illustration/colorNodes.js +72 -0
- package/dist/blocks/Illustration/createIllustrationMotion.js +172 -0
- package/dist/blocks/Illustration/getIllustrationBox.js +54 -0
- package/dist/blocks/Illustration/getIllustrationColors.js +48 -0
- package/dist/blocks/Illustration/getKeyframeRange.js +99 -0
- package/dist/blocks/Illustration/getLayerBounds.js +74 -0
- package/dist/blocks/Illustration/getLayers.js +113 -0
- package/dist/blocks/Illustration/getNodePoints.js +210 -0
- package/dist/blocks/Illustration/meta.js +196 -0
- package/dist/blocks/Illustration/parseIllustration.js +84 -0
- package/dist/blocks/Illustration/toBoundingBoxGradients.js +188 -0
- package/dist/blocks/Illustration/useIllustrationMotion.js +75 -0
- package/dist/blocks/Label/Label.js +111 -0
- package/dist/blocks/Label/getLabelProperties.js +38 -0
- package/dist/blocks/Label/getLabelState.js +59 -0
- package/dist/blocks/List/List.js +159 -0
- package/dist/blocks/List/ListRow.js +74 -0
- package/dist/blocks/List/ListRowContext.js +20 -0
- package/dist/blocks/List/SectionHeader.js +119 -0
- package/dist/blocks/List/getSections.js +161 -0
- package/dist/blocks/List/meta.js +190 -0
- package/dist/blocks/ListItem/ListItem.js +418 -0
- package/dist/blocks/ListItem/ListItemContextMenu.js +58 -0
- package/dist/blocks/ListItem/getListItemParts.js +101 -0
- package/dist/blocks/ListItem/getSfSymbol.js +33 -0
- package/dist/blocks/ListItem/meta.js +284 -0
- package/dist/blocks/ListItem/showContextMenuAlert.js +36 -0
- package/dist/blocks/Markdown/ChipWidthContext.js +20 -0
- package/dist/blocks/Markdown/ChipWidthView.js +40 -0
- package/dist/blocks/Markdown/LinkChip.js +151 -0
- package/dist/blocks/Markdown/Markdown.js +42 -0
- package/dist/blocks/Markdown/MarkdownCode.js +67 -0
- package/dist/blocks/Markdown/MarkdownContent.js +101 -0
- package/dist/blocks/Markdown/MarkdownList.js +97 -0
- package/dist/blocks/Markdown/MarkdownListContext.js +22 -0
- package/dist/blocks/Markdown/MarkdownRenderer.js +223 -0
- package/dist/blocks/Markdown/MarkdownTable.js +96 -0
- package/dist/blocks/Markdown/MarkdownTokenizer.js +43 -0
- package/dist/blocks/Markdown/TaskBox.js +58 -0
- package/dist/blocks/Markdown/TaskMark.js +37 -0
- package/dist/blocks/Markdown/getChipMaxWidth.js +33 -0
- package/dist/blocks/Markdown/getLinkChip.js +95 -0
- package/dist/blocks/Markdown/getLinkChipColors.js +51 -0
- package/dist/blocks/Markdown/getListMarker.js +116 -0
- package/dist/blocks/Markdown/getMarkdownStyles.js +206 -0
- package/dist/blocks/Markdown/getNodeText.js +37 -0
- package/dist/blocks/Markdown/layoutLinkChips.js +209 -0
- package/dist/blocks/Markdown/matchLinkChip.js +82 -0
- package/dist/blocks/Markdown/meta.js +50 -0
- package/dist/blocks/Markdown/restyleText.js +40 -0
- package/dist/blocks/Markdown/trimOuterSpace.js +42 -0
- package/dist/blocks/Menu/Menu.js +96 -0
- package/dist/blocks/Menu/getMenuActions.js +66 -0
- package/dist/blocks/Menu/meta.js +159 -0
- package/dist/blocks/MultipleSelector/MultipleSelector.js +288 -0
- package/dist/blocks/MultipleSelector/MultipleSelectorRow.js +71 -0
- package/dist/blocks/MultipleSelector/ValueSummary.js +130 -0
- package/dist/blocks/MultipleSelector/getOptionIndices.js +30 -0
- package/dist/blocks/MultipleSelector/getSessionOptions.js +38 -0
- package/dist/blocks/MultipleSelector/getSummaryCount.js +35 -0
- package/dist/blocks/MultipleSelector/meta.js +284 -0
- package/dist/blocks/MultipleSelector/toggleValue.js +50 -0
- package/dist/blocks/NumberInput/NumberInput.js +251 -0
- package/dist/blocks/NumberInput/StepButton.js +46 -0
- package/dist/blocks/NumberInput/formatNumber.js +35 -0
- package/dist/blocks/NumberInput/getNumberKeyboardType.js +32 -0
- package/dist/blocks/NumberInput/meta.js +123 -0
- package/dist/blocks/NumberInput/normalizeNumber.js +38 -0
- package/dist/blocks/NumberInput/parseNumberText.js +46 -0
- package/dist/blocks/PageDots/PageDots.js +131 -0
- package/dist/blocks/PageDots/meta.js +48 -0
- package/dist/blocks/Paragraph/Paragraph.js +52 -0
- package/dist/blocks/Paragraph/meta.js +295 -0
- package/dist/blocks/Screen/meta.js +197 -0
- package/dist/blocks/SegmentedControl/SegmentedControl.js +75 -0
- package/dist/blocks/SegmentedControl/meta.js +78 -0
- package/dist/blocks/Selector/NoValueAvatar.js +42 -0
- package/dist/blocks/Selector/PickerOptionRow.js +130 -0
- package/dist/blocks/Selector/PickerRowLeading.js +57 -0
- package/dist/blocks/Selector/PickerSearchField.js +85 -0
- package/dist/blocks/Selector/PickerSheet.js +239 -0
- package/dist/blocks/Selector/Selector.js +120 -0
- package/dist/blocks/Selector/SelectorMenu.js +97 -0
- package/dist/blocks/Selector/SelectorRow.js +86 -0
- package/dist/blocks/Selector/SelectorSheet.js +131 -0
- package/dist/blocks/Selector/getOptionIndex.js +39 -0
- package/dist/blocks/Selector/getOptionLabel.js +32 -0
- package/dist/blocks/Selector/getOptionValue.js +20 -0
- package/dist/blocks/Selector/getPickerSheetDetents.js +45 -0
- package/dist/blocks/Selector/getPickerSheetRows.js +174 -0
- package/dist/blocks/Selector/getPickerSheetScrollIndex.js +35 -0
- package/dist/blocks/Selector/getSelectorMenuActions.js +61 -0
- package/dist/blocks/Selector/meta.js +195 -0
- package/dist/blocks/Selector/normalizeSearchText.js +27 -0
- package/dist/blocks/Selector/setSelectorValue.js +52 -0
- package/dist/blocks/Sheet/Sheet.js +174 -0
- package/dist/blocks/Sheet/getSheetDetents.js +56 -0
- package/dist/blocks/Sheet/meta.js +72 -0
- package/dist/blocks/Skeleton/Skeleton.js +131 -0
- package/dist/blocks/Skeleton/SkeletonCard.js +42 -0
- package/dist/blocks/Skeleton/SkeletonHero.js +72 -0
- package/dist/blocks/Skeleton/SkeletonInsetGroup.js +82 -0
- package/dist/blocks/Skeleton/SkeletonListRow.js +90 -0
- package/dist/blocks/Skeleton/SkeletonParagraph.js +36 -0
- package/dist/blocks/Skeleton/SkeletonRows.js +58 -0
- package/dist/blocks/Skeleton/SkeletonTimeline.js +88 -0
- package/dist/blocks/Skeleton/getBarWidth.js +45 -0
- package/dist/blocks/Skeleton/getParagraphWidths.js +56 -0
- package/dist/blocks/Skeleton/getSectionCounts.js +33 -0
- package/dist/blocks/Skeleton/getSkeletonVariant.js +27 -0
- package/dist/blocks/Skeleton/meta.js +98 -0
- package/dist/blocks/Spinner/Spinner.js +68 -0
- package/dist/blocks/Spinner/meta.js +35 -0
- package/dist/blocks/StatusIcon/StatusGlyph.js +247 -0
- package/dist/blocks/StatusIcon/StatusIcon.js +34 -0
- package/dist/blocks/StatusIcon/StatusMark.js +87 -0
- package/dist/blocks/StatusIcon/getPiePath.js +41 -0
- package/dist/blocks/StatusIcon/getStatusColor.js +61 -0
- package/dist/blocks/StatusIcon/meta.js +38 -0
- package/dist/blocks/StatusIcon/statusLabels.js +33 -0
- package/dist/blocks/Switch/Switch.js +83 -0
- package/dist/blocks/Switch/meta.js +78 -0
- package/dist/blocks/Tabs/Tabs.js +269 -0
- package/dist/blocks/Tabs/meta.js +305 -0
- package/dist/blocks/Tag/TONE_PALETTES.js +34 -0
- package/dist/blocks/Tag/Tag.js +173 -0
- package/dist/blocks/Tag/getTagColors.js +120 -0
- package/dist/blocks/Tag/getTagDotColor.js +32 -0
- package/dist/blocks/Tag/meta.js +131 -0
- package/dist/blocks/TextArea/ComposerSendButton.js +69 -0
- package/dist/blocks/TextArea/TextArea.js +167 -0
- package/dist/blocks/TextArea/meta.js +96 -0
- package/dist/blocks/TextInput/TextInput.js +253 -0
- package/dist/blocks/TextInput/applyReplaceInput.js +30 -0
- package/dist/blocks/TextInput/getKeyboardProps.js +64 -0
- package/dist/blocks/TextInput/getSearchBoxStyle.js +39 -0
- package/dist/blocks/TextInput/meta.js +113 -0
- package/dist/blocks/Title/Title.js +62 -0
- package/dist/blocks/Title/meta.js +355 -0
- package/dist/blocks.js +48 -0
- package/dist/dictation.js +17 -0
- package/dist/htmlToText.js +32 -0
- package/dist/metas.js +49 -0
- package/dist/schemas/avatar.js +40 -0
- package/dist/schemas/icon.js +65 -0
- package/dist/schemas/inputLabel.js +96 -0
- package/dist/schemas/inputProperties.js +92 -0
- package/dist/schemas/linkChips.js +85 -0
- package/dist/schemas/status.js +75 -0
- package/dist/schemas/textStyle.js +33 -0
- package/dist/schemas/tone.js +28 -0
- package/dist/shared/ClearButton.js +53 -0
- package/dist/shared/CountText.js +38 -0
- package/dist/shared/NativeMenu.js +66 -0
- package/dist/shared/OptionGlyph.js +58 -0
- package/dist/shared/PropertyRow.js +89 -0
- package/dist/shared/SheetCloseButton.js +51 -0
- package/dist/shared/SheetDoneButton.js +44 -0
- package/dist/shared/SwipeContext.js +20 -0
- package/dist/shared/SwipeableRow.js +292 -0
- package/dist/shared/SystemIcon.js +72 -0
- package/dist/shared/dictation/DictationButton.js +77 -0
- package/dist/shared/dictation/DictationWarning.js +89 -0
- package/dist/shared/dictation/LevelMeter.js +57 -0
- package/dist/shared/dictation/ListeningRow.js +100 -0
- package/dist/shared/dictation/PartialSpans.js +50 -0
- package/dist/shared/dictation/checkDictationAvailable.js +65 -0
- package/dist/shared/dictation/claimMic.js +68 -0
- package/dist/shared/dictation/createQueuedRecognizer.js +213 -0
- package/dist/shared/dictation/getDictationLevel.js +30 -0
- package/dist/shared/dictation/getDictationWarning.js +40 -0
- package/dist/shared/dictation/getLevelBars.js +38 -0
- package/dist/shared/dictation/getRecognizer.js +46 -0
- package/dist/shared/dictation/getStartOptions.js +42 -0
- package/dist/shared/dictation/insertAtSelection.js +48 -0
- package/dist/shared/dictation/pickRecognitionLocale.js +37 -0
- package/dist/shared/dictation/useDictation.js +299 -0
- package/dist/shared/getControlSize.js +50 -0
- package/dist/shared/getInputBoxStyle.js +93 -0
- package/dist/shared/getPropertyRowTextStyles.js +40 -0
- package/dist/shared/getSemanticColors.js +96 -0
- package/dist/shared/getToneColor.js +51 -0
- package/dist/shared/iosTextStyles.js +49 -0
- package/dist/shared/useBlockTokens.js +41 -0
- package/dist/skeleton/SkeletonFrameContext.js +21 -0
- package/dist/skeleton/SkeletonLine.js +46 -0
- package/dist/skeleton/SkeletonShape.js +140 -0
- package/dist/skeleton/createShimmerClock.js +57 -0
- package/dist/skeleton/shimmerClock.js +20 -0
- package/dist/skeleton/skeletonText.js +44 -0
- package/dist/skeleton/useShimmer.js +34 -0
- package/dist/types.js +17 -0
- package/dist/typography/TITLE_LEVEL_STYLES.js +24 -0
- package/dist/typography/TypographyText.js +78 -0
- package/dist/typography/getIosTextStyle.js +33 -0
- package/dist/typography/getTextStyle.js +94 -0
- package/dist/useComponentTokens.js +38 -0
- package/package.json +94 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import Svg, { Circle } from 'react-native-svg';
|
|
17
|
+
/**
|
|
18
|
+
* The avatar of a picker row that stands for no value, such as "Unassigned": an empty dashed
|
|
19
|
+
* circle in the tertiary label colour, as Linear and GitHub draw nobody.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} props
|
|
22
|
+
* @param {string} props.color
|
|
23
|
+
* @param {number} props.size
|
|
24
|
+
* @param {string} [props.testID]
|
|
25
|
+
*/ function NoValueAvatar({ color, size, testID }) {
|
|
26
|
+
const strokeWidth = 1.5;
|
|
27
|
+
return /*#__PURE__*/ React.createElement(Svg, {
|
|
28
|
+
height: size,
|
|
29
|
+
testID: testID,
|
|
30
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
31
|
+
width: size
|
|
32
|
+
}, /*#__PURE__*/ React.createElement(Circle, {
|
|
33
|
+
cx: size / 2,
|
|
34
|
+
cy: size / 2,
|
|
35
|
+
fill: "none",
|
|
36
|
+
r: (size - strokeWidth) / 2,
|
|
37
|
+
stroke: color,
|
|
38
|
+
strokeDasharray: "3 2.5",
|
|
39
|
+
strokeWidth: strokeWidth
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
export default NoValueAvatar;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { Pressable, StyleSheet, Text, View } from 'react-native';
|
|
17
|
+
import { ROW_HEIGHT } from './getPickerSheetDetents.js';
|
|
18
|
+
import iosTextStyles from '../../shared/iosTextStyles.js';
|
|
19
|
+
import PickerRowLeading, { AVATAR_SIZE } from './PickerRowLeading.js';
|
|
20
|
+
import SystemIcon from '../../shared/SystemIcon.js';
|
|
21
|
+
const GAP = 12;
|
|
22
|
+
const PADDING = 16;
|
|
23
|
+
/**
|
|
24
|
+
* One row of a picker sheet, 52pt high: the leading avatar (the option's picture or initials, or
|
|
25
|
+
* the dashed circle of the no-value row) or the option's glyph, the label in body text with the
|
|
26
|
+
* option's description under it in footnote, and a checkmark in the tint colour on a chosen
|
|
27
|
+
* row. The separator under it is inset to the label, or spans the sheet under the pinned group.
|
|
28
|
+
* To a screen reader it is a button, selected when chosen, or in a multiple picker a checkbox,
|
|
29
|
+
* checked when chosen.
|
|
30
|
+
*
|
|
31
|
+
* The row that adds the search text draws its label in the tint colour; while the text is
|
|
32
|
+
* refused, its label is in the tertiary label colour with the refusal under it in the error
|
|
33
|
+
* colour, not dimmed, so the message reads.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} props
|
|
36
|
+
* @param {string} props.blockId
|
|
37
|
+
* @param {Object} props.colors getSemanticColors' colours.
|
|
38
|
+
* @param {Object} props.components
|
|
39
|
+
* @param {boolean} props.isDark
|
|
40
|
+
* @param {boolean} [props.multiple] The row is one of several that can be checked.
|
|
41
|
+
* @param {(row: Object) => void} props.onPick
|
|
42
|
+
* @param {Object} props.row A getPickerSheetRows row.
|
|
43
|
+
* @param {boolean} props.showLeading The list has leading glyphs, so every row keeps their space.
|
|
44
|
+
* @param {Object} props.tokens
|
|
45
|
+
*/ function PickerOptionRow({ blockId, colors, components, isDark, multiple = false, onPick, row, showLeading, tokens }) {
|
|
46
|
+
const labelInset = showLeading ? PADDING + AVATAR_SIZE + GAP : PADDING;
|
|
47
|
+
let labelColor = colors.label;
|
|
48
|
+
if (row.invalid) {
|
|
49
|
+
labelColor = colors.tertiaryLabel;
|
|
50
|
+
} else if (row.create) {
|
|
51
|
+
labelColor = tokens.colorTint;
|
|
52
|
+
}
|
|
53
|
+
return /*#__PURE__*/ React.createElement(Pressable, {
|
|
54
|
+
accessibilityLabel: row.description === null ? row.label : `${row.label}, ${row.description}`,
|
|
55
|
+
accessibilityRole: multiple && !row.create ? 'checkbox' : 'button',
|
|
56
|
+
accessibilityState: multiple && !row.create ? {
|
|
57
|
+
checked: row.selected,
|
|
58
|
+
disabled: row.disabled
|
|
59
|
+
} : {
|
|
60
|
+
disabled: row.disabled,
|
|
61
|
+
selected: row.selected
|
|
62
|
+
},
|
|
63
|
+
disabled: row.disabled,
|
|
64
|
+
onPress: ()=>onPick(row),
|
|
65
|
+
style: ({ pressed })=>({
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
backgroundColor: pressed ? colors.cellPressed : 'transparent',
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
gap: GAP,
|
|
70
|
+
height: ROW_HEIGHT,
|
|
71
|
+
opacity: row.disabled && !row.invalid ? 0.4 : 1,
|
|
72
|
+
paddingHorizontal: PADDING
|
|
73
|
+
}),
|
|
74
|
+
testID: `${blockId}_option_${row.key}`
|
|
75
|
+
}, showLeading ? /*#__PURE__*/ React.createElement(View, {
|
|
76
|
+
style: {
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
height: AVATAR_SIZE,
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
width: AVATAR_SIZE
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/ React.createElement(PickerRowLeading, {
|
|
83
|
+
blockId: blockId,
|
|
84
|
+
colors: colors,
|
|
85
|
+
components: components,
|
|
86
|
+
isDark: isDark,
|
|
87
|
+
row: row,
|
|
88
|
+
tokens: tokens
|
|
89
|
+
})) : null, /*#__PURE__*/ React.createElement(View, {
|
|
90
|
+
style: {
|
|
91
|
+
flex: 1,
|
|
92
|
+
justifyContent: 'center'
|
|
93
|
+
}
|
|
94
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
95
|
+
numberOfLines: 1,
|
|
96
|
+
style: [
|
|
97
|
+
iosTextStyles.body,
|
|
98
|
+
{
|
|
99
|
+
color: labelColor
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}, row.label), row.description === null ? null : /*#__PURE__*/ React.createElement(Text, {
|
|
103
|
+
numberOfLines: 1,
|
|
104
|
+
style: [
|
|
105
|
+
iosTextStyles.footnote,
|
|
106
|
+
{
|
|
107
|
+
color: row.invalid ? tokens.colorError : colors.secondaryLabel
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}, row.description)), row.selected ? /*#__PURE__*/ React.createElement(SystemIcon, {
|
|
111
|
+
color: tokens.colorTint,
|
|
112
|
+
components: components,
|
|
113
|
+
fallback: "Check",
|
|
114
|
+
size: 17,
|
|
115
|
+
symbol: "checkmark",
|
|
116
|
+
testID: `${blockId}_option_${row.key}_check`
|
|
117
|
+
}) : null, row.separator === 'none' ? null : /*#__PURE__*/ React.createElement(View, {
|
|
118
|
+
pointerEvents: "none",
|
|
119
|
+
style: {
|
|
120
|
+
backgroundColor: colors.separator,
|
|
121
|
+
bottom: 0,
|
|
122
|
+
height: StyleSheet.hairlineWidth,
|
|
123
|
+
left: row.separator === 'group' ? 0 : labelInset,
|
|
124
|
+
position: 'absolute',
|
|
125
|
+
right: 0
|
|
126
|
+
},
|
|
127
|
+
testID: `${blockId}_option_${row.key}_separator`
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
export default PickerOptionRow;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
17
|
+
import NoValueAvatar from './NoValueAvatar.js';
|
|
18
|
+
import OptionGlyph from '../../shared/OptionGlyph.js';
|
|
19
|
+
const AVATAR_SIZE = 28;
|
|
20
|
+
const GLYPH_SIZE = 20;
|
|
21
|
+
/**
|
|
22
|
+
* The leading glyph of a picker sheet row: the dashed circle of the row that stands for no
|
|
23
|
+
* value, an option's avatar at 28pt (its picture, or its initials), or its SF Symbol or icon at
|
|
24
|
+
* 20pt. Nothing for an option with none of them.
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} props
|
|
27
|
+
* @param {string} props.blockId
|
|
28
|
+
* @param {Object} props.colors getSemanticColors' colours.
|
|
29
|
+
* @param {Object} props.components
|
|
30
|
+
* @param {boolean} props.isDark
|
|
31
|
+
* @param {Object} props.row A getPickerSheetRows row.
|
|
32
|
+
* @param {Object} props.tokens
|
|
33
|
+
*/ function PickerRowLeading({ blockId, colors, components, isDark, row, tokens }) {
|
|
34
|
+
if (row.noValue) {
|
|
35
|
+
return /*#__PURE__*/ React.createElement(NoValueAvatar, {
|
|
36
|
+
color: colors.tertiaryLabel,
|
|
37
|
+
size: AVATAR_SIZE,
|
|
38
|
+
testID: `${blockId}_option_${row.key}_none`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (row.option === null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/ React.createElement(OptionGlyph, {
|
|
45
|
+
avatar: row.option.avatar,
|
|
46
|
+
color: row.option.iconColor,
|
|
47
|
+
components: components,
|
|
48
|
+
icon: row.option.icon,
|
|
49
|
+
isDark: isDark,
|
|
50
|
+
size: type.isObject(row.option.avatar) ? AVATAR_SIZE : GLYPH_SIZE,
|
|
51
|
+
symbol: row.option.symbol,
|
|
52
|
+
testID: `${blockId}_option_${row.key}_glyph`,
|
|
53
|
+
tokens: tokens
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export { AVATAR_SIZE };
|
|
57
|
+
export default PickerRowLeading;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { TextInput, View } from 'react-native';
|
|
17
|
+
import ClearButton from '../../shared/ClearButton.js';
|
|
18
|
+
import iosTextStyles from '../../shared/iosTextStyles.js';
|
|
19
|
+
import SystemIcon from '../../shared/SystemIcon.js';
|
|
20
|
+
/**
|
|
21
|
+
* The search field at the top of a picker sheet, as iOS draws one: a rounded field in the
|
|
22
|
+
* tertiary fill with a magnifier glyph, its placeholder in the tertiary label colour and a clear
|
|
23
|
+
* button while it holds text.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} props
|
|
26
|
+
* @param {string} props.accessibilityLabel
|
|
27
|
+
* @param {string} props.blockId
|
|
28
|
+
* @param {Object} props.colors getSemanticColors' colours.
|
|
29
|
+
* @param {Object} props.components
|
|
30
|
+
* @param {(text: string) => void} props.onChangeText
|
|
31
|
+
* @param {() => void} props.onFocus
|
|
32
|
+
* @param {() => void} [props.onSubmitEditing] Called when the keyboard's search key is pressed.
|
|
33
|
+
* @param {string} [props.placeholder]
|
|
34
|
+
* @param {Object} props.tokens
|
|
35
|
+
* @param {string} props.value
|
|
36
|
+
*/ function PickerSearchField({ accessibilityLabel, blockId, colors, components, onChangeText, onFocus, onSubmitEditing, placeholder = 'Search', tokens, value }) {
|
|
37
|
+
return /*#__PURE__*/ React.createElement(View, {
|
|
38
|
+
style: {
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
backgroundColor: tokens.colorTertiarySystemFill,
|
|
41
|
+
borderRadius: 10,
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
gap: 6,
|
|
44
|
+
height: 36,
|
|
45
|
+
marginBottom: 8,
|
|
46
|
+
marginHorizontal: 16,
|
|
47
|
+
marginTop: 8,
|
|
48
|
+
paddingHorizontal: 8
|
|
49
|
+
}
|
|
50
|
+
}, /*#__PURE__*/ React.createElement(SystemIcon, {
|
|
51
|
+
color: colors.secondaryLabel,
|
|
52
|
+
components: components,
|
|
53
|
+
fallback: "Search",
|
|
54
|
+
size: 15,
|
|
55
|
+
symbol: "magnifyingglass"
|
|
56
|
+
}), /*#__PURE__*/ React.createElement(TextInput, {
|
|
57
|
+
accessibilityLabel: accessibilityLabel,
|
|
58
|
+
autoCapitalize: "none",
|
|
59
|
+
autoCorrect: false,
|
|
60
|
+
clearButtonMode: "never",
|
|
61
|
+
enterKeyHint: "search",
|
|
62
|
+
onChangeText: onChangeText,
|
|
63
|
+
onFocus: onFocus,
|
|
64
|
+
onSubmitEditing: onSubmitEditing,
|
|
65
|
+
placeholder: placeholder,
|
|
66
|
+
placeholderTextColor: colors.secondaryLabel,
|
|
67
|
+
returnKeyType: "search",
|
|
68
|
+
selectionColor: tokens.colorTint,
|
|
69
|
+
style: {
|
|
70
|
+
color: colors.label,
|
|
71
|
+
flex: 1,
|
|
72
|
+
fontSize: iosTextStyles.body.fontSize,
|
|
73
|
+
height: 36,
|
|
74
|
+
letterSpacing: iosTextStyles.body.letterSpacing,
|
|
75
|
+
padding: 0
|
|
76
|
+
},
|
|
77
|
+
testID: `${blockId}_search`,
|
|
78
|
+
value: value
|
|
79
|
+
}), value === '' ? null : /*#__PURE__*/ React.createElement(ClearButton, {
|
|
80
|
+
blockId: `${blockId}_search`,
|
|
81
|
+
onPress: ()=>onChangeText(''),
|
|
82
|
+
tokens: tokens
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
export default PickerSearchField;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useMemo, useState } from 'react';
|
|
16
|
+
import { FlatList, Keyboard, Platform, Text, View, useWindowDimensions } from 'react-native';
|
|
17
|
+
import { BottomSheet } from '@expo/ui/community/bottom-sheet';
|
|
18
|
+
import { iosColors } from '@lowdefy/client-native';
|
|
19
|
+
import { type } from '@lowdefy/helpers';
|
|
20
|
+
import getPickerSheetDetents, { HEADER_HEIGHT, ROW_HEIGHT } from './getPickerSheetDetents.js';
|
|
21
|
+
import getPickerSheetRows from './getPickerSheetRows.js';
|
|
22
|
+
import getPickerSheetScrollIndex from './getPickerSheetScrollIndex.js';
|
|
23
|
+
import getSemanticColors from '../../shared/getSemanticColors.js';
|
|
24
|
+
import iosTextStyles from '../../shared/iosTextStyles.js';
|
|
25
|
+
import PickerOptionRow from './PickerOptionRow.js';
|
|
26
|
+
import PickerSearchField from './PickerSearchField.js';
|
|
27
|
+
import SheetCloseButton from '../../shared/SheetCloseButton.js';
|
|
28
|
+
import SheetDoneButton from '../../shared/SheetDoneButton.js';
|
|
29
|
+
const CLOSED = -1;
|
|
30
|
+
const MEDIUM = 0;
|
|
31
|
+
const LARGE = 1;
|
|
32
|
+
const DEFAULT_SEARCH_THRESHOLD = 7;
|
|
33
|
+
/**
|
|
34
|
+
* The bottom sheet a Selector or MultipleSelector with `variant: sheet` opens: its title centred
|
|
35
|
+
* in the header with a close button at the right (Done for a sheet that picks several options),
|
|
36
|
+
* a search field while there are more options than `searchThreshold` or new values can be added,
|
|
37
|
+
* and the options as rows (PickerOptionRow), the pinned group first. A short list rests at the
|
|
38
|
+
* medium detent; a long list or one with a search field can be dragged to the large detent,
|
|
39
|
+
* which focusing the search field opens. Its rows mount while it is presented, and the search
|
|
40
|
+
* clears when it is dismissed.
|
|
41
|
+
*
|
|
42
|
+
* Picking a row of a single picker dismisses the keyboard; a multiple picker keeps the keyboard
|
|
43
|
+
* and the search, so several matches can be checked, and clears the search once the add row is
|
|
44
|
+
* picked.
|
|
45
|
+
*
|
|
46
|
+
* As the Sheet block, it keeps the system's background while the app shows the system's colour
|
|
47
|
+
* mode, and takes the theme's elevated background when the app forces the other mode.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} props
|
|
50
|
+
* @param {string} props.blockId
|
|
51
|
+
* @param {Object} props.components
|
|
52
|
+
* @param {{ pattern?: string, message?: string }|null} [props.create] Offer to add the search
|
|
53
|
+
* text as a new value (getPickerSheetRows).
|
|
54
|
+
* @param {number[]} [props.first] Indices of the options listed first.
|
|
55
|
+
* @param {boolean} [props.full] No more options can be chosen.
|
|
56
|
+
* @param {boolean} props.isDark
|
|
57
|
+
* @param {boolean} [props.multiple] The sheet checks several options and closes with Done.
|
|
58
|
+
* @param {boolean} [props.noValue] List the item that stands for no value.
|
|
59
|
+
* @param {() => void} props.onClose Called to close the sheet: by its close or Done button, or
|
|
60
|
+
* once a swipe has dismissed it.
|
|
61
|
+
* @param {(row: Object) => void} props.onPick Called with the picked getPickerSheetRows row.
|
|
62
|
+
* @param {boolean} props.open
|
|
63
|
+
* @param {Array} props.options
|
|
64
|
+
* @param {string} [props.placeholder] The label of the item that stands for no value.
|
|
65
|
+
* @param {number} [props.searchThreshold]
|
|
66
|
+
* @param {number[]} props.selected Indices of the chosen options.
|
|
67
|
+
* @param {string} [props.title] The header title.
|
|
68
|
+
* @param {Object} props.tokens
|
|
69
|
+
*/ function PickerSheet({ blockId, components, create = null, first, full, isDark, multiple = false, noValue, onClose, onPick, open, options, placeholder, searchThreshold = DEFAULT_SEARCH_THRESHOLD, selected, title, tokens }) {
|
|
70
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
71
|
+
const colors = getSemanticColors({
|
|
72
|
+
tokens
|
|
73
|
+
});
|
|
74
|
+
const [detentIndex, setDetentIndex] = useState(MEDIUM);
|
|
75
|
+
const [query, setQuery] = useState('');
|
|
76
|
+
// The rows stay mounted from opening until the sheet has been dismissed, so they do not
|
|
77
|
+
// vanish while it slides away.
|
|
78
|
+
const [presented, setPresented] = useState(false);
|
|
79
|
+
if (open && !presented) {
|
|
80
|
+
setPresented(true);
|
|
81
|
+
}
|
|
82
|
+
// Kept while the colour is unchanged, and the detents are the same arrays each time: iOS's
|
|
83
|
+
// BottomSheet re-applies its presentation modifiers when either prop changes identity, which
|
|
84
|
+
// cancels a touch on the sheet, so a tap soon after a toggle would be lost.
|
|
85
|
+
const backgroundColor = isDark ? iosColors.elevated.dark.colorSystemBackground : tokens.colorSystemBackground;
|
|
86
|
+
const backgroundStyle = useMemo(()=>({
|
|
87
|
+
backgroundColor
|
|
88
|
+
}), [
|
|
89
|
+
backgroundColor
|
|
90
|
+
]);
|
|
91
|
+
const rowParams = {
|
|
92
|
+
create,
|
|
93
|
+
first,
|
|
94
|
+
full,
|
|
95
|
+
noValue,
|
|
96
|
+
options,
|
|
97
|
+
placeholder,
|
|
98
|
+
selected
|
|
99
|
+
};
|
|
100
|
+
const allRows = getPickerSheetRows(rowParams);
|
|
101
|
+
const rows = query === '' ? allRows : getPickerSheetRows({
|
|
102
|
+
...rowParams,
|
|
103
|
+
query
|
|
104
|
+
});
|
|
105
|
+
const searchShown = create !== null || options.length > searchThreshold;
|
|
106
|
+
const pick = (row)=>{
|
|
107
|
+
if (!multiple) {
|
|
108
|
+
Keyboard.dismiss();
|
|
109
|
+
} else if (row.create) {
|
|
110
|
+
setQuery('');
|
|
111
|
+
}
|
|
112
|
+
onPick(row);
|
|
113
|
+
};
|
|
114
|
+
const { snapPoints, resizable } = getPickerSheetDetents({
|
|
115
|
+
platform: Platform.OS,
|
|
116
|
+
rowCount: allRows.length,
|
|
117
|
+
searchShown,
|
|
118
|
+
windowHeight
|
|
119
|
+
});
|
|
120
|
+
const showLeading = options.some((option)=>type.isObject(option) && (type.isObject(option.avatar) || type.isString(option.symbol) || type.isString(option.icon)));
|
|
121
|
+
return /*#__PURE__*/ React.createElement(BottomSheet, {
|
|
122
|
+
backgroundStyle: backgroundStyle,
|
|
123
|
+
enableDynamicSizing: false,
|
|
124
|
+
enablePanDownToClose: true,
|
|
125
|
+
handleComponent: resizable ? undefined : null,
|
|
126
|
+
index: open ? detentIndex : CLOSED,
|
|
127
|
+
onChange: (index)=>{
|
|
128
|
+
if (index >= 0) setDetentIndex(index);
|
|
129
|
+
},
|
|
130
|
+
onClose: ()=>{
|
|
131
|
+
setPresented(false);
|
|
132
|
+
setQuery('');
|
|
133
|
+
setDetentIndex(MEDIUM);
|
|
134
|
+
onClose();
|
|
135
|
+
},
|
|
136
|
+
snapPoints: snapPoints
|
|
137
|
+
}, presented ? /*#__PURE__*/ React.createElement(View, {
|
|
138
|
+
style: {
|
|
139
|
+
flex: 1
|
|
140
|
+
},
|
|
141
|
+
testID: `${blockId}_sheet`
|
|
142
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
143
|
+
style: {
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
flexDirection: 'row',
|
|
146
|
+
minHeight: HEADER_HEIGHT,
|
|
147
|
+
paddingHorizontal: 16
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
150
|
+
style: {
|
|
151
|
+
flex: 1
|
|
152
|
+
}
|
|
153
|
+
}), type.isString(title) ? /*#__PURE__*/ React.createElement(Text, {
|
|
154
|
+
accessibilityRole: "header",
|
|
155
|
+
numberOfLines: 1,
|
|
156
|
+
style: [
|
|
157
|
+
iosTextStyles.headline,
|
|
158
|
+
{
|
|
159
|
+
color: colors.label,
|
|
160
|
+
textAlign: 'center'
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}, title) : null, /*#__PURE__*/ React.createElement(View, {
|
|
164
|
+
style: {
|
|
165
|
+
alignItems: 'flex-end',
|
|
166
|
+
flex: 1
|
|
167
|
+
}
|
|
168
|
+
}, multiple ? /*#__PURE__*/ React.createElement(SheetDoneButton, {
|
|
169
|
+
onPress: onClose,
|
|
170
|
+
testID: `${blockId}_done`,
|
|
171
|
+
tokens: tokens
|
|
172
|
+
}) : /*#__PURE__*/ React.createElement(SheetCloseButton, {
|
|
173
|
+
components: components,
|
|
174
|
+
onPress: onClose,
|
|
175
|
+
testID: `${blockId}_close`,
|
|
176
|
+
tokens: tokens
|
|
177
|
+
}))), searchShown ? /*#__PURE__*/ React.createElement(PickerSearchField, {
|
|
178
|
+
accessibilityLabel: type.isString(title) ? `Search ${title}` : 'Search options',
|
|
179
|
+
blockId: blockId,
|
|
180
|
+
colors: colors,
|
|
181
|
+
components: components,
|
|
182
|
+
onChangeText: setQuery,
|
|
183
|
+
onFocus: ()=>{
|
|
184
|
+
if (resizable) setDetentIndex(LARGE);
|
|
185
|
+
},
|
|
186
|
+
onSubmitEditing: ()=>{
|
|
187
|
+
const createRow = rows.find((row)=>row.create && !row.disabled);
|
|
188
|
+
if (createRow !== undefined) pick(createRow);
|
|
189
|
+
},
|
|
190
|
+
placeholder: create === null ? 'Search' : 'Search or add',
|
|
191
|
+
tokens: tokens,
|
|
192
|
+
value: query
|
|
193
|
+
}) : null, /*#__PURE__*/ React.createElement(FlatList, {
|
|
194
|
+
automaticallyAdjustKeyboardInsets: true,
|
|
195
|
+
contentContainerStyle: {
|
|
196
|
+
paddingBottom: 16
|
|
197
|
+
},
|
|
198
|
+
data: rows,
|
|
199
|
+
getItemLayout: (_, position)=>({
|
|
200
|
+
index: position,
|
|
201
|
+
length: ROW_HEIGHT,
|
|
202
|
+
offset: ROW_HEIGHT * position
|
|
203
|
+
}),
|
|
204
|
+
initialScrollIndex: getPickerSheetScrollIndex({
|
|
205
|
+
searchShown,
|
|
206
|
+
selectedPosition: rows.findIndex((row)=>row.selected),
|
|
207
|
+
windowHeight
|
|
208
|
+
}),
|
|
209
|
+
keyExtractor: (row)=>row.key,
|
|
210
|
+
keyboardDismissMode: "on-drag",
|
|
211
|
+
keyboardShouldPersistTaps: "handled",
|
|
212
|
+
ListEmptyComponent: /*#__PURE__*/ React.createElement(Text, {
|
|
213
|
+
style: [
|
|
214
|
+
iosTextStyles.body,
|
|
215
|
+
{
|
|
216
|
+
color: colors.secondaryLabel,
|
|
217
|
+
paddingTop: 24,
|
|
218
|
+
textAlign: 'center'
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}, "No results"),
|
|
222
|
+
renderItem: ({ item })=>/*#__PURE__*/ React.createElement(PickerOptionRow, {
|
|
223
|
+
blockId: blockId,
|
|
224
|
+
colors: colors,
|
|
225
|
+
components: components,
|
|
226
|
+
isDark: isDark,
|
|
227
|
+
multiple: multiple,
|
|
228
|
+
onPick: pick,
|
|
229
|
+
row: item,
|
|
230
|
+
showLeading: showLeading,
|
|
231
|
+
tokens: tokens
|
|
232
|
+
}),
|
|
233
|
+
style: {
|
|
234
|
+
flex: 1
|
|
235
|
+
},
|
|
236
|
+
testID: `${blockId}_options`
|
|
237
|
+
})) : null);
|
|
238
|
+
}
|
|
239
|
+
export default PickerSheet;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { View } from 'react-native';
|
|
17
|
+
import { Host, Picker } from '@expo/ui';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
import getInputBoxStyle from '../../shared/getInputBoxStyle.js';
|
|
20
|
+
import getLabelProperties from '../Label/getLabelProperties.js';
|
|
21
|
+
import getOptionIndex from './getOptionIndex.js';
|
|
22
|
+
import getOptionLabel from './getOptionLabel.js';
|
|
23
|
+
import getOptionValue from './getOptionValue.js';
|
|
24
|
+
import Label from '../Label/Label.js';
|
|
25
|
+
import meta from './meta.js';
|
|
26
|
+
import SelectorMenu from './SelectorMenu.js';
|
|
27
|
+
import SelectorSheet from './SelectorSheet.js';
|
|
28
|
+
import useBlockTokens from '../../shared/useBlockTokens.js';
|
|
29
|
+
// The picker item that stands for no value: shown while nothing is chosen, and kept when the
|
|
30
|
+
// input can be cleared.
|
|
31
|
+
const NO_VALUE = -1;
|
|
32
|
+
// The picker works on option indices, so an option may hold any value, as on the web.
|
|
33
|
+
// A disabled option is left out of the picker unless it is the one chosen.
|
|
34
|
+
// `variant: menu` draws a property row that opens a native menu instead (SelectorMenu), and
|
|
35
|
+
// `variant: sheet` the same row opening a bottom sheet of the options (SelectorSheet).
|
|
36
|
+
function Selector(props) {
|
|
37
|
+
if (props.properties.variant === 'menu') {
|
|
38
|
+
return /*#__PURE__*/ React.createElement(SelectorMenu, props);
|
|
39
|
+
}
|
|
40
|
+
if (props.properties.variant === 'sheet') {
|
|
41
|
+
return /*#__PURE__*/ React.createElement(SelectorSheet, props);
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/ React.createElement(SelectorPicker, props);
|
|
44
|
+
}
|
|
45
|
+
function SelectorPicker({ blockId, loading, methods, properties, required, styles, validation, value }) {
|
|
46
|
+
const { isDark, tokens } = useBlockTokens({
|
|
47
|
+
properties
|
|
48
|
+
});
|
|
49
|
+
const { accessibilityLabel, labelProperties } = getLabelProperties({
|
|
50
|
+
properties
|
|
51
|
+
});
|
|
52
|
+
const disabled = loading === true || properties.disabled === true;
|
|
53
|
+
const { box } = getInputBoxStyle({
|
|
54
|
+
disabled,
|
|
55
|
+
properties,
|
|
56
|
+
status: validation?.status,
|
|
57
|
+
tokens
|
|
58
|
+
});
|
|
59
|
+
const options = properties.options ?? [];
|
|
60
|
+
const selectedIndex = getOptionIndex({
|
|
61
|
+
options,
|
|
62
|
+
value
|
|
63
|
+
});
|
|
64
|
+
const showNoValue = selectedIndex === null || properties.allowClear !== false;
|
|
65
|
+
const items = options.map((option, index)=>({
|
|
66
|
+
index,
|
|
67
|
+
option
|
|
68
|
+
})).filter(({ index, option })=>!(type.isObject(option) && option.disabled === true) || index === selectedIndex);
|
|
69
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
|
70
|
+
blockId: blockId,
|
|
71
|
+
properties: labelProperties,
|
|
72
|
+
required: required,
|
|
73
|
+
styles: styles,
|
|
74
|
+
tokens: tokens,
|
|
75
|
+
validation: validation
|
|
76
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
77
|
+
accessibilityLabel: accessibilityLabel,
|
|
78
|
+
style: [
|
|
79
|
+
box,
|
|
80
|
+
styles.element
|
|
81
|
+
]
|
|
82
|
+
}, /*#__PURE__*/ React.createElement(Host, {
|
|
83
|
+
colorScheme: isDark ? 'dark' : 'light',
|
|
84
|
+
matchContents: true,
|
|
85
|
+
seedColor: tokens.colorTint
|
|
86
|
+
}, /*#__PURE__*/ React.createElement(Picker, {
|
|
87
|
+
appearance: properties.appearance ?? 'menu',
|
|
88
|
+
enabled: !disabled,
|
|
89
|
+
onValueChange: (index)=>{
|
|
90
|
+
const next = index === NO_VALUE ? null : getOptionValue({
|
|
91
|
+
option: options[index]
|
|
92
|
+
});
|
|
93
|
+
methods.setValue(next);
|
|
94
|
+
methods.triggerEvent({
|
|
95
|
+
name: 'onChange',
|
|
96
|
+
event: {
|
|
97
|
+
value: next
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (index === NO_VALUE) {
|
|
101
|
+
methods.triggerEvent({
|
|
102
|
+
name: 'onClear'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
selectedValue: selectedIndex ?? NO_VALUE,
|
|
107
|
+
testID: `${blockId}_input`
|
|
108
|
+
}, showNoValue ? /*#__PURE__*/ React.createElement(Picker.Item, {
|
|
109
|
+
label: properties.placeholder ?? 'Select item',
|
|
110
|
+
value: NO_VALUE
|
|
111
|
+
}) : null, items.map(({ index, option })=>/*#__PURE__*/ React.createElement(Picker.Item, {
|
|
112
|
+
key: index,
|
|
113
|
+
label: getOptionLabel({
|
|
114
|
+
option
|
|
115
|
+
}),
|
|
116
|
+
value: index
|
|
117
|
+
}))))));
|
|
118
|
+
}
|
|
119
|
+
Selector.meta = meta;
|
|
120
|
+
export default Selector;
|