@lowdefy/blocks-native 0.0.0-stage → 7.2.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 +201 -0
- package/README.md +9 -2
- package/dist/actions/AddCalendarEvent/AddCalendarEvent.js +31 -0
- package/dist/actions/AddCalendarEvent/schema.js +55 -0
- package/dist/actions/AddContact/AddContact.js +24 -0
- package/dist/actions/AddContact/schema.js +49 -0
- package/dist/actions/CancelNotification/CancelNotification.js +23 -0
- package/dist/actions/CancelNotification/schema.js +31 -0
- package/dist/actions/DiscardQueuedRequest/DiscardQueuedRequest.js +23 -0
- package/dist/actions/DiscardQueuedRequest/schema.js +31 -0
- package/dist/actions/GetCalendarEvents/GetCalendarEvents.js +32 -0
- package/dist/actions/GetCalendarEvents/schema.js +35 -0
- package/dist/actions/GetRequestQueue/GetRequestQueue.js +24 -0
- package/dist/actions/GetRequestQueue/schema.js +22 -0
- package/dist/actions/Haptic/Haptic.js +38 -0
- package/dist/actions/Haptic/schema.js +37 -0
- package/dist/actions/KeepAwake/KeepAwake.js +23 -0
- package/dist/actions/KeepAwake/schema.js +28 -0
- package/dist/actions/PickContact/PickContact.js +24 -0
- package/dist/actions/PickContact/schema.js +22 -0
- package/dist/actions/PickFile/PickFile.js +32 -0
- package/dist/actions/PickFile/schema.js +58 -0
- package/dist/actions/PickImage/PickImage.js +32 -0
- package/dist/actions/PickImage/schema.js +76 -0
- package/dist/actions/ReadNfc/ReadNfc.js +24 -0
- package/dist/actions/ReadNfc/schema.js +27 -0
- package/dist/actions/RefreshWidgets/RefreshWidgets.js +24 -0
- package/dist/actions/RefreshWidgets/schema.js +22 -0
- package/dist/actions/RequestNotificationPermission/RequestNotificationPermission.js +24 -0
- package/dist/actions/RequestNotificationPermission/schema.js +22 -0
- package/dist/actions/RetryRequestQueue/RetryRequestQueue.js +24 -0
- package/dist/actions/RetryRequestQueue/schema.js +27 -0
- package/dist/actions/ScanCode/ScanCode.js +24 -0
- package/dist/actions/ScanCode/schema.js +54 -0
- package/dist/actions/ScanDocument/ScanDocument.js +32 -0
- package/dist/actions/ScanDocument/schema.js +57 -0
- package/dist/actions/ScheduleNotification/ScheduleNotification.js +27 -0
- package/dist/actions/ScheduleNotification/schema.js +67 -0
- package/dist/actions/SetBadgeCount/SetBadgeCount.js +27 -0
- package/dist/actions/SetBadgeCount/schema.js +31 -0
- package/dist/actions/SetBrightness/SetBrightness.js +24 -0
- package/dist/actions/SetBrightness/schema.js +33 -0
- package/dist/actions/Share/Share.js +50 -0
- package/dist/actions/Share/schema.js +51 -0
- package/dist/actions/Speak/Speak.js +27 -0
- package/dist/actions/Speak/schema.js +44 -0
- package/dist/actions/StartGeofencing/StartGeofencing.js +29 -0
- package/dist/actions/StartGeofencing/schema.js +63 -0
- package/dist/actions/StartLocationTracking/StartLocationTracking.js +29 -0
- package/dist/actions/StartLocationTracking/schema.js +59 -0
- package/dist/actions/StartRecording/StartRecording.js +23 -0
- package/dist/actions/StartRecording/schema.js +32 -0
- package/dist/actions/StopGeofencing/StopGeofencing.js +23 -0
- package/dist/actions/StopGeofencing/schema.js +22 -0
- package/dist/actions/StopLocationTracking/StopLocationTracking.js +23 -0
- package/dist/actions/StopLocationTracking/schema.js +22 -0
- package/dist/actions/StopRecording/StopRecording.js +37 -0
- package/dist/actions/StopRecording/schema.js +46 -0
- package/dist/actions/StopSpeaking/StopSpeaking.js +23 -0
- package/dist/actions/StopSpeaking/schema.js +22 -0
- package/dist/actions/TakePhoto/TakePhoto.js +31 -0
- package/dist/actions/TakePhoto/schema.js +67 -0
- package/dist/actions/WriteNfc/WriteNfc.js +28 -0
- package/dist/actions/WriteNfc/schema.js +61 -0
- package/dist/actions/uploadFiles.js +51 -0
- package/dist/actions.js +47 -0
- package/dist/blocks/ActivityTimeline/ActivityTimeline.js +507 -0
- package/dist/blocks/ActivityTimeline/CommentBody.js +176 -0
- package/dist/blocks/ActivityTimeline/CommentItem.js +302 -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 +160 -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 +320 -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 +51 -0
- package/dist/blocks/Avatar/AvatarCircle.js +114 -0
- package/dist/blocks/Avatar/AvatarPhoto.js +68 -0
- package/dist/blocks/Avatar/AvatarStack.js +89 -0
- package/dist/blocks/Avatar/getAvatarColor.js +84 -0
- package/dist/blocks/Avatar/getAvatarImage.js +97 -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 +313 -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 +511 -0
- package/dist/blocks/Composer/MentionTextInput.js +91 -0
- package/dist/blocks/Composer/SuggestionList.js +165 -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/FileInput/FileInput.js +253 -0
- package/dist/blocks/FileInput/formatFileSize.js +28 -0
- package/dist/blocks/FileInput/getFileSources.js +48 -0
- package/dist/blocks/FileInput/meta.js +123 -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 +440 -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/Map/Map.js +78 -0
- package/dist/blocks/Map/meta.js +153 -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 +70 -0
- package/dist/blocks/Markdown/MarkdownCode.js +67 -0
- package/dist/blocks/Markdown/MarkdownContent.js +119 -0
- package/dist/blocks/Markdown/MarkdownImage.js +77 -0
- package/dist/blocks/Markdown/MarkdownList.js +97 -0
- package/dist/blocks/Markdown/MarkdownListContext.js +22 -0
- package/dist/blocks/Markdown/MarkdownRenderer.js +231 -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 +56 -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 +290 -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/QRScanner/QRScanner.js +94 -0
- package/dist/blocks/QRScanner/createScanFilter.js +44 -0
- package/dist/blocks/QRScanner/meta.js +80 -0
- package/dist/blocks/Screen/meta.js +197 -0
- package/dist/blocks/SegmentedControl/SegmentedControl.js +77 -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 +122 -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 +54 -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/SignaturePad/SignaturePad.js +182 -0
- package/dist/blocks/SignaturePad/meta.js +74 -0
- package/dist/blocks/SignaturePad/toSignatureValue.js +52 -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 +85 -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 +52 -0
- package/dist/device/getDeviceFeature.js +81 -0
- package/dist/device/playFeedback.js +32 -0
- package/dist/device.js +18 -0
- package/dist/dictation.js +17 -0
- package/dist/htmlToText.js +32 -0
- package/dist/metas.js +53 -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/schemas.js +47 -0
- package/dist/shared/ClearButton.js +53 -0
- package/dist/shared/CountText.js +38 -0
- package/dist/shared/MissingFeature.js +43 -0
- package/dist/shared/NativeMenu.js +69 -0
- package/dist/shared/OptionGlyph.js +59 -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 +294 -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 +23 -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 -3
|
@@ -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,122 @@
|
|
|
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
|
+
import playFeedback from '../../device/playFeedback.js';
|
|
30
|
+
// The picker item that stands for no value: shown while nothing is chosen, and kept when the
|
|
31
|
+
// input can be cleared.
|
|
32
|
+
const NO_VALUE = -1;
|
|
33
|
+
// The picker works on option indices, so an option may hold any value, as on the web.
|
|
34
|
+
// A disabled option is left out of the picker unless it is the one chosen.
|
|
35
|
+
// `variant: menu` draws a property row that opens a native menu instead (SelectorMenu), and
|
|
36
|
+
// `variant: sheet` the same row opening a bottom sheet of the options (SelectorSheet).
|
|
37
|
+
function Selector(props) {
|
|
38
|
+
if (props.properties.variant === 'menu') {
|
|
39
|
+
return /*#__PURE__*/ React.createElement(SelectorMenu, props);
|
|
40
|
+
}
|
|
41
|
+
if (props.properties.variant === 'sheet') {
|
|
42
|
+
return /*#__PURE__*/ React.createElement(SelectorSheet, props);
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/ React.createElement(SelectorPicker, props);
|
|
45
|
+
}
|
|
46
|
+
function SelectorPicker({ blockId, loading, methods, properties, required, styles, validation, value }) {
|
|
47
|
+
const { isDark, tokens } = useBlockTokens({
|
|
48
|
+
properties
|
|
49
|
+
});
|
|
50
|
+
const { accessibilityLabel, labelProperties } = getLabelProperties({
|
|
51
|
+
properties
|
|
52
|
+
});
|
|
53
|
+
const disabled = loading === true || properties.disabled === true;
|
|
54
|
+
const { box } = getInputBoxStyle({
|
|
55
|
+
disabled,
|
|
56
|
+
properties,
|
|
57
|
+
status: validation?.status,
|
|
58
|
+
tokens
|
|
59
|
+
});
|
|
60
|
+
const options = properties.options ?? [];
|
|
61
|
+
const selectedIndex = getOptionIndex({
|
|
62
|
+
options,
|
|
63
|
+
value
|
|
64
|
+
});
|
|
65
|
+
const showNoValue = selectedIndex === null || properties.allowClear !== false;
|
|
66
|
+
const items = options.map((option, index)=>({
|
|
67
|
+
index,
|
|
68
|
+
option
|
|
69
|
+
})).filter(({ index, option })=>!(type.isObject(option) && option.disabled === true) || index === selectedIndex);
|
|
70
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
|
71
|
+
blockId: blockId,
|
|
72
|
+
properties: labelProperties,
|
|
73
|
+
required: required,
|
|
74
|
+
styles: styles,
|
|
75
|
+
tokens: tokens,
|
|
76
|
+
validation: validation
|
|
77
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
78
|
+
accessibilityLabel: accessibilityLabel,
|
|
79
|
+
style: [
|
|
80
|
+
box,
|
|
81
|
+
styles.element
|
|
82
|
+
]
|
|
83
|
+
}, /*#__PURE__*/ React.createElement(Host, {
|
|
84
|
+
colorScheme: isDark ? 'dark' : 'light',
|
|
85
|
+
matchContents: true,
|
|
86
|
+
seedColor: tokens.colorTint
|
|
87
|
+
}, /*#__PURE__*/ React.createElement(Picker, {
|
|
88
|
+
appearance: properties.appearance ?? 'menu',
|
|
89
|
+
enabled: !disabled,
|
|
90
|
+
onValueChange: (index)=>{
|
|
91
|
+
const next = index === NO_VALUE ? null : getOptionValue({
|
|
92
|
+
option: options[index]
|
|
93
|
+
});
|
|
94
|
+
playFeedback();
|
|
95
|
+
methods.setValue(next);
|
|
96
|
+
methods.triggerEvent({
|
|
97
|
+
name: 'onChange',
|
|
98
|
+
event: {
|
|
99
|
+
value: next
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
if (index === NO_VALUE) {
|
|
103
|
+
methods.triggerEvent({
|
|
104
|
+
name: 'onClear'
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
selectedValue: selectedIndex ?? NO_VALUE,
|
|
109
|
+
testID: `${blockId}_input`
|
|
110
|
+
}, showNoValue ? /*#__PURE__*/ React.createElement(Picker.Item, {
|
|
111
|
+
label: properties.placeholder ?? 'Select item',
|
|
112
|
+
value: NO_VALUE
|
|
113
|
+
}) : null, items.map(({ index, option })=>/*#__PURE__*/ React.createElement(Picker.Item, {
|
|
114
|
+
key: index,
|
|
115
|
+
label: getOptionLabel({
|
|
116
|
+
option
|
|
117
|
+
}),
|
|
118
|
+
value: index
|
|
119
|
+
}))))));
|
|
120
|
+
}
|
|
121
|
+
Selector.meta = meta;
|
|
122
|
+
export default Selector;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 getLabelProperties from '../Label/getLabelProperties.js';
|
|
17
|
+
import getLabelState from '../Label/getLabelState.js';
|
|
18
|
+
import getOptionIndex from './getOptionIndex.js';
|
|
19
|
+
import getOptionLabel from './getOptionLabel.js';
|
|
20
|
+
import getSelectorMenuActions, { NO_VALUE_ID } from './getSelectorMenuActions.js';
|
|
21
|
+
import Label from '../Label/Label.js';
|
|
22
|
+
import NativeMenu from '../../shared/NativeMenu.js';
|
|
23
|
+
import SelectorRow from './SelectorRow.js';
|
|
24
|
+
import setSelectorValue from './setSelectorValue.js';
|
|
25
|
+
import useBlockTokens from '../../shared/useBlockTokens.js';
|
|
26
|
+
/**
|
|
27
|
+
* A Selector with `variant: menu`: an iOS Settings-style property row, the title at the left and
|
|
28
|
+
* the chosen option at the right (its icon or avatar, its label and an up-down chevron), that
|
|
29
|
+
* opens a native menu of the options with the chosen one checked. The validation message and
|
|
30
|
+
* extra text show under the row, as the Label draws them.
|
|
31
|
+
*/ function SelectorMenu({ blockId, components, loading, methods, properties, required, styles = {}, validation, value }) {
|
|
32
|
+
const { isDark, tokens } = useBlockTokens({
|
|
33
|
+
properties
|
|
34
|
+
});
|
|
35
|
+
const { accessibilityLabel, labelProperties } = getLabelProperties({
|
|
36
|
+
blockId,
|
|
37
|
+
properties
|
|
38
|
+
});
|
|
39
|
+
const { title } = getLabelState({
|
|
40
|
+
blockId,
|
|
41
|
+
properties: labelProperties
|
|
42
|
+
});
|
|
43
|
+
const options = properties.options ?? [];
|
|
44
|
+
const selectedIndex = getOptionIndex({
|
|
45
|
+
options,
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
const selected = selectedIndex === null ? null : options[selectedIndex];
|
|
49
|
+
const placeholder = properties.placeholder ?? 'Select item';
|
|
50
|
+
const disabled = loading === true || properties.disabled === true;
|
|
51
|
+
return /*#__PURE__*/ React.createElement(Label, {
|
|
52
|
+
blockId: blockId,
|
|
53
|
+
properties: {
|
|
54
|
+
...labelProperties,
|
|
55
|
+
disabled: true
|
|
56
|
+
},
|
|
57
|
+
required: required,
|
|
58
|
+
styles: styles,
|
|
59
|
+
tokens: tokens,
|
|
60
|
+
validation: validation
|
|
61
|
+
}, /*#__PURE__*/ React.createElement(NativeMenu, {
|
|
62
|
+
actions: getSelectorMenuActions({
|
|
63
|
+
allowClear: properties.allowClear !== false,
|
|
64
|
+
options,
|
|
65
|
+
placeholder,
|
|
66
|
+
selectedIndex
|
|
67
|
+
}),
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
fullWidth: true,
|
|
70
|
+
menuTitle: properties.menuTitle,
|
|
71
|
+
onSelect: (id)=>setSelectorValue({
|
|
72
|
+
index: id === NO_VALUE_ID ? null : Number(id),
|
|
73
|
+
methods,
|
|
74
|
+
options,
|
|
75
|
+
selectedIndex
|
|
76
|
+
}),
|
|
77
|
+
testID: `${blockId}_input`
|
|
78
|
+
}, /*#__PURE__*/ React.createElement(SelectorRow, {
|
|
79
|
+
accessibilityLabel: accessibilityLabel,
|
|
80
|
+
accessibilityRole: "button",
|
|
81
|
+
accessibilityValue: {
|
|
82
|
+
text: selected === null ? placeholder : getOptionLabel({
|
|
83
|
+
option: selected
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
blockId: blockId,
|
|
87
|
+
components: components,
|
|
88
|
+
isDark: isDark,
|
|
89
|
+
placeholder: placeholder,
|
|
90
|
+
required: required,
|
|
91
|
+
selected: selected,
|
|
92
|
+
styles: styles,
|
|
93
|
+
title: title,
|
|
94
|
+
tokens: tokens
|
|
95
|
+
})));
|
|
96
|
+
}
|
|
97
|
+
export default SelectorMenu;
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { Text } from 'react-native';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import getOptionLabel from './getOptionLabel.js';
|
|
19
|
+
import getPropertyRowTextStyles from '../../shared/getPropertyRowTextStyles.js';
|
|
20
|
+
import OptionGlyph from '../../shared/OptionGlyph.js';
|
|
21
|
+
import PropertyRow from '../../shared/PropertyRow.js';
|
|
22
|
+
import SystemIcon from '../../shared/SystemIcon.js';
|
|
23
|
+
const GLYPH_SIZE = 20;
|
|
24
|
+
/**
|
|
25
|
+
* The iOS Settings-style property row (PropertyRow) of a Selector with `variant: menu` or
|
|
26
|
+
* `variant: sheet`: the title at the left and the chosen option at the right (its icon or avatar,
|
|
27
|
+
* its label and an up-down chevron), or the placeholder while nothing is chosen. The variant
|
|
28
|
+
* wraps it in what opens its options; the menu variant gives the row itself its accessibility
|
|
29
|
+
* props.
|
|
30
|
+
*
|
|
31
|
+
* @param {Object} props
|
|
32
|
+
* @param {string} [props.accessibilityLabel]
|
|
33
|
+
* @param {string} [props.accessibilityRole]
|
|
34
|
+
* @param {Object} [props.accessibilityValue]
|
|
35
|
+
* @param {string} props.blockId
|
|
36
|
+
* @param {Object} props.components
|
|
37
|
+
* @param {boolean} props.isDark
|
|
38
|
+
* @param {string} props.placeholder
|
|
39
|
+
* @param {boolean} [props.required]
|
|
40
|
+
* @param {*} props.selected The chosen option, or null.
|
|
41
|
+
* @param {Object} props.styles The block's style slots.
|
|
42
|
+
* @param {string} [props.title]
|
|
43
|
+
* @param {Object} props.tokens
|
|
44
|
+
*/ function SelectorRow({ accessibilityLabel, accessibilityRole, accessibilityValue, blockId, components, isDark, placeholder, required, selected, styles, title, tokens }) {
|
|
45
|
+
const text = getPropertyRowTextStyles({
|
|
46
|
+
tokens
|
|
47
|
+
});
|
|
48
|
+
return /*#__PURE__*/ React.createElement(PropertyRow, {
|
|
49
|
+
accessibilityLabel: accessibilityLabel,
|
|
50
|
+
accessibilityRole: accessibilityRole,
|
|
51
|
+
accessibilityValue: accessibilityValue,
|
|
52
|
+
required: required,
|
|
53
|
+
styles: styles,
|
|
54
|
+
testID: `${blockId}_row`,
|
|
55
|
+
title: title,
|
|
56
|
+
tokens: tokens
|
|
57
|
+
}, type.isObject(selected) ? /*#__PURE__*/ React.createElement(OptionGlyph, {
|
|
58
|
+
avatar: selected.avatar,
|
|
59
|
+
color: selected.iconColor,
|
|
60
|
+
components: components,
|
|
61
|
+
icon: selected.icon,
|
|
62
|
+
isDark: isDark,
|
|
63
|
+
symbol: selected.symbol,
|
|
64
|
+
size: GLYPH_SIZE,
|
|
65
|
+
testID: `${blockId}_glyph`,
|
|
66
|
+
tokens: tokens
|
|
67
|
+
}) : null, /*#__PURE__*/ React.createElement(Text, {
|
|
68
|
+
numberOfLines: 1,
|
|
69
|
+
style: [
|
|
70
|
+
text.value,
|
|
71
|
+
{
|
|
72
|
+
flexShrink: 1
|
|
73
|
+
},
|
|
74
|
+
styles.value
|
|
75
|
+
]
|
|
76
|
+
}, selected === null ? placeholder : getOptionLabel({
|
|
77
|
+
option: selected
|
|
78
|
+
})), /*#__PURE__*/ React.createElement(SystemIcon, {
|
|
79
|
+
color: tokens.colorTextTertiary,
|
|
80
|
+
components: components,
|
|
81
|
+
fallback: "ChevronsUpDown",
|
|
82
|
+
size: 13,
|
|
83
|
+
symbol: "chevron.up.chevron.down"
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
export default SelectorRow;
|