git.iko.soy/rowtype-yoga/purescript-floating-ui
on main help sign in
9 files changed+241
since splitsnapshots
unifiedsplit
.gitignore+10 LICENSE+16 README.md+2 package.json+12 packages.dhall+105 spago.dhall+14 src/FloatingUI/FloatingUI.js+9 src/FloatingUI/FloatingUI.purs+62 test/Main.purs+11
.gitignorenew file+10
@@ -0,0 +1,10 @@
1+/bower_components/
2+/node_modules/
3+/.pulp-cache/
4+/output/
5+/generated-docs/
6+/.psc-package/
7+/.psc*
8+/.purs*
9+/.psa*
10+/.spago
LICENSEnew file+16
@@ -0,0 +1,16 @@
1+MIT No Attribution
2+
3+Copyright 2021 Betalyra Sociedade Unipessoal Lda
4+
5+Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+software and associated documentation files (the "Software"), to deal in the Software
7+without restriction, including without limitation the rights to use, copy, modify,
8+merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
9+permit persons to whom the Software is furnished to do so.
10+
11+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
15+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md+2
@@ -1 +1,3 @@
11# purescript-floating-ui
2+
3+Purescript FFI bindings for [floating ui](https://floating-ui.com/).
package.jsonnew file+12
@@ -0,0 +1,12 @@
1+{
2+ "name": "purescript-floating-ui",
3+ "version": "1.0.0",
4+ "description": "",
5+ "main": "index.js",
6+ "scripts": {
7+ "test": "echo \"Error: no test specified\" && exit 1"
8+ },
9+ "keywords": [],
10+ "author": "",
11+ "license": "ISC"
12+}
packages.dhallnew file+105
@@ -0,0 +1,105 @@
1+{-
2+Welcome to your new Dhall package-set!
3+
4+Below are instructions for how to edit this file for most use
5+cases, so that you don't need to know Dhall to use it.
6+
7+## Use Cases
8+
9+Most will want to do one or both of these options:
10+1. Override/Patch a package's dependency
11+2. Add a package not already in the default package set
12+
13+This file will continue to work whether you use one or both options.
14+Instructions for each option are explained below.
15+
16+### Overriding/Patching a package
17+
18+Purpose:
19+- Change a package's dependency to a newer/older release than the
20+ default package set's release
21+- Use your own modified version of some dependency that may
22+ include new API, changed API, removed API by
23+ using your custom git repo of the library rather than
24+ the package set's repo
25+
26+Syntax:
27+where `entityName` is one of the following:
28+- dependencies
29+- repo
30+- version
31+-------------------------------
32+let upstream = --
33+in upstream
34+ with packageName.entityName = "new value"
35+-------------------------------
36+
37+Example:
38+-------------------------------
39+let upstream = --
40+in upstream
41+ with halogen.version = "master"
42+ with halogen.repo = "https://example.com/path/to/git/repo.git"
43+
44+ with halogen-vdom.version = "v4.0.0"
45+ with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
46+-------------------------------
47+
48+### Additions
49+
50+Purpose:
51+- Add packages that aren't already included in the default package set
52+
53+Syntax:
54+where `<version>` is:
55+- a tag (i.e. "v4.0.0")
56+- a branch (i.e. "master")
57+- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
58+-------------------------------
59+let upstream = --
60+in upstream
61+ with new-package-name =
62+ { dependencies =
63+ [ "dependency1"
64+ , "dependency2"
65+ ]
66+ , repo =
67+ "https://example.com/path/to/git/repo.git"
68+ , version =
69+ "<version>"
70+ }
71+-------------------------------
72+
73+Example:
74+-------------------------------
75+let upstream = --
76+in upstream
77+ with benchotron =
78+ { dependencies =
79+ [ "arrays"
80+ , "exists"
81+ , "profunctor"
82+ , "strings"
83+ , "quickcheck"
84+ , "lcg"
85+ , "transformers"
86+ , "foldable-traversable"
87+ , "exceptions"
88+ , "node-fs"
89+ , "node-buffer"
90+ , "node-readline"
91+ , "datetime"
92+ , "now"
93+ ]
94+ , repo =
95+ "https://github.com/hdgarrood/purescript-benchotron.git"
96+ , version =
97+ "v7.0.0"
98+ }
99+-------------------------------
100+-}
101+let upstream =
102+ https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230320/packages.dhall
103+ sha256:6f2a4b50b793f304d3a64fd25d631de990de280981c73b0683a090e4fa499f0d
104+
105+in upstream
spago.dhallnew file+14
@@ -0,0 +1,14 @@
1+{ name = "floating-ui"
2+, dependencies =
3+ [ "aff"
4+ , "console"
5+ , "effect"
6+ , "js-promise"
7+ , "js-promise-aff"
8+ , "nullable"
9+ , "prelude"
10+ , "web-dom"
11+ ]
12+, packages = ./packages.dhall
13+, sources = [ "src/**/*.purs", "test/**/*.purs" ]
14+}
src/FloatingUI/FloatingUI.jsnew file+9
@@ -0,0 +1,9 @@
1+import { computePosition, autoUpdate } from "@floating-ui/dom";
2+export { offset, shift as shiftImpl, arrow as arrowImpl } from "@floating-ui/dom";
3+
4+export const computePositionImpl = (referenceEl, floatingEl, options) => {
5+ return computePosition(referenceEl, floatingEl, options);
6+};
7+export const autoUpdateImpl = (referenceEl, floatingEl, update, options) => {
8+ return autoUpdate(referenceEl, floatingEl, update, options);
9+};
src/FloatingUI/FloatingUI.pursnew file+62
@@ -0,0 +1,62 @@
1+module FloatingUI.FloartingUI
2+ ( ArrowOptions
3+ , ArrowPosition
4+ , AutoUpdateOptions
5+ , Middleware
6+ , Options
7+ , Position
8+ , arrow
9+ , autoUpdate
10+ , computePosition
11+ , offset
12+ , shift
13+ )
14+ where
15+
16+import Prelude
17+
18+import Data.Nullable (Nullable)
19+import Effect (Effect)
20+import Effect.Aff (Aff)
21+import Effect.Aff.Compat (EffectFn3, runEffectFn3)
22+import Effect.Uncurried (EffectFn4, runEffectFn4)
23+import Prim.Row (class Union)
24+import Promise (Promise)
25+import Promise.Aff as Promise
26+import Web.DOM (Element)
27+
28+type Position = { x :: Int, y :: Int, arrow :: Nullable ArrowPosition }
29+
30+type ArrowPosition = { x :: Nullable Int, y :: Nullable Int }
31+
32+foreign import data Middleware :: Type
33+
34+foreign import offset :: Int -> Middleware
35+
36+type ShiftOptions = ( padding :: Int )
37+foreign import shiftImpl :: forall options. options -> Middleware
38+
39+shift :: forall head tail. Union head tail ShiftOptions => { | head } -> Middleware
40+shift = shiftImpl
41+
42+type ArrowOptions = ( element :: Element, padding :: Int )
43+foreign import arrowImpl :: forall options. options -> Middleware
44+
45+arrow :: forall head tail. Union head tail ArrowOptions => { | head } -> Middleware
46+arrow = arrowImpl
47+
48+
49+type Options = (middleware :: Array Middleware, placement :: String)
50+
51+type AutoUpdateOptions = {}
52+
53+foreign import computePositionImpl :: forall options. EffectFn3 Element Element options (Promise Position)
54+
55+computePosition ∷ forall head tail. Union head tail Options => Element → Element → { | head } → Aff Position
56+computePosition referenceEl floatingEl options = runEffectFn3 computePositionImpl referenceEl floatingEl options #
57+ Promise.toAffE
58+
59+foreign import autoUpdateImpl :: EffectFn4 Element Element (Effect Unit) AutoUpdateOptions (Effect Unit)
60+
61+autoUpdate :: Element → Element → Effect Unit -> AutoUpdateOptions → Effect (Effect Unit)
62+autoUpdate referenceEl floatingEl update options = runEffectFn4 autoUpdateImpl referenceEl floatingEl update options
test/Main.pursnew file+11
@@ -0,0 +1,11 @@
1+module Test.Main where
2+
3+import Prelude
4+
5+import Effect (Effect)
6+import Effect.Class.Console (log)
7+
8+main :: Effect Unit
9+main = do
10+ log "🍝"
11+ log "You should add some tests."