@lowdefy/blocks-native 0.0.0-stage → 7.3.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,172 @@
|
|
|
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 { Animated } from 'react-native';
|
|
16
|
+
import getKeyframeRange from './getKeyframeRange.js';
|
|
17
|
+
const TRANSFORMS = [
|
|
18
|
+
'translateX',
|
|
19
|
+
'translateY',
|
|
20
|
+
'rotate',
|
|
21
|
+
'scale',
|
|
22
|
+
'scaleX',
|
|
23
|
+
'scaleY'
|
|
24
|
+
];
|
|
25
|
+
const ADDED = new Set([
|
|
26
|
+
'translateX',
|
|
27
|
+
'translateY',
|
|
28
|
+
'rotate'
|
|
29
|
+
]);
|
|
30
|
+
const TRANSLATES = new Set([
|
|
31
|
+
'translateX',
|
|
32
|
+
'translateY'
|
|
33
|
+
]);
|
|
34
|
+
function getClock({ animation, clocks }) {
|
|
35
|
+
const delay = animation.delay ?? 0;
|
|
36
|
+
const loop = animation.loop ?? true;
|
|
37
|
+
const key = `${animation.duration}|${delay}|${loop}`;
|
|
38
|
+
if (clocks[key] === undefined) {
|
|
39
|
+
clocks[key] = {
|
|
40
|
+
delay,
|
|
41
|
+
duration: animation.duration,
|
|
42
|
+
loop,
|
|
43
|
+
value: new Animated.Value(0)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return clocks[key];
|
|
47
|
+
}
|
|
48
|
+
// One animation's value along its clock. Translations are in the drawing's units, so they are
|
|
49
|
+
// scaled to points.
|
|
50
|
+
function getAnimatedValue({ animation, clock, scale }) {
|
|
51
|
+
const { inputRange, outputRange } = getKeyframeRange({
|
|
52
|
+
easing: animation.easing,
|
|
53
|
+
keyframes: animation.keyframes
|
|
54
|
+
});
|
|
55
|
+
return clock.value.interpolate({
|
|
56
|
+
extrapolate: 'clamp',
|
|
57
|
+
inputRange,
|
|
58
|
+
outputRange: TRANSLATES.has(animation.property) ? outputRange.map((value)=>value * scale) : outputRange
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// The animations of one target and property as one value: translations and rotations add up,
|
|
62
|
+
// scales and opacities multiply.
|
|
63
|
+
function combine({ property, values }) {
|
|
64
|
+
return values.reduce((total, value)=>ADDED.has(property) ? Animated.add(total, value) : Animated.multiply(total, value));
|
|
65
|
+
}
|
|
66
|
+
function getOrigin({ animations, scale, viewBox }) {
|
|
67
|
+
const [minX, minY, width, height] = viewBox;
|
|
68
|
+
const origin = animations.find((animation)=>animation.origin !== undefined)?.origin ?? [
|
|
69
|
+
minX + width / 2,
|
|
70
|
+
minY + height / 2
|
|
71
|
+
];
|
|
72
|
+
return [
|
|
73
|
+
(origin[0] - minX) * scale,
|
|
74
|
+
(origin[1] - minY) * scale,
|
|
75
|
+
0
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function getTargetStyle({ animations, scale, values, viewBox }) {
|
|
79
|
+
const style = {};
|
|
80
|
+
if (values.opacity !== undefined) {
|
|
81
|
+
style.opacity = combine({
|
|
82
|
+
property: 'opacity',
|
|
83
|
+
values: values.opacity
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const transform = [];
|
|
87
|
+
TRANSFORMS.forEach((property)=>{
|
|
88
|
+
if (values[property] === undefined) return;
|
|
89
|
+
const value = combine({
|
|
90
|
+
property,
|
|
91
|
+
values: values[property]
|
|
92
|
+
});
|
|
93
|
+
if (property === 'rotate') {
|
|
94
|
+
transform.push({
|
|
95
|
+
rotate: value.interpolate({
|
|
96
|
+
extrapolate: 'extend',
|
|
97
|
+
inputRange: [
|
|
98
|
+
0,
|
|
99
|
+
360
|
|
100
|
+
],
|
|
101
|
+
outputRange: [
|
|
102
|
+
'0deg',
|
|
103
|
+
'360deg'
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
transform.push({
|
|
110
|
+
[property]: value
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
if (transform.length > 0) {
|
|
114
|
+
style.transform = transform;
|
|
115
|
+
style.transformOrigin = getOrigin({
|
|
116
|
+
animations,
|
|
117
|
+
scale,
|
|
118
|
+
viewBox
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return style;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* An Illustration's animations as Animated values for the native driver. Animations that share a
|
|
125
|
+
* duration, delay and loop share one clock (an Animated.Value from 0 to 1 over the duration), so
|
|
126
|
+
* frames that swap on the same keyframe swap on the same frame.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} params
|
|
129
|
+
* @param {Object[]} params.animations The block's animations.
|
|
130
|
+
* @param {number} params.scale Points per unit of the drawing.
|
|
131
|
+
* @param {number[]} params.viewBox The drawing's `[minX, minY, width, height]`.
|
|
132
|
+
* @returns {{ clocks: Object[], styles: Object }} The clocks to run (`{ delay, duration, loop,
|
|
133
|
+
* value }`), and a view style per target id: its `opacity`, its `transform` (translateX,
|
|
134
|
+
* translateY, rotate, scale, scaleX and scaleY, in that order) and the `transformOrigin` they
|
|
135
|
+
* turn and scale about, in points within the drawing.
|
|
136
|
+
*/ function createIllustrationMotion({ animations, scale, viewBox }) {
|
|
137
|
+
const clocks = {};
|
|
138
|
+
const byTarget = {};
|
|
139
|
+
animations.forEach((animation)=>{
|
|
140
|
+
const clock = getClock({
|
|
141
|
+
animation,
|
|
142
|
+
clocks
|
|
143
|
+
});
|
|
144
|
+
const target = byTarget[animation.target] ?? {
|
|
145
|
+
animations: [],
|
|
146
|
+
values: {}
|
|
147
|
+
};
|
|
148
|
+
target.animations.push(animation);
|
|
149
|
+
target.values[animation.property] = [
|
|
150
|
+
...target.values[animation.property] ?? [],
|
|
151
|
+
getAnimatedValue({
|
|
152
|
+
animation,
|
|
153
|
+
clock,
|
|
154
|
+
scale
|
|
155
|
+
})
|
|
156
|
+
];
|
|
157
|
+
byTarget[animation.target] = target;
|
|
158
|
+
});
|
|
159
|
+
const styles = {};
|
|
160
|
+
Object.keys(byTarget).forEach((id)=>{
|
|
161
|
+
styles[id] = getTargetStyle({
|
|
162
|
+
...byTarget[id],
|
|
163
|
+
scale,
|
|
164
|
+
viewBox
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
clocks: Object.values(clocks),
|
|
169
|
+
styles
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export default createIllustrationMotion;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
/**
|
|
17
|
+
* Where an Illustration draws its viewBox in its box: scaled to fit whole and centred, as SVG's
|
|
18
|
+
* default `xMidYMid meet`. A box with only a width or a height takes the other from the
|
|
19
|
+
* viewBox's aspect ratio, and one with neither is the viewBox's size in points.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} params
|
|
22
|
+
* @param {number[]} params.viewBox `[minX, minY, width, height]`.
|
|
23
|
+
* @param {number} [params.width] The box width in points.
|
|
24
|
+
* @param {number} [params.height] The box height in points.
|
|
25
|
+
* @returns {{ width: number, height: number, scale: number, drawing: Object }} The box size,
|
|
26
|
+
* points per unit of the drawing, and the drawing's `{ left, top, width, height }` in the box.
|
|
27
|
+
*/ function getIllustrationBox({ height, viewBox, width }) {
|
|
28
|
+
const [, , viewWidth, viewHeight] = viewBox;
|
|
29
|
+
let boxWidth = width;
|
|
30
|
+
let boxHeight = height;
|
|
31
|
+
if (type.isNone(boxWidth) && type.isNone(boxHeight)) {
|
|
32
|
+
boxWidth = viewWidth;
|
|
33
|
+
boxHeight = viewHeight;
|
|
34
|
+
} else if (type.isNone(boxHeight)) {
|
|
35
|
+
boxHeight = boxWidth * viewHeight / viewWidth;
|
|
36
|
+
} else if (type.isNone(boxWidth)) {
|
|
37
|
+
boxWidth = boxHeight * viewWidth / viewHeight;
|
|
38
|
+
}
|
|
39
|
+
const scale = Math.min(boxWidth / viewWidth, boxHeight / viewHeight);
|
|
40
|
+
const drawingWidth = viewWidth * scale;
|
|
41
|
+
const drawingHeight = viewHeight * scale;
|
|
42
|
+
return {
|
|
43
|
+
drawing: {
|
|
44
|
+
height: drawingHeight,
|
|
45
|
+
left: (boxWidth - drawingWidth) / 2,
|
|
46
|
+
top: (boxHeight - drawingHeight) / 2,
|
|
47
|
+
width: drawingWidth
|
|
48
|
+
},
|
|
49
|
+
height: boxHeight,
|
|
50
|
+
scale,
|
|
51
|
+
width: boxWidth
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export default getIllustrationBox;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { resolveColor } from '@lowdefy/client-native';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
17
|
+
/**
|
|
18
|
+
* The colours an Illustration's `var(--name)` references take in the mode showing: the theme's
|
|
19
|
+
* colour tokens (`var(--colorPrimary)`), then the block's `colors`, then in dark mode its
|
|
20
|
+
* `colorsDark` over them. Each configured colour is a palette hue, a theme token or a CSS
|
|
21
|
+
* colour (resolveColor).
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} params
|
|
24
|
+
* @param {Object} [params.colors] Colours by name.
|
|
25
|
+
* @param {Object} [params.colorsDark] Colours by name in dark mode.
|
|
26
|
+
* @param {boolean} params.isDark Whether dark mode is showing.
|
|
27
|
+
* @param {Object} params.tokens The theme tokens of the mode showing.
|
|
28
|
+
* @returns {Object} Colours by name.
|
|
29
|
+
*/ function getIllustrationColors({ colors = {}, colorsDark = {}, isDark, tokens }) {
|
|
30
|
+
const configured = isDark ? {
|
|
31
|
+
...colors,
|
|
32
|
+
...colorsDark
|
|
33
|
+
} : colors;
|
|
34
|
+
const resolved = {};
|
|
35
|
+
Object.keys(tokens).forEach((name)=>{
|
|
36
|
+
if (type.isString(tokens[name])) {
|
|
37
|
+
resolved[name] = tokens[name];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.keys(configured).forEach((name)=>{
|
|
41
|
+
resolved[name] = resolveColor({
|
|
42
|
+
color: configured[name],
|
|
43
|
+
tokens
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
export default getIllustrationColors;
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { Easing } from 'react-native';
|
|
16
|
+
const EASINGS = {
|
|
17
|
+
ease: Easing.ease,
|
|
18
|
+
easeIn: Easing.in(Easing.ease),
|
|
19
|
+
easeInOut: Easing.inOut(Easing.ease),
|
|
20
|
+
easeOut: Easing.out(Easing.ease)
|
|
21
|
+
};
|
|
22
|
+
// Points an eased segment is sampled at, so the native driver's linear interpolation follows the
|
|
23
|
+
// curve closely.
|
|
24
|
+
const SAMPLES = 12;
|
|
25
|
+
// How long before the next keyframe a step holds its value, as a fraction of the cycle.
|
|
26
|
+
const STEP_HOLD = 0.0001;
|
|
27
|
+
// The least an input point may follow the one before it.
|
|
28
|
+
const MIN_GAP = 0.000001;
|
|
29
|
+
function createRange() {
|
|
30
|
+
const inputRange = [];
|
|
31
|
+
const outputRange = [];
|
|
32
|
+
function push(at, value) {
|
|
33
|
+
const last = inputRange[inputRange.length - 1];
|
|
34
|
+
inputRange.push(last === undefined ? at : Math.max(at, last + MIN_GAP));
|
|
35
|
+
outputRange.push(value);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
inputRange,
|
|
39
|
+
outputRange,
|
|
40
|
+
push
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An animation's keyframes as an interpolation of its clock, which runs from 0 to 1 over each
|
|
45
|
+
* cycle: the native driver interpolates linearly between points, so an eased segment is
|
|
46
|
+
* sampled into points along its curve, and a step holds its value until the next keyframe and
|
|
47
|
+
* jumps there. Keyframes are sorted by `at`; the first value holds from 0 and the last until 1.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} params
|
|
50
|
+
* @param {Object[]} params.keyframes `[{ at, value, easing }]`: `at` from 0 to 1 of the cycle, and
|
|
51
|
+
* the easing from this keyframe to the next.
|
|
52
|
+
* @param {string} [params.easing] The easing of segments whose keyframe sets none: `linear`,
|
|
53
|
+
* `ease`, `easeIn`, `easeOut`, `easeInOut` (the default) or `step`.
|
|
54
|
+
* @returns {{ inputRange: number[], outputRange: number[] }}
|
|
55
|
+
*/ function getKeyframeRange({ easing = 'easeInOut', keyframes }) {
|
|
56
|
+
const sorted = [
|
|
57
|
+
...keyframes
|
|
58
|
+
].sort((a, b)=>a.at - b.at);
|
|
59
|
+
const first = sorted[0];
|
|
60
|
+
const last = sorted[sorted.length - 1];
|
|
61
|
+
const frames = [
|
|
62
|
+
...first.at > 0 ? [
|
|
63
|
+
{
|
|
64
|
+
at: 0,
|
|
65
|
+
value: first.value
|
|
66
|
+
}
|
|
67
|
+
] : [],
|
|
68
|
+
...sorted,
|
|
69
|
+
...last.at < 1 ? [
|
|
70
|
+
{
|
|
71
|
+
at: 1,
|
|
72
|
+
value: last.value
|
|
73
|
+
}
|
|
74
|
+
] : []
|
|
75
|
+
];
|
|
76
|
+
const range = createRange();
|
|
77
|
+
range.push(frames[0].at, frames[0].value);
|
|
78
|
+
for(let index = 1; index < frames.length; index += 1){
|
|
79
|
+
const from = frames[index - 1];
|
|
80
|
+
const to = frames[index];
|
|
81
|
+
const segmentEasing = from.easing ?? easing;
|
|
82
|
+
const span = to.at - from.at;
|
|
83
|
+
if (segmentEasing === 'step' && span > 0) {
|
|
84
|
+
range.push(to.at - Math.min(STEP_HOLD, span / 2), from.value);
|
|
85
|
+
}
|
|
86
|
+
if (EASINGS[segmentEasing] !== undefined && span > 0) {
|
|
87
|
+
for(let sample = 1; sample < SAMPLES; sample += 1){
|
|
88
|
+
const t = sample / SAMPLES;
|
|
89
|
+
range.push(from.at + span * t, from.value + (to.value - from.value) * EASINGS[segmentEasing](t));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
range.push(to.at, to.value);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
inputRange: range.inputRange,
|
|
96
|
+
outputRange: range.outputRange
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export default getKeyframeRange;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
import getNodePoints from './getNodePoints.js';
|
|
17
|
+
function strokeOf(node) {
|
|
18
|
+
if (type.isNone(node.props.stroke) || node.props.stroke === 'none') {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
return type.isNumber(node.props.strokeWidth) ? node.props.strokeWidth : 1;
|
|
22
|
+
}
|
|
23
|
+
function widestStroke(nodes) {
|
|
24
|
+
return nodes.reduce((widest, node)=>{
|
|
25
|
+
if (typeof node === 'string') return widest;
|
|
26
|
+
return Math.max(widest, strokeOf(node), widestStroke(node.children));
|
|
27
|
+
}, 0);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The part of the viewBox a drawn layer (getLayers) draws in, so its SVG view is only that big: a
|
|
31
|
+
* view's backing store is its size, and a drawing split into many layers would otherwise hold a
|
|
32
|
+
* whole-drawing store for each. The bounds hold every point the layer's shapes name (a path's
|
|
33
|
+
* control points included), half the widest stroke and a unit of margin, rounded out to whole
|
|
34
|
+
* units and kept within the viewBox. Null, for the whole viewBox, when the layer has a transform,
|
|
35
|
+
* an arc, text, an image, a use or a size it cannot read.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} params
|
|
38
|
+
* @param {Object} params.layer A drawn layer, `{ ancestors, nodes }`.
|
|
39
|
+
* @param {number[]} params.viewBox `[minX, minY, width, height]`.
|
|
40
|
+
* @returns {number[]|null} `[x, y, width, height]` in the drawing's units, or null.
|
|
41
|
+
*/ function getLayerBounds({ layer, viewBox }) {
|
|
42
|
+
if (layer.ancestors.some((ancestor)=>!type.isNone(ancestor.props.transform))) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const points = [];
|
|
46
|
+
for (const node of layer.nodes){
|
|
47
|
+
if (typeof node === 'string') continue;
|
|
48
|
+
if (!type.isNone(node.props.transform)) return null;
|
|
49
|
+
const found = getNodePoints({
|
|
50
|
+
node
|
|
51
|
+
});
|
|
52
|
+
if (found === null) return null;
|
|
53
|
+
points.push(...found);
|
|
54
|
+
}
|
|
55
|
+
if (points.length === 0) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const pad = Math.max(...layer.ancestors.map(strokeOf), widestStroke(layer.nodes)) / 2 + 1;
|
|
59
|
+
const [minX, minY, width, height] = viewBox;
|
|
60
|
+
const left = Math.max(minX, Math.floor(Math.min(...points.map((point)=>point[0])) - pad));
|
|
61
|
+
const top = Math.max(minY, Math.floor(Math.min(...points.map((point)=>point[1])) - pad));
|
|
62
|
+
const right = Math.min(minX + width, Math.ceil(Math.max(...points.map((point)=>point[0])) + pad));
|
|
63
|
+
const bottom = Math.min(minY + height, Math.ceil(Math.max(...points.map((point)=>point[1])) + pad));
|
|
64
|
+
if (right <= left || bottom <= top) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return [
|
|
68
|
+
left,
|
|
69
|
+
top,
|
|
70
|
+
right - left,
|
|
71
|
+
bottom - top
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
export default getLayerBounds;
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
*/ function isTarget({ node, targets }) {
|
|
16
|
+
return typeof node !== 'string' && targets.has(node.props.id);
|
|
17
|
+
}
|
|
18
|
+
function holdsTarget({ node, targets }) {
|
|
19
|
+
if (typeof node === 'string' || node.tag !== 'g') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return node.children.some((child)=>isTarget({
|
|
23
|
+
node: child,
|
|
24
|
+
targets
|
|
25
|
+
}) || holdsTarget({
|
|
26
|
+
node: child,
|
|
27
|
+
targets
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Splits a drawing into the layers it is drawn as, in paint order, so each animated element is
|
|
32
|
+
* a view of its own that the native driver moves: React Native's native driver animates a view's
|
|
33
|
+
* transform and opacity, not an SVG element's attributes.
|
|
34
|
+
*
|
|
35
|
+
* - A drawn layer, `{ ancestors, nodes }`: neighbouring elements with no animated element among
|
|
36
|
+
* them, drawn in one SVG inside their ancestor groups (whose transforms, fills and strokes
|
|
37
|
+
* they keep).
|
|
38
|
+
* - An animated layer, `{ target, layers }`: the element whose id an animation targets, drawn in
|
|
39
|
+
* its own view, its own layers inside it. A group holding animated elements is split around
|
|
40
|
+
* them, so an animated element inside an animated group moves with the group.
|
|
41
|
+
*
|
|
42
|
+
* Only groups (`g`) are looked into for animated elements.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} params
|
|
45
|
+
* @param {Array} params.nodes Parsed nodes, in paint order.
|
|
46
|
+
* @param {Set<string>} params.targets The element ids animations target.
|
|
47
|
+
* @param {Object[]} [params.ancestors] The groups the nodes sit in.
|
|
48
|
+
* @returns {Object[]} The layers.
|
|
49
|
+
*/ function getLayers({ ancestors = [], nodes, targets }) {
|
|
50
|
+
const layers = [];
|
|
51
|
+
let fragment = [];
|
|
52
|
+
function flush() {
|
|
53
|
+
if (fragment.length > 0) {
|
|
54
|
+
layers.push({
|
|
55
|
+
ancestors,
|
|
56
|
+
nodes: fragment
|
|
57
|
+
});
|
|
58
|
+
fragment = [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
nodes.forEach((node)=>{
|
|
62
|
+
if (typeof node === 'string') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (isTarget({
|
|
66
|
+
node,
|
|
67
|
+
targets
|
|
68
|
+
})) {
|
|
69
|
+
flush();
|
|
70
|
+
layers.push({
|
|
71
|
+
target: node.props.id,
|
|
72
|
+
layers: holdsTarget({
|
|
73
|
+
node,
|
|
74
|
+
targets
|
|
75
|
+
}) ? getLayers({
|
|
76
|
+
ancestors: [
|
|
77
|
+
...ancestors,
|
|
78
|
+
node
|
|
79
|
+
],
|
|
80
|
+
nodes: node.children,
|
|
81
|
+
targets
|
|
82
|
+
}) : [
|
|
83
|
+
{
|
|
84
|
+
ancestors,
|
|
85
|
+
nodes: [
|
|
86
|
+
node
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (holdsTarget({
|
|
94
|
+
node,
|
|
95
|
+
targets
|
|
96
|
+
})) {
|
|
97
|
+
flush();
|
|
98
|
+
layers.push(...getLayers({
|
|
99
|
+
ancestors: [
|
|
100
|
+
...ancestors,
|
|
101
|
+
node
|
|
102
|
+
],
|
|
103
|
+
nodes: node.children,
|
|
104
|
+
targets
|
|
105
|
+
}));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
fragment.push(node);
|
|
109
|
+
});
|
|
110
|
+
flush();
|
|
111
|
+
return layers;
|
|
112
|
+
}
|
|
113
|
+
export default getLayers;
|