@flickfyi/flkr 0.0.182 → 0.0.185
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/dist/{api-client-CAg1b8Bh.js → api-client-nn4U_Vfn.js} +1 -1
- package/dist/{app-DpM5nhb9.js → app-COXGJhrt.js} +3 -3
- package/dist/{bundler-DNrDcqyk.js → bundler-CW4YC73e.js} +4 -2
- package/dist/cli.js +11 -11
- package/dist/{delegate-DcVye0KE.js → delegate-aUVluBjB.js} +2 -2
- package/dist/{generate-B1l1z_FZ.js → generate-BeL1QPDi.js} +1 -1
- package/dist/{preview-Dqn_Tq6K.js → preview-DTVM8Csb.js} +2 -2
- package/dist/{publish-BmDqO1xU.js → publish-BJG-s-w5.js} +4 -4
- package/dist/{pull-CO80DMn8.js → pull-B_Yfjpi2.js} +1 -1
- package/dist/{save-8crfOeo1.js → save-UrfgmK2-.js} +2 -2
- package/dist/{sdk-app-BXWrf_pf.js → sdk-app-BAxznAf9.js} +3 -3
- package/dist/{sdk-deploy-CaEonlvx.js → sdk-deploy-D1wgQxse.js} +3 -3
- package/dist/{sdk-generation-CF8ATbrL.js → sdk-generation-CLQ-QrVM.js} +1 -1
- package/dist/{sdk-project-CKV3U3u9.js → sdk-project-BaO0fqhW.js} +1 -1
- package/dist/{use-auth-B6nwU2rp.js → use-auth-CtM4_BAY.js} +1 -1
- package/node_modules/@flickfyi/biscuit/.turbo/turbo-build.log +4 -4
- package/node_modules/@flickfyi/core/README.md +19 -9
- package/node_modules/@flickfyi/core/dist/chunks/{default-CuxDsQoM.js → default-BTmKidHV.js} +1 -1
- package/node_modules/@flickfyi/core/dist/chunks/{default-BB6YexEH.cjs → default-JhTq5I_y.cjs} +1 -1
- package/node_modules/@flickfyi/core/dist/chunks/{define-CUJRqVKY.cjs → define-BKCRhpuY.cjs} +1 -1
- package/node_modules/@flickfyi/core/dist/chunks/{define-e_VqSs4M.js → define-DZXgUsy7.js} +5 -5
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/kowalski/catalog.js +728 -549
- package/node_modules/@flickfyi/core/dist/kowalski/index.cjs +5 -5
- package/node_modules/@flickfyi/core/dist/kowalski/index.js +4297 -3700
- package/node_modules/@flickfyi/core/dist/kowalski/schemas.cjs +1 -0
- package/node_modules/@flickfyi/core/dist/kowalski/schemas.js +637 -0
- package/node_modules/@flickfyi/core/dist/kowalski-catalog.css +516 -0
- package/node_modules/@flickfyi/core/dist/kowalski.css +10 -0
- package/node_modules/@flickfyi/core/dist/themes/athletic/athletic.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/athletic/athletic.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/compact/compact.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/compact/compact.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/default/default.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/default/default.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/editorial/editorial.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/editorial/editorial.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/handwritten/handwritten.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/handwritten/handwritten.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/index.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/index.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/kids/kids.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/kids/kids.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/rounded/rounded.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/rounded/rounded.js +1 -1
- package/node_modules/@flickfyi/core/dist/themes/technical/technical.cjs +1 -1
- package/node_modules/@flickfyi/core/dist/themes/technical/technical.js +1 -1
- package/node_modules/@flickfyi/core/dist-types/hooks/use-feature-store/index.d.ts +43 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/calculations.d.ts +57 -3
- package/node_modules/@flickfyi/core/dist-types/kowalski/calculator.d.ts +7 -6
- package/node_modules/@flickfyi/core/dist-types/kowalski/catalog.d.cts +524 -809
- package/node_modules/@flickfyi/core/dist-types/kowalski/catalog.d.ts +524 -809
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/bill-split.d.ts +38 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/bookmark.d.ts +48 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/budget.d.ts +39 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/calculator.d.ts +62 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/checklist.d.ts +35 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/color-palette.d.ts +32 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/contact.d.ts +41 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/countdown.d.ts +34 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/event.d.ts +43 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/expense.d.ts +40 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/goal.d.ts +36 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/habit.d.ts +57 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/ledger.d.ts +43 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/note.d.ts +35 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/poll.d.ts +41 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/random-picker.d.ts +69 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/rating.d.ts +33 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/reminder.d.ts +48 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/rotation.d.ts +39 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/scoreboard.d.ts +37 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/shopping-list.d.ts +41 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/task-board.d.ts +39 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/time-zone.d.ts +34 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/timer.d.ts +43 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/trip.d.ts +61 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/components/unit-converter.d.ts +106 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/create-schemas.d.ts +6 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/date-time.d.ts +1 -1
- package/node_modules/@flickfyi/core/dist-types/kowalski/everyday.d.ts +28 -8
- package/node_modules/@flickfyi/core/dist-types/kowalski/feature-schema.d.ts +65 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/format.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/fortune.d.ts +21 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/frame.d.ts +4 -4
- package/node_modules/@flickfyi/core/dist-types/kowalski/index.d.cts +31 -7
- package/node_modules/@flickfyi/core/dist-types/kowalski/index.d.ts +31 -7
- package/node_modules/@flickfyi/core/dist-types/kowalski/lesson.d.ts +89 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/recipe.d.ts +129 -8
- package/node_modules/@flickfyi/core/dist-types/kowalski/schemas.d.cts +4 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/schemas.d.ts +4 -0
- package/node_modules/@flickfyi/core/dist-types/kowalski/time-since.d.ts +34 -0
- package/node_modules/@flickfyi/core/examples/example-metadata.ts +19 -2
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.stories.tsx +25 -6
- package/node_modules/@flickfyi/core/examples/kowalski/bill-split/bill-split.tsx +6 -12
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.stories.tsx +22 -5
- package/node_modules/@flickfyi/core/examples/kowalski/bookmark/bookmark.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.stories.tsx +26 -5
- package/node_modules/@flickfyi/core/examples/kowalski/budget/budget.tsx +6 -21
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.stories.tsx +18 -5
- package/node_modules/@flickfyi/core/examples/kowalski/calculator/calculator.tsx +6 -19
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.stories.tsx +25 -5
- package/node_modules/@flickfyi/core/examples/kowalski/checklist/checklist.tsx +6 -21
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.stories.tsx +19 -6
- package/node_modules/@flickfyi/core/examples/kowalski/color-palette/color-palette.tsx +6 -17
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.stories.tsx +30 -5
- package/node_modules/@flickfyi/core/examples/kowalski/contact/contact.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.stories.tsx +22 -5
- package/node_modules/@flickfyi/core/examples/kowalski/countdown/countdown.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.stories.tsx +23 -5
- package/node_modules/@flickfyi/core/examples/kowalski/event/event.tsx +6 -19
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.stories.tsx +23 -5
- package/node_modules/@flickfyi/core/examples/kowalski/expense/expense.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/fortune/fortune.stories.tsx +61 -0
- package/node_modules/@flickfyi/core/examples/kowalski/fortune/fortune.tsx +11 -0
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.stories.tsx +18 -5
- package/node_modules/@flickfyi/core/examples/kowalski/goal/goal.tsx +3 -19
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.stories.tsx +22 -5
- package/node_modules/@flickfyi/core/examples/kowalski/habit/habit.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.stories.tsx +25 -5
- package/node_modules/@flickfyi/core/examples/kowalski/ledger/ledger.tsx +6 -20
- package/node_modules/@flickfyi/core/examples/kowalski/lesson/lesson.stories.tsx +99 -0
- package/node_modules/@flickfyi/core/examples/kowalski/lesson/lesson.tsx +11 -0
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.stories.tsx +21 -5
- package/node_modules/@flickfyi/core/examples/kowalski/note/note.tsx +3 -17
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.stories.tsx +26 -5
- package/node_modules/@flickfyi/core/examples/kowalski/poll/poll.tsx +3 -21
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.stories.tsx +37 -6
- package/node_modules/@flickfyi/core/examples/kowalski/random-picker/random-picker.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.stories.tsx +18 -5
- package/node_modules/@flickfyi/core/examples/kowalski/rating/rating.tsx +6 -14
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.stories.tsx +117 -5
- package/node_modules/@flickfyi/core/examples/kowalski/recipe/recipe.tsx +6 -115
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.stories.tsx +22 -5
- package/node_modules/@flickfyi/core/examples/kowalski/reminder/reminder.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.stories.tsx +26 -5
- package/node_modules/@flickfyi/core/examples/kowalski/rotation/rotation.tsx +6 -22
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.stories.tsx +26 -5
- package/node_modules/@flickfyi/core/examples/kowalski/scoreboard/scoreboard.tsx +6 -21
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.stories.tsx +28 -6
- package/node_modules/@flickfyi/core/examples/kowalski/shopping-list/shopping-list.tsx +6 -22
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.stories.tsx +27 -6
- package/node_modules/@flickfyi/core/examples/kowalski/task-board/task-board.tsx +6 -22
- package/node_modules/@flickfyi/core/examples/kowalski/time-since/time-since.stories.tsx +33 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-since/time-since.tsx +12 -0
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.stories.tsx +22 -6
- package/node_modules/@flickfyi/core/examples/kowalski/time-zone/time-zone.tsx +6 -17
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.stories.tsx +18 -5
- package/node_modules/@flickfyi/core/examples/kowalski/timer/timer.tsx +6 -18
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.stories.tsx +25 -5
- package/node_modules/@flickfyi/core/examples/kowalski/trip/trip.tsx +3 -21
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.stories.tsx +19 -6
- package/node_modules/@flickfyi/core/examples/kowalski/unit-converter/unit-converter.tsx +6 -19
- package/node_modules/@flickfyi/core/examples/parrott/calculator/calculator.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/calculator/calculator.tsx +2 -13
- package/node_modules/@flickfyi/core/examples/parrott/checklist/checklist.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/checklist/checklist.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/countdown/countdown.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/countdown/countdown.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/counter/counter.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/counter/counter.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/fortune/fortune.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/fortune/fortune.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/grid/grid.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/grid/grid.tsx +4 -9
- package/node_modules/@flickfyi/core/examples/parrott/kale-smoothie/kale-smoothie.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/kale-smoothie/kale-smoothie.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/list/list.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/list/list.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/log/log.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/log/log.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/timed-task/timed-task.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/timed-task/timed-task.tsx +0 -8
- package/node_modules/@flickfyi/core/examples/parrott/timer/timer.stories.tsx +10 -3
- package/node_modules/@flickfyi/core/examples/parrott/timer/timer.tsx +0 -8
- package/node_modules/@flickfyi/core/package.json +16 -3
- package/node_modules/@flickfyi/core/src/{kowalski/use-configured-feature.ts → hooks/use-configured-feature/index.ts} +1 -1
- package/node_modules/@flickfyi/core/src/{kowalski/use-feature-store.ts → hooks/use-feature-store/index.ts} +37 -12
- package/node_modules/@flickfyi/core/src/kowalski/README.md +13 -0
- package/node_modules/@flickfyi/core/src/kowalski/calculations.ts +36 -8
- package/node_modules/@flickfyi/core/src/kowalski/calculator.ts +15 -7
- package/node_modules/@flickfyi/core/src/kowalski/catalog.ts +110 -704
- package/node_modules/@flickfyi/core/src/kowalski/components/bill-split.tsx +284 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/bookmark.tsx +347 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/budget.tsx +169 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/calculator.tsx +202 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/checklist.tsx +119 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/color-palette.tsx +302 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/contact.tsx +247 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/countdown.tsx +173 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/event.tsx +260 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/expense.tsx +257 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/goal.tsx +182 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/habit.tsx +272 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/ledger.tsx +211 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/note.tsx +188 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/poll.tsx +242 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/random-picker.tsx +308 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/rating.tsx +112 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/reminder.tsx +298 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/rotation.tsx +146 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/scoreboard.tsx +139 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/shopping-list.tsx +144 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/task-board.tsx +146 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/time-zone.tsx +240 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/timer.tsx +225 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/trip.tsx +338 -0
- package/node_modules/@flickfyi/core/src/kowalski/components/unit-converter.tsx +285 -0
- package/node_modules/@flickfyi/core/src/kowalski/create-schemas.ts +8 -0
- package/node_modules/@flickfyi/core/src/kowalski/date-time.tsx +1 -1
- package/node_modules/@flickfyi/core/src/kowalski/everyday.tsx +1 -640
- package/node_modules/@flickfyi/core/src/kowalski/feature-schema.ts +84 -0
- package/node_modules/@flickfyi/core/src/kowalski/format.ts +29 -3
- package/node_modules/@flickfyi/core/src/kowalski/fortune.tsx +67 -0
- package/node_modules/@flickfyi/core/src/kowalski/frame.tsx +5 -6
- package/node_modules/@flickfyi/core/src/kowalski/index.ts +31 -22
- package/node_modules/@flickfyi/core/src/kowalski/lesson.tsx +564 -0
- package/node_modules/@flickfyi/core/src/kowalski/recipe.tsx +78 -37
- package/node_modules/@flickfyi/core/src/kowalski/schemas.ts +67 -0
- package/node_modules/@flickfyi/core/src/kowalski/stories/composition.tsx +22 -20
- package/node_modules/@flickfyi/core/src/kowalski/time-since.tsx +145 -0
- package/node_modules/@flickfyi/core/src/molecules/progress/progress.tsx +4 -1
- package/node_modules/@flickfyi/core/src/oklch.ts +1 -6
- package/node_modules/@flickfyi/core/src/parrott/theme.ts +3 -1
- package/node_modules/@flickfyi/core/src/themes/editorial/editorial.ts +6 -1
- package/node_modules/@flickfyi/core/src/themes/palette.ts +5 -5
- package/node_modules/@flickfyi/core/src/themes/stories/composition.tsx +11 -9
- package/node_modules/@flickfyi/core/src/themes/stories/gallery.tsx +7 -11
- package/node_modules/@flickfyi/core/tsgo.bun.lock +7 -7
- package/node_modules/@flickfyi/core/tsgo.package.json +1 -1
- package/package.json +2 -2
- package/node_modules/@flickfyi/core/dist-types/kowalski/clocks.d.ts +0 -4
- package/node_modules/@flickfyi/core/dist-types/kowalski/details.d.ts +0 -7
- package/node_modules/@flickfyi/core/dist-types/kowalski/productivity.d.ts +0 -5
- package/node_modules/@flickfyi/core/dist-types/kowalski/tools.d.ts +0 -7
- package/node_modules/@flickfyi/core/dist-types/kowalski/use-feature-store.d.ts +0 -15
- package/node_modules/@flickfyi/core/src/kowalski/clocks.tsx +0 -464
- package/node_modules/@flickfyi/core/src/kowalski/details.tsx +0 -1387
- package/node_modules/@flickfyi/core/src/kowalski/productivity.tsx +0 -575
- package/node_modules/@flickfyi/core/src/kowalski/tools.tsx +0 -1213
- /package/node_modules/@flickfyi/core/dist-types/{kowalski/use-clock.d.ts → hooks/use-clock/index.d.ts} +0 -0
- /package/node_modules/@flickfyi/core/dist-types/{kowalski/use-configured-feature.d.ts → hooks/use-configured-feature/index.d.ts} +0 -0
- /package/node_modules/@flickfyi/core/src/{kowalski/use-clock.ts → hooks/use-clock/index.ts} +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { Flex, Text } from '@flickfyi/core'
|
|
2
|
+
import { Input } from '@flickfyi/core/atoms'
|
|
3
|
+
import { Field, Segmented, Stat, Stepper } from '@flickfyi/core/molecules'
|
|
4
|
+
import * as stylex from '@stylexjs/stylex'
|
|
5
|
+
import { useEffect, useState } from 'react'
|
|
6
|
+
import { z } from 'zod/v4'
|
|
7
|
+
|
|
8
|
+
import { useConfiguredFeature } from '~/hooks/use-configured-feature'
|
|
9
|
+
import { billShares, formatCurrency } from '~/kowalski/calculations'
|
|
10
|
+
import type { CreateSchemas } from '~/kowalski/create-schemas'
|
|
11
|
+
import { featureFields, store } from '~/kowalski/feature-schema'
|
|
12
|
+
import { format, parseNumberInput, resolveCurrency } from '~/kowalski/format'
|
|
13
|
+
import {
|
|
14
|
+
FeatureAction,
|
|
15
|
+
FeatureField,
|
|
16
|
+
FeatureFrame,
|
|
17
|
+
FeatureNumber,
|
|
18
|
+
FeatureWell,
|
|
19
|
+
layout,
|
|
20
|
+
} from '~/kowalski/frame'
|
|
21
|
+
import { space, text } from '~/themes/scale.stylex'
|
|
22
|
+
import { roles } from '~/themes/shared'
|
|
23
|
+
import { font } from '~/themes/tokens.stylex'
|
|
24
|
+
|
|
25
|
+
const defaultId = 'KowalskiBillSplit'
|
|
26
|
+
const defaultScope = 'private'
|
|
27
|
+
|
|
28
|
+
export const BillSplitData = /* @__PURE__ */ z
|
|
29
|
+
.strictObject({
|
|
30
|
+
currency: z
|
|
31
|
+
.string()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('A three-letter ISO currency code, e.g. "USD" or "EUR". Omit for "USD".'),
|
|
34
|
+
people: z.number().describe('How many people split the bill, e.g. 4.'),
|
|
35
|
+
tipPercent: z
|
|
36
|
+
.number()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Tip as a percentage of the total, e.g. 18. Omit for no tip.'),
|
|
39
|
+
title: z.string().optional().describe('A short heading. Omit for "Split the bill".'),
|
|
40
|
+
total: z.number().describe('The bill total before tip, in the currency, e.g. 84.5.'),
|
|
41
|
+
})
|
|
42
|
+
.describe(
|
|
43
|
+
'Split a bill equally with an optional tip, rounding in the selected currency.'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export type BillSplitData = z.infer<typeof BillSplitData>
|
|
47
|
+
|
|
48
|
+
export const BillSplitProps = z.strictObject({
|
|
49
|
+
data: BillSplitData,
|
|
50
|
+
...featureFields,
|
|
51
|
+
scope: featureFields.scope.default(defaultScope),
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export type BillSplitProps = z.input<typeof BillSplitProps> & {
|
|
55
|
+
style?: stylex.StyleXArray<stylex.StyleXStyles>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const billSplitStoreSchema = store({
|
|
59
|
+
people: z.number().default(1),
|
|
60
|
+
tipPercent: z.number().default(0),
|
|
61
|
+
total: z.number().default(0),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export const createSchemas: CreateSchemas = ({
|
|
65
|
+
id = defaultId,
|
|
66
|
+
scope = defaultScope,
|
|
67
|
+
} = {}) => ({
|
|
68
|
+
[`stores/${scope}/${id}`]: billSplitStoreSchema,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
export function BillSplit({
|
|
72
|
+
data,
|
|
73
|
+
id,
|
|
74
|
+
revision = 0,
|
|
75
|
+
scope = defaultScope,
|
|
76
|
+
style,
|
|
77
|
+
}: BillSplitProps) {
|
|
78
|
+
const schema = billSplitStoreSchema
|
|
79
|
+
const store = useConfiguredFeature({
|
|
80
|
+
name: id ?? defaultId,
|
|
81
|
+
revision,
|
|
82
|
+
schema,
|
|
83
|
+
scope,
|
|
84
|
+
seed: schema.parse({
|
|
85
|
+
people: data.people,
|
|
86
|
+
tipPercent: data.tipPercent,
|
|
87
|
+
total: data.total,
|
|
88
|
+
}),
|
|
89
|
+
})
|
|
90
|
+
const result = billShares(
|
|
91
|
+
store.value.total,
|
|
92
|
+
store.value.people,
|
|
93
|
+
store.value.tipPercent,
|
|
94
|
+
data.currency
|
|
95
|
+
)
|
|
96
|
+
const money = format.formatters.getNumberFormat(format.locale, {
|
|
97
|
+
currency: resolveCurrency(data.currency),
|
|
98
|
+
style: 'currency',
|
|
99
|
+
})
|
|
100
|
+
const billTotal = formatCurrency(store.value.total, data.currency)
|
|
101
|
+
const perPerson = money.format(result.perPerson)
|
|
102
|
+
const subtotal = billShares(store.value.total, 1, 0, data.currency).total
|
|
103
|
+
const tipPresets = [0, 15, 20, 25]
|
|
104
|
+
const [customTipOpen, setCustomTipOpen] = useState(false)
|
|
105
|
+
const [peopleDraft, setPeopleDraft] = useState(
|
|
106
|
+
format.formatNumber(store.value.people, { format: 'integer' })
|
|
107
|
+
)
|
|
108
|
+
const [preservePeopleDraft, setPreservePeopleDraft] = useState<{ text: string }>()
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (preservePeopleDraft === undefined) {
|
|
111
|
+
setPeopleDraft(current =>
|
|
112
|
+
parseNumberInput(current) === store.value.people
|
|
113
|
+
? current
|
|
114
|
+
: format.formatNumber(store.value.people, { format: 'integer' })
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}, [preservePeopleDraft, store.value.people])
|
|
118
|
+
const customTipVisible = customTipOpen || !tipPresets.includes(store.value.tipPercent)
|
|
119
|
+
const peopleValid = isPeopleCount(parseNumberInput(peopleDraft))
|
|
120
|
+
return (
|
|
121
|
+
<FeatureFrame
|
|
122
|
+
style={style}
|
|
123
|
+
onRetry={store.retry}
|
|
124
|
+
notice={store.error}
|
|
125
|
+
component="billSplit"
|
|
126
|
+
title={data.title ?? 'Split the bill'}
|
|
127
|
+
>
|
|
128
|
+
<FeatureField
|
|
129
|
+
component="billSplit"
|
|
130
|
+
label="Bill total"
|
|
131
|
+
value={billTotal}
|
|
132
|
+
ready={store.ready}
|
|
133
|
+
saving={store.saving}
|
|
134
|
+
parseValue={value => parseNumberInput(value, resolveCurrency(data.currency))}
|
|
135
|
+
validate={value => parseNumberInput(value, resolveCurrency(data.currency)) >= 0}
|
|
136
|
+
onChange={(value, onSaved) => {
|
|
137
|
+
store.set(
|
|
138
|
+
{ total: parseNumberInput(value, resolveCurrency(data.currency)) },
|
|
139
|
+
onSaved
|
|
140
|
+
)
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
<Field label="Tip">
|
|
144
|
+
<Segmented
|
|
145
|
+
disabled={!store.ready}
|
|
146
|
+
options={[
|
|
147
|
+
...tipPresets.map(tip => ({
|
|
148
|
+
label: format.formatNumber(tip / 100, { style: 'percent' }),
|
|
149
|
+
value: tip,
|
|
150
|
+
})),
|
|
151
|
+
{ label: 'Custom', value: 'custom' as const },
|
|
152
|
+
]}
|
|
153
|
+
value={customTipVisible ? 'custom' : store.value.tipPercent}
|
|
154
|
+
onChange={tip => {
|
|
155
|
+
setCustomTipOpen(tip === 'custom')
|
|
156
|
+
if (typeof tip === 'number') {
|
|
157
|
+
store.set({ tipPercent: tip })
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
</Field>
|
|
162
|
+
{customTipVisible && (
|
|
163
|
+
<FeatureNumber
|
|
164
|
+
component="billSplit"
|
|
165
|
+
label="Tip percent"
|
|
166
|
+
min={0}
|
|
167
|
+
ready={store.ready}
|
|
168
|
+
saving={store.saving}
|
|
169
|
+
value={store.value.tipPercent}
|
|
170
|
+
onChange={(tipPercent, onSaved) => {
|
|
171
|
+
store.set({ tipPercent }, onSaved)
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
175
|
+
<Field error={!peopleValid && 'Choose 1–1,000 people.'} label="People">
|
|
176
|
+
<Stepper
|
|
177
|
+
decrementDisabled={!store.ready || store.value.people <= 1}
|
|
178
|
+
decrementLabel="Fewer people"
|
|
179
|
+
incrementDisabled={!store.ready}
|
|
180
|
+
incrementLabel="More people"
|
|
181
|
+
onDecrement={() => {
|
|
182
|
+
setPreservePeopleDraft(undefined)
|
|
183
|
+
store.set(current => ({ people: Math.max(1, current.people - 1) }))
|
|
184
|
+
}}
|
|
185
|
+
onIncrement={() => {
|
|
186
|
+
setPreservePeopleDraft(undefined)
|
|
187
|
+
store.set(current => ({ people: current.people + 1 }))
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
{store.ready ? (
|
|
191
|
+
<Input
|
|
192
|
+
placeholder="People"
|
|
193
|
+
value={peopleDraft}
|
|
194
|
+
onChange={text => {
|
|
195
|
+
setPeopleDraft(text)
|
|
196
|
+
const edit = { text }
|
|
197
|
+
setPreservePeopleDraft(edit)
|
|
198
|
+
if (isPeopleCount(parseNumberInput(text))) {
|
|
199
|
+
store.set({ people: parseNumberInput(text) }, () =>
|
|
200
|
+
setPreservePeopleDraft(current =>
|
|
201
|
+
current === edit ? undefined : current
|
|
202
|
+
)
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
}}
|
|
206
|
+
style={[layout.input, layout.stepperInput]}
|
|
207
|
+
/>
|
|
208
|
+
) : (
|
|
209
|
+
<Text {...stylex.props(roles.text, layout.stepperInput)}>
|
|
210
|
+
{format.formatNumber(store.value.people, { format: 'integer' })}
|
|
211
|
+
</Text>
|
|
212
|
+
)}
|
|
213
|
+
</Stepper>
|
|
214
|
+
{store.ready &&
|
|
215
|
+
peopleValid &&
|
|
216
|
+
preservePeopleDraft !== undefined &&
|
|
217
|
+
!store.saving && (
|
|
218
|
+
<FeatureAction
|
|
219
|
+
component="billSplit"
|
|
220
|
+
onClick={() =>
|
|
221
|
+
store.set({ people: parseNumberInput(peopleDraft) }, () =>
|
|
222
|
+
setPreservePeopleDraft(current =>
|
|
223
|
+
current === preservePeopleDraft ? undefined : current
|
|
224
|
+
)
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
>
|
|
228
|
+
Retry people
|
|
229
|
+
</FeatureAction>
|
|
230
|
+
)}
|
|
231
|
+
</Field>
|
|
232
|
+
<FeatureWell>
|
|
233
|
+
<Stat>
|
|
234
|
+
<Stat.Value style={billStyles.amount(perPerson.length)}>{perPerson}</Stat.Value>
|
|
235
|
+
<Stat.Caption>Per person</Stat.Caption>
|
|
236
|
+
</Stat>
|
|
237
|
+
{result.remainder > 0 && (
|
|
238
|
+
<Text {...stylex.props(roles.muted, billStyles.centered)}>
|
|
239
|
+
{`One person pays ${money.format(result.perPerson + result.remainder)} — ${money.format(result.remainder)} extra to cover rounding.`}
|
|
240
|
+
</Text>
|
|
241
|
+
)}
|
|
242
|
+
{store.value.tipPercent > 0 && (
|
|
243
|
+
<Flex {...stylex.props(billStyles.row)}>
|
|
244
|
+
<Text
|
|
245
|
+
{...stylex.props(roles.muted)}
|
|
246
|
+
>{`Tip (${format.formatNumber(store.value.tipPercent, { format: 'decimal', style: 'unit', unit: 'percent', unitDisplay: 'narrow' })})`}</Text>
|
|
247
|
+
<Text {...stylex.props(roles.text)}>
|
|
248
|
+
{money.format(result.total - subtotal)}
|
|
249
|
+
</Text>
|
|
250
|
+
</Flex>
|
|
251
|
+
)}
|
|
252
|
+
<Flex {...stylex.props(billStyles.row)}>
|
|
253
|
+
<Text {...stylex.props(roles.strong)}>Total with tip</Text>
|
|
254
|
+
<Text {...stylex.props(roles.strong)}>{money.format(result.total)}</Text>
|
|
255
|
+
</Flex>
|
|
256
|
+
</FeatureWell>
|
|
257
|
+
</FeatureFrame>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Long totals step down the display scale so they never overflow the well.
|
|
262
|
+
const billStyles = /* @__PURE__ */ stylex.create({
|
|
263
|
+
amount: (length: number) => ({
|
|
264
|
+
fontSize: length > 16 ? text.lg : length > 9 ? text['4xl'] : font.displaySize,
|
|
265
|
+
lineHeight:
|
|
266
|
+
length > 16
|
|
267
|
+
? text.lgLeading
|
|
268
|
+
: length > 9
|
|
269
|
+
? text['4xlLeading']
|
|
270
|
+
: font.displayLeading,
|
|
271
|
+
}),
|
|
272
|
+
centered: { textAlign: 'center' },
|
|
273
|
+
row: {
|
|
274
|
+
alignItems: 'center',
|
|
275
|
+
flexDirection: 'row',
|
|
276
|
+
flexWrap: 'wrap',
|
|
277
|
+
gap: space[2],
|
|
278
|
+
justifyContent: 'space-between',
|
|
279
|
+
},
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
function isPeopleCount(value: number) {
|
|
283
|
+
return Number.isInteger(value) && value >= 1
|
|
284
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { Flex, Icon, Text } from '@flickfyi/core'
|
|
2
|
+
import { Button as NativeButton, Input } from '@flickfyi/core/atoms'
|
|
3
|
+
import * as stylex from '@stylexjs/stylex'
|
|
4
|
+
import { toArray } from 'lodash'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
import isURL from 'validator/lib/isURL.js'
|
|
7
|
+
import { z } from 'zod/v4'
|
|
8
|
+
|
|
9
|
+
import { useConfiguredFeature } from '~/hooks/use-configured-feature'
|
|
10
|
+
import type { CreateSchemas } from '~/kowalski/create-schemas'
|
|
11
|
+
import { featureFields, replacement, store } from '~/kowalski/feature-schema'
|
|
12
|
+
import { FeatureAction, FeatureEdit, FeatureFrame, layout } from '~/kowalski/frame'
|
|
13
|
+
import { size, space, text } from '~/themes/scale.stylex'
|
|
14
|
+
import { appearance, button, roles } from '~/themes/shared'
|
|
15
|
+
|
|
16
|
+
export const webAddressOptions = {
|
|
17
|
+
max_allowed_length: 2048,
|
|
18
|
+
protocols: ['http', 'https'],
|
|
19
|
+
require_host: true,
|
|
20
|
+
require_protocol: true,
|
|
21
|
+
require_tld: false,
|
|
22
|
+
require_valid_protocol: true,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const defaultId = 'KowalskiBookmark'
|
|
26
|
+
const defaultScope = 'private'
|
|
27
|
+
|
|
28
|
+
export const BookmarkData = /* @__PURE__ */ z
|
|
29
|
+
.strictObject({
|
|
30
|
+
note: z.string().optional().describe('A short note about the link. Omit for none.'),
|
|
31
|
+
title: z.string().describe('A short heading.'),
|
|
32
|
+
url: z
|
|
33
|
+
.string()
|
|
34
|
+
.describe('The full http or https address, e.g. "https://example.com".'),
|
|
35
|
+
})
|
|
36
|
+
.describe('Display, edit, and retain a web bookmark. No implicit metadata fetch.')
|
|
37
|
+
|
|
38
|
+
export type BookmarkData = z.infer<typeof BookmarkData>
|
|
39
|
+
|
|
40
|
+
export const BookmarkProps = z.strictObject({
|
|
41
|
+
data: BookmarkData,
|
|
42
|
+
...featureFields,
|
|
43
|
+
scope: featureFields.scope.default(defaultScope),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
export type BookmarkProps = z.input<typeof BookmarkProps> & {
|
|
47
|
+
style?: stylex.StyleXArray<stylex.StyleXStyles>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const bookmarkStoreSchema = store({
|
|
51
|
+
note: replacement(z.string().default('')),
|
|
52
|
+
title: replacement(z.string().default('')),
|
|
53
|
+
url: replacement(z.string().nullable().default(null)),
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
export const createSchemas: CreateSchemas = ({
|
|
57
|
+
id = defaultId,
|
|
58
|
+
scope = defaultScope,
|
|
59
|
+
} = {}) => ({
|
|
60
|
+
[`stores/${scope}/${id}`]: bookmarkStoreSchema,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
export function Bookmark({
|
|
64
|
+
data,
|
|
65
|
+
id,
|
|
66
|
+
revision = 0,
|
|
67
|
+
scope = defaultScope,
|
|
68
|
+
style,
|
|
69
|
+
}: BookmarkProps) {
|
|
70
|
+
const schema = bookmarkStoreSchema
|
|
71
|
+
const store = useConfiguredFeature({
|
|
72
|
+
name: id ?? defaultId,
|
|
73
|
+
revision,
|
|
74
|
+
schema,
|
|
75
|
+
scope,
|
|
76
|
+
seed: schema.parse({
|
|
77
|
+
note: { value: data.note },
|
|
78
|
+
title: { value: data.title },
|
|
79
|
+
url: { value: data.url },
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
82
|
+
const [draft, setDraft] = useState({ note: '', title: '', url: '' })
|
|
83
|
+
const [baseline, setBaseline] = useState<typeof draft | null>(null)
|
|
84
|
+
const [showAddress, setShowAddress] = useState(false)
|
|
85
|
+
const [showFullNote, setShowFullNote] = useState(false)
|
|
86
|
+
const editing = baseline !== null
|
|
87
|
+
const domain = (store.value.url.value ?? '')
|
|
88
|
+
.replace(/^https?:\/\//i, '')
|
|
89
|
+
.split(/[/?#]/)[0]
|
|
90
|
+
?.split('@')
|
|
91
|
+
.pop()
|
|
92
|
+
?.replace(/^www\./i, '')
|
|
93
|
+
const title = store.value.title.value.trim()
|
|
94
|
+
? store.value.title.value
|
|
95
|
+
: domain || 'Untitled bookmark'
|
|
96
|
+
const note = store.value.note.value
|
|
97
|
+
const noteCharacters = toArray(note)
|
|
98
|
+
const longNote = noteCharacters.length > 360
|
|
99
|
+
const valid = {
|
|
100
|
+
note: true,
|
|
101
|
+
title: true,
|
|
102
|
+
url: isURL(draft.url, { ...webAddressOptions }),
|
|
103
|
+
}
|
|
104
|
+
const changed =
|
|
105
|
+
baseline &&
|
|
106
|
+
(draft.note !== baseline.note ||
|
|
107
|
+
draft.title !== baseline.title ||
|
|
108
|
+
draft.url !== baseline.url)
|
|
109
|
+
function editBookmark() {
|
|
110
|
+
if (!store.ready || store.saving) {
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
const values = {
|
|
114
|
+
note: store.value.note.value,
|
|
115
|
+
title: store.value.title.value,
|
|
116
|
+
url: store.value.url.value ?? '',
|
|
117
|
+
}
|
|
118
|
+
setDraft(values)
|
|
119
|
+
setBaseline(values)
|
|
120
|
+
}
|
|
121
|
+
return (
|
|
122
|
+
<FeatureFrame
|
|
123
|
+
style={style}
|
|
124
|
+
onRetry={store.retry}
|
|
125
|
+
notice={store.error}
|
|
126
|
+
component="bookmark"
|
|
127
|
+
title={title}
|
|
128
|
+
detail={domain || 'No web address'}
|
|
129
|
+
trailing={
|
|
130
|
+
!editing && (
|
|
131
|
+
<FeatureEdit
|
|
132
|
+
disabled={!store.ready || store.saving}
|
|
133
|
+
label="Edit bookmark"
|
|
134
|
+
onClick={editBookmark}
|
|
135
|
+
/>
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
>
|
|
139
|
+
{editing ? (
|
|
140
|
+
<Flex {...stylex.props(bookmarkStyles.editor)}>
|
|
141
|
+
{store.saving && <Text {...stylex.props(roles.muted)}>Saving changes…</Text>}
|
|
142
|
+
{(
|
|
143
|
+
[
|
|
144
|
+
{ key: 'title', label: 'Title', message: '' },
|
|
145
|
+
{
|
|
146
|
+
key: 'url',
|
|
147
|
+
label: 'Web address',
|
|
148
|
+
message: 'Use a valid address starting with https:// or http://.',
|
|
149
|
+
},
|
|
150
|
+
{ key: 'note', label: 'Note', message: '' },
|
|
151
|
+
] as const
|
|
152
|
+
).map(field => (
|
|
153
|
+
<Flex key={field.key} {...stylex.props(layout.field)}>
|
|
154
|
+
<Flex {...stylex.props(bookmarkStyles.fieldLabel)}>
|
|
155
|
+
<Text {...stylex.props(roles.label, layout.fieldLabel)}>
|
|
156
|
+
{field.label}
|
|
157
|
+
</Text>
|
|
158
|
+
{field.key !== 'url' && (
|
|
159
|
+
<Text {...stylex.props(roles.muted, bookmarkStyles.caption)}>
|
|
160
|
+
Optional
|
|
161
|
+
</Text>
|
|
162
|
+
)}
|
|
163
|
+
</Flex>
|
|
164
|
+
{store.saving ? (
|
|
165
|
+
<Text
|
|
166
|
+
{...stylex.props(
|
|
167
|
+
roles.text,
|
|
168
|
+
appearance.surface,
|
|
169
|
+
layout.input,
|
|
170
|
+
bookmarkStyles.submittedValue
|
|
171
|
+
)}
|
|
172
|
+
>
|
|
173
|
+
{draft[field.key] || (field.key === 'note' ? 'No note' : 'No title')}
|
|
174
|
+
</Text>
|
|
175
|
+
) : (
|
|
176
|
+
<Input
|
|
177
|
+
multiline={field.key === 'note'}
|
|
178
|
+
placeholder={field.label}
|
|
179
|
+
value={draft[field.key]}
|
|
180
|
+
onChange={value =>
|
|
181
|
+
setDraft(current => ({ ...current, [field.key]: value }))
|
|
182
|
+
}
|
|
183
|
+
style={[layout.input, field.key === 'note' && layout.multiline]}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
{!valid[field.key] && (
|
|
187
|
+
<Text {...stylex.props(roles.muted)}>{field.message}</Text>
|
|
188
|
+
)}
|
|
189
|
+
</Flex>
|
|
190
|
+
))}
|
|
191
|
+
<Flex {...stylex.props(layout.actions)}>
|
|
192
|
+
<FeatureAction
|
|
193
|
+
component="bookmark"
|
|
194
|
+
disabled={store.saving}
|
|
195
|
+
onClick={() => setBaseline(null)}
|
|
196
|
+
>
|
|
197
|
+
Cancel
|
|
198
|
+
</FeatureAction>
|
|
199
|
+
<FeatureAction
|
|
200
|
+
component="bookmark"
|
|
201
|
+
disabled={
|
|
202
|
+
store.saving ||
|
|
203
|
+
!store.ready ||
|
|
204
|
+
!changed ||
|
|
205
|
+
!valid.title ||
|
|
206
|
+
!valid.url ||
|
|
207
|
+
!valid.note
|
|
208
|
+
}
|
|
209
|
+
onClick={() => {
|
|
210
|
+
if (
|
|
211
|
+
!store.ready ||
|
|
212
|
+
store.saving ||
|
|
213
|
+
!baseline ||
|
|
214
|
+
!changed ||
|
|
215
|
+
!valid.title ||
|
|
216
|
+
!valid.url ||
|
|
217
|
+
!valid.note
|
|
218
|
+
) {
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
store.set(
|
|
222
|
+
current => ({
|
|
223
|
+
...(draft.title !== baseline.title &&
|
|
224
|
+
draft.title !== current.title.value && {
|
|
225
|
+
title: { value: draft.title },
|
|
226
|
+
}),
|
|
227
|
+
...(draft.url !== baseline.url &&
|
|
228
|
+
draft.url !== (current.url.value ?? '') && {
|
|
229
|
+
url: { value: draft.url || null },
|
|
230
|
+
}),
|
|
231
|
+
...(draft.note !== baseline.note &&
|
|
232
|
+
draft.note !== current.note.value && {
|
|
233
|
+
note: { value: draft.note },
|
|
234
|
+
}),
|
|
235
|
+
}),
|
|
236
|
+
() => setBaseline(null)
|
|
237
|
+
)
|
|
238
|
+
}}
|
|
239
|
+
variant="primary"
|
|
240
|
+
>
|
|
241
|
+
{store.saving ? 'Saving…' : 'Save changes'}
|
|
242
|
+
</FeatureAction>
|
|
243
|
+
</Flex>
|
|
244
|
+
</Flex>
|
|
245
|
+
) : (
|
|
246
|
+
<Flex {...stylex.props(bookmarkStyles.details)}>
|
|
247
|
+
{store.saving ? (
|
|
248
|
+
<Text {...stylex.props(roles.muted)}>Saving changes…</Text>
|
|
249
|
+
) : !store.ready && !store.error ? (
|
|
250
|
+
<Text {...stylex.props(roles.muted)}>Loading bookmark…</Text>
|
|
251
|
+
) : null}
|
|
252
|
+
<Flex {...stylex.props(bookmarkStyles.note)}>
|
|
253
|
+
{note && (
|
|
254
|
+
<Text {...stylex.props(roles.text, bookmarkStyles.noteText)}>
|
|
255
|
+
{longNote && !showFullNote
|
|
256
|
+
? `${noteCharacters.slice(0, 360).join('')}…`
|
|
257
|
+
: note}
|
|
258
|
+
</Text>
|
|
259
|
+
)}
|
|
260
|
+
{longNote && (
|
|
261
|
+
<FeatureAction
|
|
262
|
+
component="bookmark"
|
|
263
|
+
onClick={() => setShowFullNote(current => !current)}
|
|
264
|
+
variant="quiet"
|
|
265
|
+
>
|
|
266
|
+
{showFullNote ? 'Show less' : 'Read full note'}
|
|
267
|
+
</FeatureAction>
|
|
268
|
+
)}
|
|
269
|
+
{!note && (
|
|
270
|
+
<FeatureAction
|
|
271
|
+
component="bookmark"
|
|
272
|
+
disabled={!store.ready || store.saving}
|
|
273
|
+
icon="plus"
|
|
274
|
+
onClick={editBookmark}
|
|
275
|
+
variant="quiet"
|
|
276
|
+
>
|
|
277
|
+
Add a note
|
|
278
|
+
</FeatureAction>
|
|
279
|
+
)}
|
|
280
|
+
</Flex>
|
|
281
|
+
{store.value.url.value && (
|
|
282
|
+
<Flex {...stylex.props(bookmarkStyles.address)}>
|
|
283
|
+
<NativeButton
|
|
284
|
+
onClick={() => setShowAddress(current => !current)}
|
|
285
|
+
style={[button.quiet, bookmarkStyles.addressButton]}
|
|
286
|
+
>
|
|
287
|
+
<Flex {...stylex.props(bookmarkStyles.addressRow)}>
|
|
288
|
+
<Text {...stylex.props(roles.strong, bookmarkStyles.caption)}>
|
|
289
|
+
{showAddress ? 'Hide web address' : 'Show web address'}
|
|
290
|
+
</Text>
|
|
291
|
+
<Icon
|
|
292
|
+
name={showAddress ? 'chevron.up' : 'chevron.down'}
|
|
293
|
+
{...stylex.props(roles.muted, bookmarkStyles.chevron)}
|
|
294
|
+
/>
|
|
295
|
+
</Flex>
|
|
296
|
+
</NativeButton>
|
|
297
|
+
{showAddress && (
|
|
298
|
+
<Flex {...stylex.props(appearance.surface, bookmarkStyles.addressValue)}>
|
|
299
|
+
<Text {...stylex.props(roles.muted, bookmarkStyles.caption)}>
|
|
300
|
+
{store.value.url.value}
|
|
301
|
+
</Text>
|
|
302
|
+
</Flex>
|
|
303
|
+
)}
|
|
304
|
+
</Flex>
|
|
305
|
+
)}
|
|
306
|
+
{store.value.url.value && (
|
|
307
|
+
<NativeButton
|
|
308
|
+
accessibilityLabel={`Open ${title}`}
|
|
309
|
+
disabled={!store.ready || store.saving}
|
|
310
|
+
href={store.value.url.value}
|
|
311
|
+
style={[button.primary, button.lg, layout.action]}
|
|
312
|
+
>
|
|
313
|
+
<Flex {...stylex.props(layout.actionContent)}>
|
|
314
|
+
<Icon name="arrow.up.right" />
|
|
315
|
+
<Text>Open link</Text>
|
|
316
|
+
</Flex>
|
|
317
|
+
</NativeButton>
|
|
318
|
+
)}
|
|
319
|
+
</Flex>
|
|
320
|
+
)}
|
|
321
|
+
</FeatureFrame>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const bookmarkStyles = /* @__PURE__ */ stylex.create({
|
|
326
|
+
address: { gap: space[1], minWidth: size[0.5] },
|
|
327
|
+
addressButton: { padding: `${space[2]} 0`, textAlign: 'left' },
|
|
328
|
+
addressRow: {
|
|
329
|
+
alignItems: 'center',
|
|
330
|
+
flexDirection: 'row',
|
|
331
|
+
gap: space[3],
|
|
332
|
+
justifyContent: 'space-between',
|
|
333
|
+
},
|
|
334
|
+
addressValue: { minWidth: size[0.5], padding: `${space[3]} ${space[3.5]}` },
|
|
335
|
+
caption: { fontSize: text['sm'] },
|
|
336
|
+
chevron: { fontSize: text['xs'], fontWeight: '600' },
|
|
337
|
+
details: { gap: space[4] },
|
|
338
|
+
editor: { gap: space[5] },
|
|
339
|
+
fieldLabel: {
|
|
340
|
+
alignItems: 'center',
|
|
341
|
+
flexDirection: 'row',
|
|
342
|
+
justifyContent: 'space-between',
|
|
343
|
+
},
|
|
344
|
+
note: { gap: space[3] },
|
|
345
|
+
noteText: { lineHeight: '1.6' },
|
|
346
|
+
submittedValue: { minWidth: size[0.5] },
|
|
347
|
+
})
|