HS: open/close commands for dialog/details — 428→435
- Parser: open/close commands with optional target (defaults to me) - Compiler: open-element → hs-open!, close-element → hs-close! - Runtime: hs-open! calls showModal() for dialogs, sets open=true for details - Runtime: hs-close! calls close() for dialogs, sets open=false for details - dialog: 1/10 → 8/10 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -827,6 +827,10 @@
|
|||||||
(list (quote dom-remove) (hs-to-sx (nth ast 1))))
|
(list (quote dom-remove) (hs-to-sx (nth ast 1))))
|
||||||
((= head (quote empty-target))
|
((= head (quote empty-target))
|
||||||
(list (quote hs-empty-target!) (hs-to-sx (nth ast 1))))
|
(list (quote hs-empty-target!) (hs-to-sx (nth ast 1))))
|
||||||
|
((= head (quote open-element))
|
||||||
|
(list (quote hs-open!) (hs-to-sx (nth ast 1))))
|
||||||
|
((= head (quote close-element))
|
||||||
|
(list (quote hs-close!) (hs-to-sx (nth ast 1))))
|
||||||
((= head (quote swap!))
|
((= head (quote swap!))
|
||||||
(let
|
(let
|
||||||
((lhs (nth ast 1)) (rhs (nth ast 2)))
|
((lhs (nth ast 1)) (rhs (nth ast 2)))
|
||||||
|
|||||||
@@ -1495,6 +1495,20 @@
|
|||||||
((lhs (parse-expr)))
|
((lhs (parse-expr)))
|
||||||
(match-kw "with")
|
(match-kw "with")
|
||||||
(let ((rhs (parse-expr))) (list (quote swap!) lhs rhs)))))
|
(let ((rhs (parse-expr))) (list (quote swap!) lhs rhs)))))
|
||||||
|
(define
|
||||||
|
parse-open-cmd
|
||||||
|
(fn
|
||||||
|
()
|
||||||
|
(let
|
||||||
|
((target (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end"))) (list (quote me))) (true (parse-expr)))))
|
||||||
|
(list (quote open-element) target))))
|
||||||
|
(define
|
||||||
|
parse-close-cmd
|
||||||
|
(fn
|
||||||
|
()
|
||||||
|
(let
|
||||||
|
((target (cond ((at-end?) (list (quote me))) ((and (= (tp-type) "keyword") (or (= (tp-val) "then") (= (tp-val) "end"))) (list (quote me))) (true (parse-expr)))))
|
||||||
|
(list (quote close-element) target))))
|
||||||
(define
|
(define
|
||||||
parse-cmd
|
parse-cmd
|
||||||
(fn
|
(fn
|
||||||
@@ -1582,6 +1596,10 @@
|
|||||||
(do (adv!) (parse-empty-cmd)))
|
(do (adv!) (parse-empty-cmd)))
|
||||||
((and (= typ "keyword") (= val "swap"))
|
((and (= typ "keyword") (= val "swap"))
|
||||||
(do (adv!) (parse-swap-cmd)))
|
(do (adv!) (parse-swap-cmd)))
|
||||||
|
((and (= typ "keyword") (= val "open"))
|
||||||
|
(do (adv!) (parse-open-cmd)))
|
||||||
|
((and (= typ "keyword") (= val "close"))
|
||||||
|
(do (adv!) (parse-close-cmd)))
|
||||||
(true (parse-expr))))))
|
(true (parse-expr))))))
|
||||||
(define
|
(define
|
||||||
parse-cmd-list
|
parse-cmd-list
|
||||||
@@ -1630,7 +1648,9 @@
|
|||||||
(= v "focus")
|
(= v "focus")
|
||||||
(= v "empty")
|
(= v "empty")
|
||||||
(= v "clear")
|
(= v "clear")
|
||||||
(= v "swap"))))
|
(= v "swap")
|
||||||
|
(= v "open")
|
||||||
|
(= v "close"))))
|
||||||
(define
|
(define
|
||||||
cl-collect
|
cl-collect
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
@@ -475,8 +475,30 @@
|
|||||||
((= tag "FORM") (dom-set-inner-html target ""))
|
((= tag "FORM") (dom-set-inner-html target ""))
|
||||||
(true (dom-set-inner-html target ""))))))))
|
(true (dom-set-inner-html target ""))))))))
|
||||||
;; Collection: split by
|
;; Collection: split by
|
||||||
(define hs-first (fn (lst) (first lst)))
|
(define
|
||||||
|
hs-open!
|
||||||
|
(fn
|
||||||
|
(el)
|
||||||
|
(let
|
||||||
|
((tag (dom-get-prop el "tagName")))
|
||||||
|
(if
|
||||||
|
(= tag "DIALOG")
|
||||||
|
(host-call el "showModal")
|
||||||
|
(dom-set-prop el "open" true)))))
|
||||||
;; Collection: joined by
|
;; Collection: joined by
|
||||||
|
(define
|
||||||
|
hs-close!
|
||||||
|
(fn
|
||||||
|
(el)
|
||||||
|
(let
|
||||||
|
((tag (dom-get-prop el "tagName")))
|
||||||
|
(if
|
||||||
|
(= tag "DIALOG")
|
||||||
|
(host-call el "close")
|
||||||
|
(dom-set-prop el "open" false)))))
|
||||||
|
|
||||||
|
(define hs-first (fn (lst) (first lst)))
|
||||||
|
|
||||||
(define hs-last (fn (lst) (last lst)))
|
(define hs-last (fn (lst) (last lst)))
|
||||||
|
|
||||||
(define
|
(define
|
||||||
|
|||||||
@@ -119,6 +119,8 @@
|
|||||||
"empty"
|
"empty"
|
||||||
"clear"
|
"clear"
|
||||||
"swap"
|
"swap"
|
||||||
|
"open"
|
||||||
|
"close"
|
||||||
"exists"
|
"exists"
|
||||||
"matches"
|
"matches"
|
||||||
"contains"
|
"contains"
|
||||||
|
|||||||
Reference in New Issue
Block a user